36 "SimulatorName",
"Simulator",
"Name of the simulator component that should be used");
38 "RobotStateComponent",
39 "Name of the robot state component that should be used");
76IMUSimulation::frameAcquisitionTaskLoop()
80 auto robotLinearVelocityAsync =
81 simulator->begin_getRobotLinearVelocity(robotStateComponent->getRobotName(), nodeName);
82 auto robotAngularVelocityAsync =
83 simulator->begin_getRobotAngularVelocity(robotStateComponent->getRobotName(), nodeName);
85 SharedRobotNodeInterfacePrx robotNode =
86 robotStateComponent->getSynchronizedRobot()->getRobotNode(nodeName);
87 FramedPoseBasePtr poseInRootFrame = robotNode->getGlobalPose();
90 QuaternionPtr::dynamicCast(poseInRootFrame->orientation)->toEigenQuaternion();
91 Eigen::Vector3f currentPosition =
92 Vector3Ptr::dynamicCast(poseInRootFrame->position)->toEigen() / 1000.0;
94 float deltaTime = (now->timestamp -
timestamp) * std::pow(10, -6);
96 Vector3BasePtr robotLinearVelocity =
97 simulator->end_getRobotLinearVelocity(robotLinearVelocityAsync);
98 Vector3BasePtr robotAngularVelocity =
99 simulator->end_getRobotAngularVelocity(robotAngularVelocityAsync);
103 Eigen::Vector3f currentLinearVelocity =
104 orientation.toRotationMatrix().transpose() *
105 Vector3Ptr::dynamicCast(robotLinearVelocity)->
toEigen() / 1000.0f;
106 Eigen::Vector3f angularVelocity = orientation.toRotationMatrix().transpose() *
107 Vector3Ptr::dynamicCast(robotAngularVelocity)->
toEigen();
112 Eigen::Vector3f acceleration = (currentLinearVelocity - linearVelocity) / deltaTime;
116 data.acceleration.push_back(acceleration(0));
117 data.acceleration.push_back(acceleration(1));
118 data.acceleration.push_back(acceleration(2));
120 data.gyroscopeRotation.push_back(angularVelocity(0));
121 data.gyroscopeRotation.push_back(angularVelocity(1));
122 data.gyroscopeRotation.push_back(angularVelocity(2));
124 data.magneticRotation.push_back(0.0);
125 data.magneticRotation.push_back(0.0);
126 data.magneticRotation.push_back(0.0);
128 data.orientationQuaternion.push_back(currentOrientation.w());
129 data.orientationQuaternion.push_back(currentOrientation.x());
130 data.orientationQuaternion.push_back(currentOrientation.y());
131 data.orientationQuaternion.push_back(currentOrientation.z());
136 orientation = currentOrientation;
137 position = currentPosition;
139 linearVelocity = currentLinearVelocity;
145 return "IMUSimulation";
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
IMUSimulationPropertyDefinitions(std::string prefix)
Brief description of class IMUSimulation.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onExitIMU() override
void onStartIMU() override
void onInitIMU() override
static std::string GetDefaultName()
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