30 #include <Eigen/Geometry>
46 robotName = getProperty<std::string>(
"RobotName").getValue();
47 platformName = getProperty<std::string>(
"PlatformName").getValue();
49 simulatorPrxName = getProperty<std::string>(
"SimulatorProxyName").getValue();
54 intervalMs = getProperty<int>(
"IntervalMs").getValue();
61 std::string robotTopicName =
"Simulator_Robot_";
63 ARMARX_INFO <<
"Simulator Robot topic: " << robotTopicName;
117 return Eigen::Vector3f::Zero();
128 return Eigen::Vector3f::Zero();
132 Eigen::Vector3f
a = (
v - curV);
134 if ((
v - curV).norm() > 1e-5)
141 ARMARX_ERROR <<
"NAN in platform calculation, a=" <<
a <<
", (v - curV)=" << (
v - curV) <<
",(v - curV).normalized()=" << (
v - curV).normalized() <<
flush;
142 return Eigen::Vector3f::Zero();
154 const float M_2PI = 2 *
M_PI;
157 float minDist = (cw < ccw) ? -cw : ccw;
166 float a = (
v - curV);
178 static Eigen::Vector2f transformToLocalVelocity(
float currentRotation,
float velX,
float velY)
181 return Eigen::Rotation2Df(-currentRotation) * Eigen::Vector2f(velX, velY);
186 Eigen::Vector3f relTargetPosition;
187 Eigen::Vector3f curLinVel;
188 float curAngVel = 0.f;
211 Vector3Ptr p = Vector3Ptr::dynamicCast(state.pose->position);
214 Vector3BasePtr
v = state.linearVelocity;
215 Vector3BasePtr o = state.angularVelocity;
254 targetPlatformVelocityRotation *= 5;
256 Eigen::Vector3f translationVel;
258 translationVel << targetPlatformVelocityX, targetPlatformVelocityY, 0;
259 translationVel *= .003;
296 Vector3Ptr newPosition = Vector3Ptr::dynamicCast(newPose->position);
303 QuaternionPtr newOrientation = QuaternionPtr::dynamicCast(newPose->orientation);
309 currentRotation = copysign(std::acos(rotMat(0, 0)), std::asin(rotMat(1, 0)));
328 ARMARX_DEBUG <<
"currentRotationVelocity (only z is used): " << rotationVel->x <<
"," << rotationVel->x <<
"," << rotationVel->z;
340 ::armarx::TransformStamped transformStamped;
344 header.frame =
"root";
346 header.timestampInMicroSeconds = state.timestampInMicroSeconds;
348 TransformStamped globalRobotPose;
349 globalRobotPose.header = header;
369 def->defineOptionalProperty<
int>(
"IntervalMs", 100,
"The time in milliseconds between two calls to the simulation method.");
372 def->defineOptionalProperty<
float>(
"LinearVelocityMin", 0.5,
"Minimum Linear velocity of the platform (unit: m/sec).");
373 def->defineOptionalProperty<
float>(
"LinearVelocityMax", 1.5,
"Maximum Linear velocity of the platform (unit: m/sec).");
374 def->defineOptionalProperty<
float>(
"LinearAccelerationMax", 0.9,
"Maximum Linear Acceleration (unit: m/sec^2");
375 def->defineOptionalProperty<
float>(
"AngularVelocityMax", 0.8,
"Maximum Angular velocity of the platform (unit: rad/sec).");
376 def->defineOptionalProperty<
float>(
"AngularAccelerationMax", 1.9,
"Maximum Angular Acceleration (unit: rad/sec^2");
377 def->defineOptionalProperty<
float>(
"PlatformOrientationOffset", 0,
"Rotation offset of the platform (unit: rad).");
378 def->defineOptionalProperty<std::string>(
"RobotName",
"Armar3",
"Name of the Robot to use.");
379 def->defineOptionalProperty<std::string>(
"PlatformName",
"Platform",
"Name of the Platform node to use.");
380 def->defineOptionalProperty<std::string>(
"SimulatorProxyName",
"Simulator",
"Name of the simulator proxy to use.");