Read IMU sensor from a plugin
Hello,
I made a model of a robot and I added and IMU sensor to it in the sdf file as follow:
<sensor name="imu_sensor" type="imu">
<pose>0 0 0 0 0 0</pose>
<always_on>1</always_on>
<update_rate>100.0</update_rate>
</sensor>
I'm controlling my robot using a plugin I wrote and everything is working fine, but I would like to read the IMU sensor data inside my plugin's code. I know that I can subscribe to the topic of the IMU ("~/gazebo/default/imu_sensor/imu") and read from there, but I'm wondering how can I get from code an instance of the IMU sensor object and read the IMU like I read the pose of the model.
Basically my question is: How can I read the IMU data using an instance of an IMU object in the model? I guess should be something like below, but I don't know how to glue everything together yet.
ImuSensor imu;
double acc = imu.GetLinearAcceleration();
I'm wondering why do you want to do that? Why not just subscribe to the topic?
The reason is that in my plugin I'm collecting some data ( including imu ) to send out in another message and I don't want to synchronize the data from the imu topic with the other data. I rather prefer read all the elements/data I need at the "same time".