29 controllerPlugin_(controllerComponentPlugin), properties_(properties)
33 if (properties_.rtUnitDynamicallyLoadLibraries)
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";
60 auto builder = controllerPlugin_.createControllerBuilder<
61 armarx::navigation::common::ControllerType::PlatformLocalTrajectory>();
65 const armarx::PackagePath configPath = [&]() -> armarx::PackagePath
67 const armarx::PackagePath baseConfigPath(
68 "armarx_navigation",
"controller_config/PlatformTrajectory/default.json");
70 ARMARX_CHECK(std::filesystem::exists(baseConfigPath.toSystemPath()))
73 const armarx::PackagePath robotSpecificConfigPath(
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")
87 .withConfig(configPath.toSystemPath())
92 localTrajCtrl_ = std::move(ctrlWrapper);
93 localTrajCtrlInitialConfig_ = localTrajCtrl_->config;
98 ARMARX_INFO <<
"Initializing global trajectory controller";
101 auto builder = controllerPlugin_.createControllerBuilder<
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");
123 builder.withConfig(configPath.toSystemPath());
126 auto ctrlWrapper = builder.create();
130 globalTrajCtrl_ = std::move(ctrlWrapper);
131 globalTrajCtrlInitialConfig_ = globalTrajCtrl_->config;
249 ARMARX_INFO <<
"Stopping local trajectory controller (if available and active)";
250 if (localTrajCtrl_ && localTrajCtrl_->ctrl() &&
251 localTrajCtrl_->ctrl()->isControllerActive())
253 ARMARX_INFO <<
"Stopping local trajectory controller.";
254 localTrajCtrl_->deactivate();
259 ARMARX_INFO <<
"Local trajectory controller was not available or active.";
262 ARMARX_INFO <<
"Stopping global trajectory controller (if available and active)";
263 if (globalTrajCtrl_ && globalTrajCtrl_->ctrl() &&
264 globalTrajCtrl_->ctrl()->isControllerActive())
266 ARMARX_INFO <<
"Stopping global trajectory controller.";
267 globalTrajCtrl_->deactivate();
272 ARMARX_INFO <<
"Global trajectory controller was not available or active.";
276 auto robotUnit = controllerPlugin_.getRobotUnitPlugin().getRobotUnit();
279 const auto platformUnitPrx = robotUnit->getPlatformUnit();
282 ARMARX_INFO <<
"Stopping platform via PlatformUnit";
283 platformUnitPrx->stopPlatform();
287 ARMARX_WARNING <<
"PlatformUnit proxy not available, cannot stop platform";
292 ARMARX_INFO <<
"RobotUnit not available, cannot stop platform";
300 if (localTrajCtrl_->ctrl()->isControllerActive())
303 localTrajCtrl_->config.params.limits.linear =
304 std::min(limits.
linear, localTrajCtrlInitialConfig_.params.limits.linear);
305 localTrajCtrl_->config.params.limits.angular =
306 std::min(limits.
angular, localTrajCtrlInitialConfig_.params.limits.angular);
308 localTrajCtrl_->updateConfig();
311 if (globalTrajCtrl_->ctrl()->isControllerActive())
314 globalTrajCtrl_->config.params.limits.linear =
315 std::min(limits.
linear, globalTrajCtrlInitialConfig_.params.limits.linear);
316 globalTrajCtrl_->config.params.limits.angular =
317 std::min(limits.
angular, globalTrajCtrlInitialConfig_.params.limits.angular);
319 globalTrajCtrl_->updateConfig();
327 <<
"Scaling factor may not be negative, but is " << velocityFactor;
329 <<
"Scaling factor may not be > 1, but is " << velocityFactor;
331 if (localTrajCtrl_->ctrl()->isControllerActive())
333 localTrajCtrl_->config.params.velocityFactor = velocityFactor;
335 localTrajCtrl_->updateConfig();
338 if (globalTrajCtrl_->ctrl()->isControllerActive())
340 globalTrajCtrl_->config.params.velocityFactor = velocityFactor;
342 globalTrajCtrl_->updateConfig();