19 #include <armarx/navigation/platform_controller/aron/PlatformLocalTrajectoryControllerConfig.aron.generated.h>
29 controllerPlugin_(controllerComponentPlugin), properties_(properties)
36 <<
"Dynamic loading of the controller library is deactivated (and this "
37 "is also desired). If loading the controllers is failing subsequently, "
38 "make sure that the RobotUnit's property `LoadLibraries` contains "
39 "`armarx_navigation:armarx_navigation_platform_controller`.";
57 ARMARX_INFO <<
"Initializing local trajectory controller";
68 "armarx_navigation",
"controller_config/PlatformTrajectory/default.json");
75 "controller_config/PlatformTrajectory/" + properties_.
robotName +
78 if (std::filesystem::exists(robotSpecificConfigPath.
toSystemPath()))
80 return robotSpecificConfigPath;
83 return baseConfigPath;
86 auto ctrlWrapper = builder.withNodeSet(
"PlatformPlanning")
92 localTrajCtrl_ = std::move(ctrlWrapper);
93 localTrajCtrlInitialConfig_ = localTrajCtrl_->config;
98 ARMARX_INFO <<
"Initializing global trajectory controller";
106 builder.withNodeSet(
"PlatformPlanning");
112 "controller_config/GlobalTrajectory/" + properties.
robotName +
".json");
114 if (std::filesystem::exists(robotSpecificConfigPath.
toSystemPath()))
116 ARMARX_INFO <<
"Using robot specific config: " << robotSpecificConfigPath;
117 builder.withConfig(robotSpecificConfigPath.toSystemPath());
122 "armarx_navigation",
"controller_config/GlobalTrajectory/default.json");
126 auto ctrlWrapper = builder.create();
130 globalTrajCtrl_ = std::move(ctrlWrapper);
131 globalTrajCtrlInitialConfig_ = globalTrajCtrl_->config;
145 const bool activateController)
150 toAron(localTrajCtrl_->config.targets.trajectory, trajectory);
153 localTrajCtrl_->updateConfig();
155 if (activateController and not localTrajCtrl_->ctrl()->isControllerActive())
157 ARMARX_INFO <<
"Start local trajectory controller";
159 localTrajCtrl_->activate();
165 const bool activateController)
170 toAron(globalTrajCtrl_->config.targets.trajectory, trajectory);
173 << globalTrajCtrl_->config.targets.trajectory.points.size()
174 <<
" to controller.";
177 globalTrajCtrl_->updateConfig();
179 if (activateController and not globalTrajCtrl_->ctrl()->isControllerActive())
181 globalTrajCtrl_->activate();
189 switch (controllerType)
192 if (globalTrajCtrl_ and not globalTrajCtrl_->ctrl()->isControllerActive())
194 globalTrajCtrl_->activate();
198 if (localTrajCtrl_ and not localTrajCtrl_->ctrl()->isControllerActive())
200 localTrajCtrl_->activate();
212 switch (controllerType)
217 if (not globalTrajCtrl_->ctrl()->isControllerActive())
220 <<
"The global trajectory controller is not active but "
221 "should be. Activating now.";
222 globalTrajCtrl_->activate();
229 if (not localTrajCtrl_->ctrl()->isControllerActive())
232 <<
"The local trajectory controller is not active but "
233 "should be. Activating now.";
234 localTrajCtrl_->activate();
249 if (localTrajCtrl_->ctrl()->isControllerActive())
251 ARMARX_INFO <<
"Stopping local trajectory controller.";
252 localTrajCtrl_->deactivate();
256 if (globalTrajCtrl_->ctrl()->isControllerActive())
258 ARMARX_INFO <<
"Stopping global trajectory controller.";
259 globalTrajCtrl_->deactivate();
264 const auto platformUnitPrx =
268 ARMARX_INFO <<
"Stopping platform via PlatformUnit";
269 platformUnitPrx->stopPlatform();
277 if (localTrajCtrl_->ctrl()->isControllerActive())
280 localTrajCtrl_->config.params.limits.linear =
281 std::min(limits.
linear, localTrajCtrlInitialConfig_.params.limits.linear);
282 localTrajCtrl_->config.params.limits.angular =
283 std::min(limits.
angular, localTrajCtrlInitialConfig_.params.limits.angular);
285 localTrajCtrl_->updateConfig();
288 if (globalTrajCtrl_->ctrl()->isControllerActive())
291 globalTrajCtrl_->config.params.limits.linear =
292 std::min(limits.
linear, globalTrajCtrlInitialConfig_.params.limits.linear);
293 globalTrajCtrl_->config.params.limits.angular =
294 std::min(limits.
angular, globalTrajCtrlInitialConfig_.params.limits.angular);
296 globalTrajCtrl_->updateConfig();