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);
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;
256 TransformStamped platformPose;
257 platformPose.header = odomPoseHeader;
258 platformPose.transform = currentPlatformPose();
260 TwistStamped platformVelocity;
261 platformVelocity.header = odomVelocityHeader;
262 platformVelocity.twist.linear << vel[0], vel[1], 0;
263 platformVelocity.twist.angular << 0, 0, vel[2];
266 odometryPrx->reportOdometryVelocity(platformVelocity);
269 TransformStamped currentPose;
271 currentPose.header.frame = robotRootFrame;
272 currentPose.header.agent = agentName;
273 currentPose.header.timestampInMicroSeconds =
TimeUtil::GetTime().toMicroSeconds();
274 currentPose.transform = currentPlatformPose();
281 const auto& velo = platformVelocity.twist;
282 listenerPrx->reportPlatformVelocity(velo.linear.x(), velo.linear.y(), velo.angular.z());
287 Ice::Float targetPlatformPositionY,
288 Ice::Float targetPlatformRotation,
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;
335 float targetPlatformOffsetY,
336 float targetPlatformOffsetRotation,
339 const Ice::Current&
c)
357 float orientaionalVelocity,
358 const Ice::Current&
c)
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Property< PropertyType > getProperty(const std::string &name)
The periodic task executes one thread method repeatedly using the time period specified in the constr...
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_VERBOSE
The logging level for verbose information.
std::string const GlobalFrame
Variable of the global coordinate system.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::string const OdometryFrame
MultiDimPIDControllerTemplate<> MultiDimPIDController
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.