5 #include <Ice/Current.h>
6 #include <IceUtil/Time.h>
8 #include <VirtualRobot/VirtualRobot.h>
14 #include <ArmarXCore/interface/core/ManagedIceObjectDefinitions.h>
15 #include <ArmarXCore/interface/observers/ObserverInterface.h>
16 #include <ArmarXCore/interface/observers/VariantBase.h>
17 #include <ArmarXCore/interface/serialization/Eigen/Eigen_fdi.h>
25 #include <RobotAPI/interface/units/RobotUnit/NJointController.h>
26 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
29 #include <armarx/navigation/platform_controller/aron/PlatformLocalTrajectoryControllerConfig.aron.generated.h>
34 const NJointControllerRegistration<Controller>
Registration(
38 const NJointControllerConfigPtr& config,
45 ConfigPtrT cfg = ConfigPtrT::dynamicCast(config);
54 ControlModes::HolonomicPlatformVelocity)
57 <<
"The actuator " << robotUnit->getRobotPlatformName() <<
" has no control mode "
58 << ControlModes::HolonomicPlatformVelocity;
60 const auto configData = ::armarx::fromAron<arondto::Config, Config>(cfg->config);
61 const auto trajectoryFollowingControllerParams = configData.params;
67 trajectoryFollowingController.emplace(trajectoryFollowingControllerParams);
91 robotStateBuffer_rtToAdditionalTask.
getWriteBuffer().global_T_robot.matrix() =
98 const Ice::Current& iceCurrent)
104 const auto updateConfig = ::armarx::fromAron<arondto::Config, Config>(dto);
107 configBuffer_updateConfigToAdditionalTask.
commitWrite();
110 configBuffer_updateConfigToOnPublish.
commitWrite();
120 ARMARX_CHECK(trajectoryFollowingController.has_value());
122 const auto& configBuffer =
126 if (configBuffer.targets.trajectory.points().empty())
130 filteredTwist.
reset();
138 const auto result = trajectoryFollowingController->control(
139 configBuffer.targets.trajectory,
144 const float alpha = configBuffer.params.alpha;
146 alpha * filteredTwist.
linear + (1. - alpha) * result.twist.linear.head<2>();
148 alpha * filteredTwist.
angular + (1. - alpha) * result.twist.angular.z();
156 targetBuffer_additionalTaskToOnPublish.
getWriteBuffer() = filteredTwist;
157 targetBuffer_additionalTaskToOnPublish.
commitWrite();
169 datafields[
"vx"] =
new Variant(targets.linear.x());
170 datafields[
"vy"] =
new Variant(targets.linear.y());
171 datafields[
"vyaw"] =
new Variant(targets.angular);
172 datafields[
"trajectory_points"] =
174 .targets.trajectory.points()
177 debugObservers->setDebugChannel(
185 runTask(
"PlatformTrajectoryControllerAdditionalTask",
190 ARMARX_IMPORTANT <<
"Create a new thread alone PlatformTrajectory controller";
191 while (
getState() == eManagedIceObjectStarted)
198 c.waitForCycleDuration();
202 ARMARX_INFO <<
"PlatformTrajectoryVelocityController::onInitNJointController";
209 filteredTwist.
reset();
211 robotStateBuffer_rtToAdditionalTask.
getWriteBuffer().global_T_robot.matrix() =
221 rtReady.store(
false);