30 #include <Eigen/Geometry>
32 #include <VirtualRobot/MathTools.h>
37 #include <RobotAPI/interface/core/GeometryBase.h>
38 #include <RobotAPI/interface/units/PlatformUnitInterface.h>
48 def->defineOptionalProperty<
int>(
51 "The time in milliseconds between two calls to the simulation method.");
52 def->defineOptionalProperty<
float>(
53 "InitialRotation", 0,
"Initial rotation of the platform.");
54 def->defineOptionalProperty<
float>(
55 "InitialPosition.x", 0,
"Initial x position of the platform.");
56 def->defineOptionalProperty<
float>(
57 "InitialPosition.y", 0,
"Initial y position of the platform.");
58 def->defineOptionalProperty<std::string>(
61 "Reference frame in which the platform position is reported.");
62 def->defineOptionalProperty<
float>(
63 "LinearVelocity", 1000.0,
"Linear velocity of the platform (default: 1000 mm/sec).");
64 def->defineOptionalProperty<
float>(
65 "MaxLinearAcceleration",
67 "Linear acceleration of the platform (default: 1000 mm/sec).");
68 def->defineOptionalProperty<
float>(
69 "Kp_Position", 5.0,
"P value of the PID position controller");
70 def->defineOptionalProperty<
float>(
71 "Kp_Velocity", 5.0,
"P value of the PID velocity controller");
72 def->defineOptionalProperty<
float>(
73 "AngularVelocity", 1.5,
"Angular velocity of the platform (default: 1.5 rad/sec).");
75 def->component(robotStateComponent);
84 referenceFrame = getProperty<std::string>(
"ReferenceFrame").getValue();
97 getProperty<float>(
"MaxLinearAcceleration").getValue()));
103 getProperty<float>(
"MaxLinearAcceleration").getValue()));
108 intervalMs = getProperty<int>(
"IntervalMs").getValue();
115 "PlatformUnitSimulation");
119 PlatformUnitSimulation::currentPlatformPose()
const
121 return VirtualRobot::MathTools::posrpy2eigen4f(
128 agentName = robotStateComponent->getRobotName();
129 robotRootFrame = robotStateComponent->getSynchronizedRobot()->getRootNode()->getName();
131 TransformStamped currentPose;
133 currentPose.header.frame = robotRootFrame;
134 currentPose.header.agent = agentName;
135 currentPose.header.timestampInMicroSeconds =
TimeUtil::GetTime().toMicroSeconds();
136 currentPose.transform = currentPlatformPose();
168 std::vector<float> vel(3, 0.0f);
175 posPID->update(timeDeltaInSeconds,
178 float newXTickMotion =
posPID->getControlValue()[0] * timeDeltaInSeconds;
181 vel[0] =
posPID->getControlValue()[0];
182 vel[1] =
posPID->getControlValue()[1];
211 targetVel = rot * targetVel;
241 FrameHeader odomVelocityHeader;
242 odomVelocityHeader.parentFrame = robotRootFrame;
243 odomVelocityHeader.frame = robotRootFrame;
244 odomVelocityHeader.agent = agentName;
245 odomVelocityHeader.timestampInMicroSeconds =
TimeUtil::GetTime().toMicroSeconds();
249 FrameHeader odomPoseHeader;
251 odomPoseHeader.frame = robotRootFrame;
252 odomPoseHeader.agent = agentName;
269 TransformStamped currentPose;
271 currentPose.header.frame = robotRootFrame;
272 currentPose.header.agent = agentName;
273 currentPose.header.timestampInMicroSeconds =
TimeUtil::GetTime().toMicroSeconds();
274 currentPose.transform = currentPlatformPose();
282 listenerPrx->reportPlatformVelocity(velo.linear.x(), velo.linear.y(), velo.angular.z());
291 const Ice::Current&
c)
293 ARMARX_INFO <<
"new target pose : " << targetPlatformPositionX <<
", "
294 << targetPlatformPositionY <<
" with angle " << targetPlatformRotation;
308 header.frame = robotRootFrame;
309 header.agent = agentName;
311 TransformStamped targetPose;
312 targetPose.header = header;
313 targetPose.transform = VirtualRobot::MathTools::posrpy2eigen4f(
319 float targetPlatformVelocityY,
320 float targetPlatformVelocityRotation,
321 const Ice::Current&
c)
324 << targetPlatformVelocityY
325 <<
" with angular velocity: " << targetPlatformVelocityRotation;
326 std::unique_lock lock(currentPoseMutex);
327 platformMode = eVelocityControl;
328 linearVelocityX =
std::min(maxLinearVelocity, targetPlatformVelocityX);
329 linearVelocityY =
std::min(maxLinearVelocity, targetPlatformVelocityY);
330 angularVelocity =
std::min(maxAngularVelocity, targetPlatformVelocityRotation);
335 float targetPlatformOffsetY,
336 float targetPlatformOffsetRotation,
337 float positionalAccuracy,
338 float orientationalAccuracy,
339 const Ice::Current&
c)
357 float orientaionalVelocity,
358 const Ice::Current&
c)