kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.03k stars 472 forks source link

Data order for Madgwick filter #345

Open egen1um opened 5 years ago

egen1um commented 5 years ago

Hi Kris!

First of all I'd like to thank you for all the help you're giving here. Your Github issues page is definitely most useful resource on internet for IMU related questions :)

I've probably read all your answers, but somehow I still can't wrap my head around order and signs of data that you pass to the filter. Could you please explain it once more "for dummies" way?

axis

For example, I have this same type of orientation for acc, gyro and magnetometer and I'm using NWU Madgwick filter. What would be the correct order and more importantly why?

Also, if you have any experience with Unity, how would you convert Madgwick quaternion to Unity quaternion?

kriswiner commented 5 years ago

No idea about Unity.

The Madgwick and Mahony filters (and quaternions in general I believe) work in a right-handed coordinate system. So the data have to be "provided" to conform to this. Thus NED, ENU (the two most common orientation conventions) or even NWU will all work. As long as the sensor data is provided in a manner consistent with the chosen convention.

So first step, the user decides which edge of the sensor board will be pointing to true North when the quaternions read 1 0 0 0. This is one of two absolute references in the system (the other is gravity). Once the board edge facing North is decided (yes, it is your choice!), then it is a simply matter to find out which accel axis point North, no? Then West, then Up. Then the filter should get the data as AN, AW, AU...same for the other two sensors.

Then once you do this, and assuming you have chosen the sensor configurations reasonably, calibrated the sensors sufficiently, are running the fusioniterations sufficiently fast, you have taken into account the local magnetic declination, etc you can check the behavior of your absolute orientation engine. What do the quaternions say when the sensors are pointed North (Yaw or Heading = 0)? Should be 1 0 0 0. Try turnin the board 90 degrees. What happens now? etc.

On Tue, Feb 5, 2019 at 5:02 AM egen1um notifications@github.com wrote:

Hi Kris!

First of all I'd like to thank you for all the help you're giving here. Your Github issues page is definitely most useful resource on internet for IMU related questions :)

I've probably read all your answers, but somehow I still can't wrap my head around order and signs of data that you pass to the filter. Could you please explain it once more "for dummies" way?

[image: axis] https://user-images.githubusercontent.com/6449822/52274495-8ad9cf80-2955-11e9-97c6-0e1c83310695.png

For example, I have this same type of orientation for acc, gyro and magnetometer and I'm using NWU Madgwick filter. What would be the correct order and more importantly why?

Also, if you have any experience with Unity, how would you convert Madgwick quaternion to Unity quaternion?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/345, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qtnQ4k2jYSGWMB2IALTlrFc9F4HKks5vKYDZgaJpZM4ajKhd .

egen1um commented 5 years ago

So if we take picture from previous post and use upper edge as North, then the order for NWU will be (ay, ax, az, gy, gx, gz, my, mx, mz)?

As for calibration, what do you think about Magneto? Is it good enough?

kriswiner commented 5 years ago

Did you look at the MPU9250 data sheet?

On Tue, Feb 5, 2019 at 10:45 AM egen1um notifications@github.com wrote:

So if we take picture from previous post and use upper edge as North, then the order for NWU will be (ay, ax, az, gy, gx, gz, my, mx, mz)?

As for calibration, what do you think about Magneto http://sailboatinstruments.blogspot.com/2011/09/improved-magnetometer-calibration-part.html? Is it good enough?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/345#issuecomment-460755772, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qo848fjptAjpoRREZIfLZSxB50HAks5vKdFPgaJpZM4ajKhd .

egen1um commented 5 years ago

I'm sorry, it's not exactly about MPU9250, it's more of a general question, I didn't know where else to ask :)

kriswiner commented 5 years ago

West is -x, no?

This isn't really that hard, or shouldn't be....;>

Do you know what right-handed coordinate system means? Look it up, google is your frind in this case...

On Tue, Feb 5, 2019 at 10:49 AM egen1um notifications@github.com wrote:

I'm sorry, it's not exactly about MPU9250, it's more of a general question, I didn't know where else to ask :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/345#issuecomment-460757018, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qnCBVKqsM3pmGZRc3v9OAJ-UyxDNks5vKdIdgaJpZM4ajKhd .

