30#include <Eigen/Geometry>
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();
171 ARMARX_DEBUG <<
"calc platform ang vel, from:" << source <<
" to:" << target
172 <<
", curVel:" << curV <<
flush;
173 const float M_2PI = 2 *
M_PI;
174 float cw = fmod(source - target + M_2PI, M_2PI);
175 float ccw = fmod(target - source + M_2PI, M_2PI);
176 float minDist = (cw < ccw) ? -cw : ccw;
185 float a = (v - curV);
198static Eigen::Vector2f
199transformToLocalVelocity(
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 =
269 Ice::Float targetPlatformPositionY,
270 Ice::Float targetPlatformRotation,
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,
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);
366 Eigen::Matrix3f rotMat = newOrientation->toEigen();
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.");
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)