30 #include <Eigen/Geometry>
50 robotName = getProperty<std::string>(
"RobotName").getValue();
51 platformName = getProperty<std::string>(
"PlatformName").getValue();
53 simulatorPrxName = getProperty<std::string>(
"SimulatorProxyName").getValue();
58 intervalMs = getProperty<int>(
"IntervalMs").getValue();
66 "PlatformUnitSimulation");
71 std::string robotTopicName =
"Simulator_Robot_";
73 ARMARX_INFO <<
"Simulator Robot topic: " << robotTopicName;
123 Eigen::Vector3f curV)
126 <<
", curVel:" << curV.transpose() <<
", linearVelocityMax:" <<
linearVelocityMax
132 return Eigen::Vector3f::Zero();
143 <<
",distance.normalized()=" <<
distance.normalized() <<
flush;
144 return Eigen::Vector3f::Zero();
148 Eigen::Vector3f
a = (
v - curV);
150 if ((
v - curV).norm() > 1e-5)
157 ARMARX_ERROR <<
"NAN in platform calculation, a=" <<
a <<
", (v - curV)=" << (
v - curV)
158 <<
",(v - curV).normalized()=" << (
v - curV).normalized() <<
flush;
159 return Eigen::Vector3f::Zero();
172 <<
", curVel:" << curV <<
flush;
173 const float M_2PI = 2 *
M_PI;
176 float minDist = (cw < ccw) ? -cw : ccw;
185 float a = (
v - curV);
198 static Eigen::Vector2f
199 transformToLocalVelocity(
float currentRotation,
float velX,
float velY)
202 return Eigen::Rotation2Df(-currentRotation) * Eigen::Vector2f(velX, velY);
208 Eigen::Vector3f relTargetPosition;
209 Eigen::Vector3f curLinVel;
210 float curAngVel = 0.f;
233 Vector3Ptr p = Vector3Ptr::dynamicCast(state.pose->position);
237 Vector3BasePtr
v = state.linearVelocity;
238 Vector3BasePtr o = state.angularVelocity;
244 Eigen::Vector2f localVelocity =
253 const Eigen::Vector3f desiredLinVel =
255 const float desiredAngVel =
273 const Ice::Current&
c)
290 float targetPlatformVelocityY,
291 float targetPlatformVelocityRotation,
292 const Ice::Current&
c)
295 targetPlatformVelocityRotation *= 5;
297 Eigen::Vector3f translationVel;
299 translationVel << targetPlatformVelocityX, targetPlatformVelocityY, 0;
300 translationVel *= .003;
308 new Vector3(Eigen::Vector3f(0.f, 0.f, targetPlatformVelocityRotation)));
313 float targetPlatformOffsetY,
314 float targetPlatformOffsetRotation,
315 float positionalAccuracy,
316 float orientationalAccuracy,
317 const Ice::Current&
c)
337 float angularVelocity,
338 const Ice::Current&
c)
354 Vector3Ptr newPosition = Vector3Ptr::dynamicCast(newPose->position);
361 QuaternionPtr newOrientation = QuaternionPtr::dynamicCast(newPose->orientation);
367 currentRotation = copysign(std::acos(rotMat(0, 0)), std::asin(rotMat(1, 0)));
377 const Vector3BasePtr& rotationVel)
389 ARMARX_DEBUG <<
"currentRotationVelocity (only z is used): " << rotationVel->x <<
","
390 << rotationVel->x <<
"," << rotationVel->z;
403 ::armarx::TransformStamped transformStamped;
407 header.frame =
"root";
409 header.timestampInMicroSeconds = state.timestampInMicroSeconds;
411 TransformStamped globalRobotPose;
412 globalRobotPose.header = header;
423 Eigen::Vector2f localVelocity =
435 def->defineOptionalProperty<
int>(
436 "IntervalMs", 100,
"The time in milliseconds between two calls to the simulation method.");
439 def->defineOptionalProperty<
float>(
440 "LinearVelocityMin", 0.5,
"Minimum Linear velocity of the platform (unit: m/sec).");
441 def->defineOptionalProperty<
float>(
442 "LinearVelocityMax", 1.5,
"Maximum Linear velocity of the platform (unit: m/sec).");
443 def->defineOptionalProperty<
float>(
444 "LinearAccelerationMax", 0.9,
"Maximum Linear Acceleration (unit: m/sec^2");
445 def->defineOptionalProperty<
float>(
446 "AngularVelocityMax", 0.8,
"Maximum Angular velocity of the platform (unit: rad/sec).");
447 def->defineOptionalProperty<
float>(
448 "AngularAccelerationMax", 1.9,
"Maximum Angular Acceleration (unit: rad/sec^2");
449 def->defineOptionalProperty<
float>(
450 "PlatformOrientationOffset", 0,
"Rotation offset of the platform (unit: rad).");
451 def->defineOptionalProperty<std::string>(
"RobotName",
"Armar3",
"Name of the Robot to use.");
452 def->defineOptionalProperty<std::string>(
453 "PlatformName",
"Platform",
"Name of the Platform node to use.");
454 def->defineOptionalProperty<std::string>(
455 "SimulatorProxyName",
"Simulator",
"Name of the simulator proxy to use.");