kriswiner / MPU9250

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

Pitch behaviour funny #209

Open NickMortimer opened 6 years ago

NickMortimer commented 6 years ago

Hi Kris

Sorry to bother you again. I'm having some funny stuff happening. I have my system calibrated and outputting yaw pitch roll. The funny thing is that pitch and yaw work perfectly but roll is funny. starts at 0 then goes up to 90 and then reduces to 0 and then to -90 and then again back 0 as I turn it. so I get ambiguity eg. I have 45 points on the circle that have a value of 45 degrees and they are 90 apart. Its giving me a real headache!

Is it a faulty chip?

Thanks

Nick

kriswiner commented 6 years ago

More likely you are not feeding the Madgwik filter correctly.

Which MPU9250 breakout are you using?

On Fri, Nov 17, 2017 at 10:26 PM, Nick Mortimer notifications@github.com wrote:

Hi Kris

Sorry to bother you again. I'm having some funny stuff happening. I have my system calibrated and outputting yaw pitch roll. The funny thing is that pitch and yaw work perfectly but roll is funny. starts at 0 then goes up to 90 and then reduces to 0 and then to -90 and then again back 0 as I turn it. so I get ambiguity eg. I have 45 points on the circle that have a value of 45 degrees and they are 90 apart. Its giving me a real headache!

Is it a faulty chip?

Thanks

Nick

— 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/209, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qkBIhetEUmEuT74MueZ4Mg64MYWHks5s3nh7gaJpZM4Qi5fI .

NickMortimer commented 6 years ago

I've tried swapping and sign changing on most of the inputs!

https://www.sparkfun.com/products/13762

kriswiner commented 6 years ago

Flailing rarely works.

The Madgwick filter expects the sensor data in either NED or ENU order.

Choose North for your set up, figure out which accel axis aligns with North, then East, then Down, then do the same for gyro and mag. Gyro and accel should be the same, mag will be different on the MPU9250. So if the -y axis point East, enter -My in the EAST slot, etc.

I usually negate the accel data, but this is not necessary.

On Sat, Nov 18, 2017 at 12:01 AM, Nick Mortimer notifications@github.com wrote:

I've tried swapping and sign changing on most of the inputs!

https://www.sparkfun.com/products/13762

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

NickMortimer commented 6 years ago

Ok I have finally worked this out! My bad pitch only has a valid range +/-90 degrees and that in my application of 360 rotation in all directions is not good thus pitch should be calculated using:

pitch = atan2f(2q[1]q[0] - 2q[1]q[3], 1 - 2q[2]q[2] - 2q[3]q[3]);

Nick