ENSTABretagneRobotics / razor_imu_9dof

A ROS driver and firmware to connect to Sparkfun OpenLog Artemis, 9DoF Razor IMU M0, 9DOF Razor IMU and 9DOF Sensor Stick. These boards consists of 3 sensors: magnetic, gyro and acceleration sensor.
BSD 3-Clause "New" or "Revised" License
92 stars 114 forks source link

Wrong coordinate system for SEN 14001? #43

Closed subodh-malgonde closed 6 years ago

subodh-malgonde commented 6 years ago

I am using Razor 9DOF IMU (hardware version SEN14001). The code in imu_node.py converts the readings from Razor AHRS firmware to ROS standards (REP 103). However when I test the orientations by measuring the acceleration due to gravity (9.8 m/s^2) on each axis by echoing messsages from the topic imu (I am running roslaunch razor_imu_9dof razor-pub.launch), I get very different orientations. See these Pictures:

This means the axis are oriented this way:

This is the left handed coordinate system, whereas ROS uses right handed coordinate system.

Am I missing something? I ask because according to PR https://github.com/KristofRobot/razor_imu_9dof/pull/34 this repo supposed to work with SEN14001?

subodh-malgonde commented 6 years ago

I observed values from the serial monitor, which shows data directly from Razor_AHRS, I get this coordinate system:

whatsapp image 2018-07-20 at 3 16 46 pm

So it looks like Razor_AHRS has the same coordinate system as REP-103, which is:

  1. X axis pointing forward (towards the short edge with the connector holes)
  2. Y axis pointing to the left
  3. Z axis pointing up

So imu_node.py does not need to modify anything. Am I right @lebarsfa?

lebarsfa commented 6 years ago

This is a bit unexpected... The conventions should be the one described here : https://github.com/Razor-AHRS/razor-9dof-ahrs/issues/57#issuecomment-378585065 ... See also https://github.com/Razor-AHRS/razor-9dof-ahrs/wiki/tutorial (around the middle of the page, the screenshot of Razor_AHRS_test.pde). With the serial monitor, do you get yaw=0 when towards the North, yaw=90 towards the East, yaw=-90 (or 270) towards the West? If it is not the case, that means that you probably use a different/modified firmware inside the Razor (also, do you use the default options?), or maybe your Razor is different...

For the accelerations, note this : https://github.com/KristofRobot/razor_imu_9dof/blob/fb23b76e4727cd294a84c453506ed6d5eeb7562e/nodes/imu_node.py#L240 This probably explains why the sign of the accelerations is the contrary.

subodh-malgonde commented 6 years ago

Thank you so much for getting back!

With the serial monitor, do you get yaw=0 when towards the North, yaw=90 towards the East, yaw=-90 (or 270) towards the West?

I get yaw = 90 towards east. However when I orient it to north, it does not go to 0. Also for west it does not go to -90. I think my magnetometer is faulty. See this GIF, as I rotate the Razor around the Z axis, the visualitzation does not follow the actual movement.

ezgif-2-4e73ff3fae

I used Razor_AHRS_test.pde for the above sketch. For rotations around X & Y axes, it follows (this part is not in the GIF).

If it is not the case, that means that you probably use a different/modified firmware inside the Razor (also, do you use the default options?), or maybe your Razor is different...

I have not changed anything from Razor_AHRS.ino apart from HW__VERSION_CODE (14001). Is that what you mean by default options?

I think the firmware inside the Razor is different, maybe Sparkfun changed it.

subodh-malgonde commented 6 years ago

UPDATE: The incorrect yaw on the horizontal plane was due to non-calibrated sensors. This resulted in the IMU firmware applying incorrect drift correction for the gyroscope and magnetometer. Source: Troubleshooting: Unstable yaw (aka heading aka azimuth) readings / Yaw drift. After calibrating the sensors, my yaw values are correct.

~Going back to the original problem of wrong co-ordinate system, I applied these corrections to the code in imu_node.py to fix it~:

  1. ~https://github.com/subodh-malgonde/razor_imu_9dof/commit/bf06e0265061139f09dd1cce2b710029974f91b9~
  2. ~https://github.com/subodh-malgonde/razor_imu_9dof/commit/457f7aaff77aed552bc51cacff894cea1239a95e~
  3. ~https://github.com/subodh-malgonde/razor_imu_9dof/commit/0c0aa562a2a79ae359382786290e469ffad0e57f~

UPDATE 2: It turns out IMUs measure acceleration opposite of gravitational acceleration in the static state. Please see these posts:

  1. IMU convention for robot_localization
  2. Why do 3-axis accelerometers seemingly have a left-handed coordinate system?
    1. IMU data to be used with robot_localization

So the razor_imu_9dof package provides data in the right format. No changes are required to the code.

@lebarsfa Your suspicion was right about the negated accelerations.