33 defineOptionalProperty<std::string>(
"nodeName",
"HeadIMU",
"");
34 defineOptionalProperty<std::string>(
35 "SimulatorName",
"Simulator",
"Name of the simulator component that should be used");
36 defineOptionalProperty<std::string>(
"RobotStateComponentName",
37 "RobotStateComponent",
38 "Name of the robot state component that should be used");
44 usingProxy(getProperty<std::string>(
"RobotStateComponentName").getValue());
46 nodeName = getProperty<std::string>(
"nodeName").getValue();
51 usingProxy(getProperty<std::string>(
"SimulatorName").getValue());
57 robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(
58 getProperty<std::string>(
"RobotStateComponentName").getValue());
61 getProxy<SimulatorInterfacePrx>(getProperty<std::string>(
"SimulatorName").getValue());
75 IMUSimulation::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();
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;
137 timestamp = now->timestamp;
138 linearVelocity = currentLinearVelocity;
144 return "IMUSimulation";