xioTechnologies / Fusion

MIT License
1.02k stars 241 forks source link

IMU/Sensor Axis Alignment #187

Closed mjs513 closed 2 weeks ago

mjs513 commented 2 weeks ago

This is probably the most basic question but one that still makes my head spin. I have been playing with the original Madgwick algorithm for years since the days of FreeIMU by Fabio Versano (rest in peace). And I believe uses z axis down.

Anyway, in the original source from (https://code.google.com/archive/p/imumargalgorithm30042010sohm/downloads) it shows that the axes are aligned with x => North (forward), y => West (left wing) and z => up. Which if you forgive is a NWU if attached to the IMU: image This seems to be the same alignment for the MPU-9250 that you identified for the MPU-9250 in this post: https://github.com/xioTechnologies/Fusion/issues/24#issuecomment-1141470871, i.e. _magnetometer = numpy.array([mpu9250_mag_y, mpu9250_mag_x, -1 * mpu9250_magz]), so you are aligning the magnetometer with the accelerometer axes.

The thing that getting me confused is that I see many examples where they are aligning the accel/gyro axes with the magnetometer. (Matlab, Kris Winners implementation and a big discussion by jremington on the arduino forum).

Or if in general if it doesn't matter as long as the axes are aligned? Or what is the convention for Fusion and the original Madgwick Algorithm which seems to be common?

Hope this makes sense.

Thanks Mike

xioTechnologies commented 2 weeks ago

It does not matter if you align the magnetometer with the other sensors; align the other sensors with the magnetometer; or align all sensors to some arbitrary axes. Choose your XYZ axes directions and then use measurements corresponding to those directions.

mjs513 commented 2 weeks ago

Thank you very much for the confirmation. Really appreciate it! Now to play some more.