32#include <Eigen/Geometry>
68 "PlatformUnitSimulation");
73 std::string robotTopicName =
"Simulator_Robot_";
75 ARMARX_INFO <<
"Simulator Robot topic: " << robotTopicName;
125 Eigen::Vector3f curV)
128 <<
", curVel:" << curV.transpose() <<
", linearVelocityMax:" <<
linearVelocityMax
134 return Eigen::Vector3f::Zero();
145 <<
",distance.normalized()=" <<
distance.normalized() <<
flush;
146 return Eigen::Vector3f::Zero();
150 Eigen::Vector3f a = (v - curV);
152 if ((v - curV).
norm() > 1e-5)
159 ARMARX_ERROR <<
"NAN in platform calculation, a=" << a <<
", (v - curV)=" << (v - curV)
160 <<
",(v - curV).normalized()=" << (v - curV).normalized() <<
flush;
161 return Eigen::Vector3f::Zero();
173 ARMARX_DEBUG <<
"calc platform ang vel, from:" << source <<
" to:" << target
174 <<
", curVel:" << curV <<
flush;
175 const float M_2PI = 2 *
M_PI;
176 float cw = fmod(source - target + M_2PI, M_2PI);
177 float ccw = fmod(target - source + M_2PI, M_2PI);
178 float minDist = (cw < ccw) ? -cw : ccw;
187 float a = (v - curV);
200static Eigen::Vector2f
201transformToLocalVelocity(
float currentRotation,
float velX,
float velY)
204 return Eigen::Rotation2Df(-currentRotation) * Eigen::Vector2f(velX, velY);
210 Eigen::Vector3f relTargetPosition;
211 Eigen::Vector3f curLinVel;
212 float curAngVel = 0.f;
235 Vector3Ptr p = Vector3Ptr::dynamicCast(state.pose->position);
239 Vector3BasePtr v = state.linearVelocity;
240 Vector3BasePtr o = state.angularVelocity;
246 Eigen::Vector2f localVelocity =
255 const Eigen::Vector3f desiredLinVel =
257 const float desiredAngVel =
271 Ice::Float targetPlatformPositionY,
272 Ice::Float targetPlatformRotation,
275 const Ice::Current&
c)
292 float targetPlatformVelocityY,
293 float targetPlatformVelocityRotation,
294 const Ice::Current&
c)
297 targetPlatformVelocityRotation *= 5;
299 Eigen::Vector3f translationVel;
301 translationVel << targetPlatformVelocityX, targetPlatformVelocityY, 0;
302 translationVel *= .003;
310 new Vector3(Eigen::Vector3f(0.f, 0.f, targetPlatformVelocityRotation)));
315 float targetPlatformOffsetY,
316 float targetPlatformOffsetRotation,
319 const Ice::Current&
c)
339 float angularVelocity,
340 const Ice::Current&
c)
356 Vector3Ptr newPosition = Vector3Ptr::dynamicCast(newPose->position);
363 QuaternionPtr newOrientation = QuaternionPtr::dynamicCast(newPose->orientation);
368 Eigen::Matrix3f rotMat = newOrientation->toEigen();
369 currentRotation = copysign(std::acos(rotMat(0, 0)), std::asin(rotMat(1, 0)));
379 const Vector3BasePtr& rotationVel)
391 ARMARX_DEBUG <<
"currentRotationVelocity (only z is used): " << rotationVel->x <<
","
392 << rotationVel->x <<
"," << rotationVel->z;
405 ::armarx::TransformStamped transformStamped;
409 header.frame =
"root";
411 header.timestampInMicroSeconds = state.timestampInMicroSeconds;
413 TransformStamped globalRobotPose;
414 globalRobotPose.header = header;
425 Eigen::Vector2f localVelocity =
437 def->defineOptionalProperty<
int>(
438 "IntervalMs", 100,
"The time in milliseconds between two calls to the simulation method.");
441 def->defineOptionalProperty<
float>(
442 "LinearVelocityMin", 0.5,
"Minimum Linear velocity of the platform (unit: m/sec).");
443 def->defineOptionalProperty<
float>(
444 "LinearVelocityMax", 1.5,
"Maximum Linear velocity of the platform (unit: m/sec).");
445 def->defineOptionalProperty<
float>(
446 "LinearAccelerationMax", 0.9,
"Maximum Linear Acceleration (unit: m/sec^2");
447 def->defineOptionalProperty<
float>(
448 "AngularVelocityMax", 0.8,
"Maximum Angular velocity of the platform (unit: rad/sec).");
449 def->defineOptionalProperty<
float>(
450 "AngularAccelerationMax", 1.9,
"Maximum Angular Acceleration (unit: rad/sec^2");
451 def->defineOptionalProperty<
float>(
452 "PlatformOrientationOffset", 0,
"Rotation offset of the platform (unit: rad).");
453 def->defineOptionalProperty<std::string>(
"RobotName",
"Armar3",
"Name of the Robot to use.");
454 def->defineOptionalProperty<std::string>(
455 "PlatformName",
"Platform",
"Name of the Platform node to use.");
456 def->defineOptionalProperty<std::string>(
457 "SimulatorProxyName",
"Simulator",
"Name of the simulator proxy to use.");
465 return "PlatformUnitDynamicSimulation";
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Property< PropertyType > getProperty(const std::string &name)
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
The periodic task executes one thread method repeatedly using the time period specified in the constr...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
#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.
IceInternal::Handle< Vector3 > Vector3Ptr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< Quaternion > QuaternionPtr
const LogSender::manipulator flush
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
bool isfinite(const std::vector< T, Ts... > &v)
double norm(const Point &a)
double distance(const Point &a, const Point &b)