Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial Yaw Roll Pitch example of MPU6050_DMP6 lib #736

Open
altomare23 opened this issue Mar 10, 2023 · 2 comments
Open

Serial Yaw Roll Pitch example of MPU6050_DMP6 lib #736

altomare23 opened this issue Mar 10, 2023 · 2 comments

Comments

@altomare23
Copy link

I built a box running the serial YPR example.
Everything looks ok if roll is kept <90 degrees. But as soon as the box is tilted to have a roll >90 degrees, the pitch abruptly changes to >179 degrees.
Why is roll affecting the pitch and viceversa ? Did anybody see this problem or did I something wrong?
Is there anything to correct this problem ?

@Aarpp
Copy link

Aarpp commented Apr 4, 2023

Hello altomare23 , its Dis encouraging when questions go ignored, I know.
well, I decided to be the change I'd like to see,. Yes, I too noticed the same thing. I am working on a UAV, and I knew I would have to deal with this as well, so I decided to make an attempt.

the following only works with the roll angle from what I observed in testing. Feel free to apply the same to pitch just to experience it yourself. In theory this may allow for barrel rolls .

 
float PITCH = ypr[1]*180/M_PI;
float ROLL = ypr[2]*180/M_PI;


if(ROLL <=-90){PITCH =-(PITCH +180);}
if(ROLL >=90){PITCH =-(PITCH -180);}



barrel_sol_1
passing past 90 degrees

barrel_sol_2

However, its not perfect you would have to create conditions: what I mean is, if I roll 360 degrees
there are two separate regions where pitch is affected and increments to 360 degrees, additional restrictions would need to be placed. This is just a snippet to hopefully get you started.

@altomare23
Copy link
Author

Thanks a lot Aarpp, you were so kind to confirm that the same problem is observed by others. Now, in order to bypass this problem, I implemented a mixed (interim) solution. YAW is evaluated as ypr[0]*180/M_PI; but pitch and roll are computed in agreement with https://wiki.dfrobot.com/How_to_Use_a_Three-Axis_Accelerometer_for_Tilt_Sensing. So:
ROLL = atan2(AY , AZ) * 180.0 /M_PI;
PITCH = atan2(-AX , sqrt(AY * AY + AZ * AZ)) * 180.0 /M_PI;
This works much better minimizing interactions.
In any case I will experiment your solution to improve all measurements. My special thanks !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants