Field-Robotics-Japan / UnitySensors

ROS/ROS2 enabled Sensor models (Assets) on Unity
Apache License 2.0
191 stars 28 forks source link

Direction of gravity vector of IMU simulation #116

Closed yosuke closed 4 months ago

yosuke commented 4 months ago

When I visualize the IMU simulation using ROS RViz IMU plugin, the linear acceleration vector is directing downward (toward the ground), while this should direct upward (toward the sky) as shown in the following URL: http://wiki.ros.org/rviz_imu_plugin?action=AttachFile&do=get&target=rviz_imu_plugin.png

This is probably because the gravity vector is added in the UnitySensors implementation: https://github.com/Field-Robotics-Japan/UnitySensors/blob/master/Assets/UnitySensors/Runtime/Scripts/Sensors/IMU/IMUSensor.cs#L51

While the gravity vector is subtracted in the other implemenation (e.g. gazebo): https://github.com/gazebosim/gazebo-classic/blob/gazebo11/gazebo/sensors/ImuSensor.cc#L375-L376

We probably need to think "Because the IMU is not moving, linear velocity is applied against the gravitational force (that is why the vector should be subtracted)".

Autumn60 commented 4 months ago

@yosuke Thank you for the Issue.

This is due to my lack of knowledge about the IMU. For reference, what values of vertical acceleration does the IMU show when it is in free fall?

yosuke commented 4 months ago

@Autumn60 Good point. My assumption is, it turns zero during free fall. And yes, it seems right: https://physics.stackexchange.com/questions/402611/why-an-accelerometer-shows-zero-force-while-in-free-fall

Autumn60 commented 4 months ago

@yosuke This issue was fixed in #118. Would you try the develop branch?

RyodoTanaka commented 4 months ago

@yosuke @Autumn60 Thank you for your discussion and the merge. This issue looks already solved by the merge, thus I close it.