kriswiner / MPU9250

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

roll and Pitch Limitation #194

Open Muhammad-Khodeer opened 6 years ago

Muhammad-Khodeer commented 6 years ago

Hello kris, thank you for this great project, I used your code to calibrate and test my MPU9250. I'm using Sparkfun board IMU with Arduino Zero. However I have a couple of questions

I succeeded to get Yaw, Pitch and Roll reading with ranges Yaw (0 to 360), Roll (-180 to 180) and pitch (-90 to 90), I am not sure yet if I got the best accuracy yet but my question is what if I need the range of Roll and Pitch (from 0 to 360)? and get reading of 360 rotation of roll and pitch? how to overcome this limitation?

I read that using matrices (Euler Angles classic or Tait-Bryan ) we can't get 9 degrees of freedom (0° to 360°) in all Roll, Pitch and Yaw (which what I need) And I have to use quaternions to overcome "Gimbal Lock" and get (0° to 360°) range at the three angels Roll, Pitch and Yaw. Is that true ? and have you any code that help me on this? I am thinking about to change to BNO055 IMU as the simulation video show the object rotate in 360 degree all directions.

Also I want my sensor to be very sensitive so it changes output if change by one degree occurred for example if it is fixed in a servo motor I want to read the one degree of the motor change is that possible? did you measure the sensitivity before? how?

kriswiner commented 6 years ago

For AHRS, pitch is -90 to +90 and roll is -180 to +180. You can always remap to anything you want.

With sparkfun's MPU9250 I think you might be able to get +/- 5 degrees accuracy. The BNO055 is worse.

On Sun, Oct 15, 2017 at 5:01 AM, Muhammad_Khodeer notifications@github.com wrote:

Hello kris, thank you for this great project, I used your code to calibrate and test my MPU9250. I'm using Sparkfun board IMU with Arduino Zero. However I have a couple of questions

I succeeded to get Yaw, Pitch and Roll reading with ranges Yaw (0 to 360), Roll (-180 to 180) and pitch (-90 to 90), I am not sure yet if I got the best accuracy yet but my question is what if I need the range of Roll and Pitch (from 0 to 360)? how to overcome this limitation? as I want my unity simulation box to rotate in all directions 360 degree

I read that using matrices (Euler Angles classic or Tait-Bryan ) we can't get 9 degrees of freedom (0° to 360°) in all Roll, Pitch and Yaw (which what I need) And I have to use quaternions to overcome "Gimbal Lock" and get (0° to 360°) range at the three angels Roll, Pitch and Yaw. Is that true ? and have you any code that help me on this? I am thinking about to change to BNO055 IMU as the simulation video show the object rotate in 360 degree all directions.

Also I want my sensor to be very sensitive so it changes output if change by one degree occurred for example if it is fixed in a servo motor I want to read the one degree of the motor change is that possible? did you measure the sensitivity before? how?

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

Muhammad-Khodeer commented 6 years ago

Thank you A lot Kris I got good results. I also have some questions

1- I want to take the best Magnetometer calibration values that worked with me and fix it in my code instead doing calibration every time. Is that right? what is the area range that same calibration values keep working fine ?

2- What is the best way to measure the accuracy? something like stepper motor ?

kriswiner commented 6 years ago

You can store mag calibration values in your sketch or on EEPROM, etc and avoid having to calibrate each time. Just make sure you check periodically that the mag is still calibrated. And if you change environments where the Earth's magnetic field or temperature vary a lot, you will likely have to calibrate again.

For accuracy, yes, you just need to test the estimated orientation against a known orientation. Just a rotating table with degree markings is good enough to test heading, for example.

On Wed, Oct 18, 2017 at 4:39 AM, Muhammad_Khodeer notifications@github.com wrote:

Thank you A lot Kris I got good results. I also have some questions

1- I want to take the best Magnetometer calibration values that worked with me and fix it in my code instead doing calibration every time. Is that right? what is the area range that same calibration values keep working fine ?

2- What is the best way to measure the accuracy? something like servo motor ?

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

inderjeetkharay commented 5 years ago

Hello Muhammad,

Are you able to get angles in the range of 0 to 360 degrees?

Thanks

kriswiner commented 5 years ago

You cannot get roll and pitch to go from 0 to 360 since they are defined from -90 to 90 and -180 to 180 for pitch and roll, respectively.

On Thu, Aug 22, 2019 at 12:36 PM inderjeetkharay notifications@github.com wrote:

Hello Muhammad,

Are you able to get angles in the range of 0 to 360 degrees?

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/194?email_source=notifications&email_token=ABTDLKXNNKWSU5QD4H4MEALQF3TFXA5CNFSM4D7G4QY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD46FA4Q#issuecomment-524046450, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTDLKTC2GSKEDMV5VV2CFTQF3TFXANCNFSM4D7G4QYQ .

