ahrs icon indicating copy to clipboard operation
ahrs copied to clipboard

Quaternion transformation to Roll-Pitch-Yaw angles

Open Mayitzin opened this issue 4 years ago • 6 comments

When you see the gyroscope integration, you can see that the Y-axis spins 1 negative turn then 1 positive turn. When you see the estimated and reference orientation, the Yaw simply doesn't follow that. I agree reference Yaw and reconstructed Yaw are similar because their quaternions are very very close. the problem isn't about +-2pi. The problem comes that the to_angles()conversion doesn't get you the real movement.

Originally posted by @anisghaoui in https://github.com/Mayitzin/ahrs/discussions/20#discussioncomment-371173

Mayitzin avatar Feb 16 '21 12:02 Mayitzin

@Mayitzin is this issue confirmed? I am facing a kinda similar issue with Kalman and Mahony. If this issue is confirmed, is there a workaround for this?

aayushsingla avatar Feb 22 '21 17:02 aayushsingla

This issue is confirmed to me. I also used Mahony. I got the same observation. My only workaround is to use my phone flat on my hand face up to the ceiling, usb towards my chest. And consider the Z axis as the Yaw. The Yaw is then correct.

The problem is that I checked the current implementation of to_angles() and it seems correct but doesn't have singularities management (which in my case doesn't change a thing).

You can go on an adventure and try to find the quaternion conversion. Gl Hf

anisghaoui avatar Feb 22 '21 17:02 anisghaoui

do we have any update on this weirdness?

anisghaoui avatar May 04 '21 09:05 anisghaoui

No, I switched to a different approach due to the approaching deadlines. This is still unsolved.

do we have any update on this weirdness?

aayushsingla avatar May 04 '21 19:05 aayushsingla

Taking code sample from the documentation

attitude = ahrs.filters.Madgwick(acc=acc_data, gyr=gyro_data)
attitude.Q

How to convert from quaternion into yaw/pitch/roll angles?

tt7533 avatar Jun 06 '21 17:06 tt7533

How to convert from quaternion into yaw/pitch/roll angles?

  1. Convert from quaternion to DCM (Rotation Matrix)
  2. Considering a rotation order of Euler Angles, convert DCM to EA.

PeterBorisenko avatar Jun 02 '23 21:06 PeterBorisenko