35 "SimulatorName",
"Simulator",
"Name of the simulator component that should be used");
37 "RobotStateComponent",
38 "Name of the robot state component that should be used");
75IMUSimulation::frameAcquisitionTaskLoop()
79 auto robotLinearVelocityAsync =
80 simulator->begin_getRobotLinearVelocity(robotStateComponent->getRobotName(), nodeName);
81 auto robotAngularVelocityAsync =
82 simulator->begin_getRobotAngularVelocity(robotStateComponent->getRobotName(), nodeName);
84 SharedRobotNodeInterfacePrx robotNode =
85 robotStateComponent->getSynchronizedRobot()->getRobotNode(nodeName);
86 FramedPoseBasePtr poseInRootFrame = robotNode->getGlobalPose();
89 QuaternionPtr::dynamicCast(poseInRootFrame->orientation)->toEigenQuaternion();
90 Eigen::Vector3f currentPosition =
91 Vector3Ptr::dynamicCast(poseInRootFrame->position)->toEigen() / 1000.0;
93 float deltaTime = (now->timestamp -
timestamp) * std::pow(10, -6);
95 Vector3BasePtr robotLinearVelocity =
96 simulator->end_getRobotLinearVelocity(robotLinearVelocityAsync);
97 Vector3BasePtr robotAngularVelocity =
98 simulator->end_getRobotAngularVelocity(robotAngularVelocityAsync);
102 Eigen::Vector3f currentLinearVelocity =
103 orientation.toRotationMatrix().transpose() *
104 Vector3Ptr::dynamicCast(robotLinearVelocity)->
toEigen() / 1000.0f;
105 Eigen::Vector3f angularVelocity = orientation.toRotationMatrix().transpose() *
106 Vector3Ptr::dynamicCast(robotAngularVelocity)->
toEigen();
111 Eigen::Vector3f acceleration = (currentLinearVelocity - linearVelocity) / deltaTime;
115 data.acceleration.push_back(acceleration(0));
116 data.acceleration.push_back(acceleration(1));
117 data.acceleration.push_back(acceleration(2));
119 data.gyroscopeRotation.push_back(angularVelocity(0));
120 data.gyroscopeRotation.push_back(angularVelocity(1));
121 data.gyroscopeRotation.push_back(angularVelocity(2));
123 data.magneticRotation.push_back(0.0);
124 data.magneticRotation.push_back(0.0);
125 data.magneticRotation.push_back(0.0);
127 data.orientationQuaternion.push_back(currentOrientation.w());
128 data.orientationQuaternion.push_back(currentOrientation.x());
129 data.orientationQuaternion.push_back(currentOrientation.y());
130 data.orientationQuaternion.push_back(currentOrientation.z());
135 orientation = currentOrientation;
136 position = currentPosition;
138 linearVelocity = currentLinearVelocity;
144 return "IMUSimulation";
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
IMUSimulationPropertyDefinitions(std::string prefix)
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onExitIMU() override
void onStartIMU() override
void onInitIMU() override
std::string getDefaultName() const override
InertialMeasurementUnitPropertyDefinitions(std::string prefix)
InertialMeasurementUnitListenerPrx IMUTopicPrx
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
std::string getName() const
Retrieve name of object.
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...
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Eigen::Matrix3f toEigen() const
static TimestampVariantPtr nowPtr()
Quaternion< float, 0 > Quaternionf
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< TimestampVariant > TimestampVariantPtr