egen1um commented 5 years ago

Yes, -x, my bad. Ok, I think I finally got it. It's just that I've seen some confusing posts here, but I guess that's because of specifics of physical orientation of different sensors on different boards (I mean this answer:

we need to feed into the madgwick function Ay, Ax, -Az, Gy, Gx, -Gz, Mx, My, and Mz. But because gravity is by convention // positive down, we need to invert the accel data, so we pass -Ay, -Ax, Az, Gy, Gx, -Gz, Mx, My, and Mz into the Madgwick...

Anyway, now instead of answering same question for 1001 time you can give link to this post :) Thanks again for your time and patience!

kriswiner commented 5 years ago

All sensors are different, and user chooses which axis is North so there is no one right answer for all people for all time. In tother words, the user has to understand what he/she is doing!;>

On Tue, Feb 5, 2019 at 11:16 AM egen1um notifications@github.com wrote:

Yes, -x, my bad. Ok, I think I finally got it. It's just that I've seen some confusing posts here, but I guess that's because of specifics of physical orientation of different sensors on different boards (I mean this answer:

we need to feed into the madgwick function Ay, Ax, -Az, Gy, Gx, -Gz, Mx, My, and Mz. But because gravity is by convention // positive down, we need to invert the accel data, so we pass -Ay, -Ax, Az, Gy, Gx, -Gz, Mx, My, and Mz into the Madgwick...

Anyway, now instead of answering same question for 1001 time you can give link to this post :) Thanks again for your time and patience!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/345#issuecomment-460766935, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qvpmhqm91OyikNbRvEVyjg6MWytDks5vKdipgaJpZM4ajKhd .

maopal commented 3 years ago

mpu9250 model

Looking at this illustration of MPU9250 given that I choose Y-axis to point North and choose to used the NED system. Would my input be madgwickquaternionupdate(ay, ax, az, gy, gx, gz, my, mx, mz)?

Y=North X=East and Z= down?

kriswiner commented 3 years ago

Which accel axis is painting North then?

On Sun, Feb 21, 2021 at 4:39 AM palemao notifications@github.com wrote:

[image: mpu9250 model] https://user-images.githubusercontent.com/74777355/108624916-c7df6480-743f-11eb-9c08-374f51cd0908.PNG

Looking at this illustration of MPU9250 given that I choose Y-axis to point North and choose to used the NED system. Would my input be madgwickquaternionupdate(ay, ax, az, gy, gx, gz, my, mx, mz)?

Y=North X=East and Z= down?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/345#issuecomment-782851442, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKQTSAJVSF5BYKUMGEDTAD5IFANCNFSM4GUMVBOQ .

maopal commented 3 years ago

I have just seen that the axis of Mag ang accel & gyro are misaligned on the MPU9250 datasheet. Capture

so let me ask the question again with this new knowledge: mpu9250 model

Using NED system: Given I point x-axis of my mag North, East=Y and Down is Z.

For ACCEL & GYRO: North = Y, EAST=X and Down = -Z

This is my thought process is this correct?

Thanks again :)

kriswiner commented 3 years ago

yes, so N axes are Ay, Gy, Mx, etc and the Madgiwck filter expects N, E, D input...so filter(AN, AE, AD, GN, GE, GD, MN, ME, MD)

On Mon, Feb 22, 2021 at 3:50 AM palemao notifications@github.com wrote:

I have just seen that the axis of Mag ang accel & gyro are misaligned on the MPU9250 datasheet. [image: Capture] https://user-images.githubusercontent.com/74777355/108703820-10ac2180-7503-11eb-9bb2-9ff6d9d71acc.PNG

so let me ask the question again with this new knowledge: [image: mpu9250 model] https://user-images.githubusercontent.com/74777355/108703842-173a9900-7503-11eb-9f2b-02e286d9491b.PNG

Using NED system: Given I point x-axis of my mag North, East=Y and Down is Z.

For ACCEL & GYRO: North = Y, EAST=X and Down = -Z

This is my thought process is this correct?

Thanks again :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/345#issuecomment-783319405, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTDLKQR7MK26VR2LCEDXNDTAJAJ7ANCNFSM4GUMVBOQ .