inderjeetkharay commented 5 years ago

Dear Kris,

Thanks for your reply. Actually I ordered teensy 3.2 and Ladybug. So at first I tried your code with teensy 3.2. I am getting pitch from -90 to 90 and roll -180 to 180. That's fine. But at roll 90 or -90, pitch doesn't changes, it remain somehow constant. What problem should I have? For filter I used (North, East, Down) notation. Also At fort worth declination is 3° 22' E ± 0° 20', so I need to substract 3.36 from yaw. Is that correct?

Also I will try to do connections for Ladybug tomorrow to see the difference.

Thanks Inderjeet

inderjeetkharay commented 5 years ago

Also, to add, my readings at still position at table are: ax = -0.18 ay = -0.37 az = 1000.49 mg gx = -0.01 gy = 0.11 gz = 0.08 deg/s mx = 84 my = -89 mz = 380 mG

kriswiner commented 5 years ago

That all seems correct. The trouble is that at certain positions the angles are degenerate. it is the same problem as standing on the North pole and asking, Which direction is South?

On Thu, Aug 22, 2019 at 2:26 PM inderjeetkharay notifications@github.com wrote:

Also, to add, my readings at still position at table are: ax = -0.18 ay = -0.37 az = 1000.49 mg gx = -0.01 gy = 0.11 gz = 0.08 deg/s mx = 84 my = -89 mz = 380 mG

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/194?email_source=notifications&email_token=ABTDLKXM7HWIFBKXC573KYLQF4AAZA5CNFSM4D7G4QY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD46OIFQ#issuecomment-524084246, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTDLKVFYCUNW7A7C6MSBSLQF4AAZANCNFSM4D7G4QYQ .

inderjeetkharay commented 5 years ago

Dear Kris,

I understood the case you are talking about. But the problem I am facing is: When my sensor is at table then all three angles (yaw, pitch, roll) works fine. But when I change roll angle, let us say I change roll angle by 20 degrees. Now I am trying to change pitch, but pitch is not changing. At the same position when I change yaw, it change the Pitch angle. It means yaw becomes the pitch? Sorry I am not able to understand the problem. Please let me know where can be the problem. Maybe I need transformation from global to sensor body frame.

Thank You Inderjeet

kriswiner commented 5 years ago

Two likely possibilities: you are not feeding the sensor data in the correct NED orientation or the Madgwick/Mahony filter or the sensors are not properly calibrated.

On Sun, Aug 25, 2019 at 5:07 PM inderjeetkharay notifications@github.com wrote:

Dear Kris,

I understood the case you are talking about. But the problem I am facing is: When my sensor is at table then all three angles (yaw, pitch, roll) works fine. Bur when I change roll angle, let us say I change roll angle by 20 degrees. Now I am trying to change pitch, but pitch is not changing. At the same position when I change yaw, it change the Pitch angle. It means yaw becomes the pitch? Sorry I am not able to understand the problem. Please let me know where can be the problem. Maybe I need transformation from global to sensor body frame.

Thank You Inderjeet

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/194?email_source=notifications&email_token=ABTDLKQFQ3O7UZVU6KKJ6BLQGMNCRA5CNFSM4D7G4QY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5C6V5Q#issuecomment-524675830, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTDLKQK6QJ7F7NYIVRGZXDQGMNCRANCNFSM4D7G4QYQ .

inderjeetkharay commented 5 years ago

Dear Kris,

Thanks a lot for the comments. Yes, now I am getting good angles. Now I am extending your code for 6 MPU9250 sensors using multiplexer. I want to ask that the libraries will remain same? (Right now I am using your algorithm of Teensy)

include

include

include

include

or I need to add any other library for multiplexer?

Thank You Inderjeet Singh

kriswiner commented 5 years ago

Not sure. If you are running multiple MPU9250s on a single I2C bus this https://github.com/kriswiner/MPU9250/tree/master/Dual_MPU9250 might be useful.

On Tue, Aug 27, 2019 at 2:41 PM inderjeetkharay notifications@github.com wrote:

Dear Kris,

Thanks a lot for the comments. Yes, now I am getting good angles. Now I am extending your code for 6 MPU9250 sensors using multiplexer. I want to ask that the libraries will remain same? (Right now I am using your algorithm of Teensy)

include

include

include

include

or I need to add any other library for multiplexer?

Thank You Inderjeet Singh

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/194?email_source=notifications&email_token=ABTDLKS7H7KSGEKPTNXJ7ULQGWLPZA5CNFSM4D7G4QY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5JFGPI#issuecomment-525488957, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTDLKUCSRKEA4FD45OFTCDQGWLPZANCNFSM4D7G4QYQ .