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

Euler angle calculation is different from Wikipedia? #468

Open
de-viant opened this issue Oct 3, 2021 · 2 comments
Open

Euler angle calculation is different from Wikipedia? #468

de-viant opened this issue Oct 3, 2021 · 2 comments

Comments

@de-viant
Copy link

de-viant commented Oct 3, 2021

Wikipedia shows
image

And in the code it is
yaw = atan2(2.0f * (q[1] * q[2] + q[0] * q[3]), q[0] * q[0] + q[1] * q[1] - q[2] * q[2] - q[3] * q[3]);

pitch = -asin(2.0f * (q[1] * q[3] - q[0] * q[2]));

roll = atan2(2.0f * (q[0] * q[1] + q[2] * q[3]), q[0] * q[0] - q[1] * q[1] - q[2] * q[2] + q[3] * q[3]);

it seems Euler angle calculation is different from the wikipedia displays. (Formulae for Yaw and Roll seem interchanged)

https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

@kriswiner
Copy link
Owner

kriswiner commented Oct 3, 2021 via email

@de-viant
Copy link
Author

de-viant commented Oct 3, 2021

your convention gives better result.
In my device I have an MPU6050 and QMC5883L (Clone of HMC5883), which have their axes aligned (atleast the x, y axes not so sure about z axis) so I update as

MadgwickQuaternionUpdate(ax, ay, az, gxPI/180.0f, gyPI/180.0f, gzPI/180.0f, mx, my, mz).
instead of
MadgwickQuaternionUpdate(ax, ay, az, gx
PI/180.0f, gyPI/180.0f, gzPI/180.0f, my, -mx, -mz
as in the MPU6050HMC5883AHR example sketch.

It seems to work fine, the only thing that bothers me is
image

The small correlation I observe of yaw with change with roll or pitch. But changing yaw doesn't change roll, pitch.
I tested by using a breadboard, rotating along x,y,z axes. I see yaw varies slightly when I change pitch or roll, but when I place the breadboard flat on the table (initial state) the yaw corrects to initial value. Is this behavior expected?

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