4

I have a IMU sensor that gives me orientation in terms of Quaternion and I would like to change it to readable RPY angles.

I found the formula to convert them intrinsically from Wiki

for a quaternion q= qr+qi+qj+qk

roll=atan2(2(qr*qi+qj*qk),1-2(qi^2+qj^2))
pitch=arcsin(2(qr*qj-qk*qi))
yaw=atan2(2(qr*qk+qi*qj),1-2(qj^2+qk^2))

I understand there can be gimbal lock problem when representing in RPY. How could I avoid this when pitch approaches +/- 90 degrees

P.S. I am coding in LabVIEW

user3763570
  • 157
  • 1
  • 9
  • Isn't this a fundamental property of RPY angles? See http://www.chrobotics.com/library/understanding-euler-angles – nekomatic Mar 14 '17 at 13:55

1 Answers1

3

Nekomatic is right, the gimbal lock is a fundemental problem with Euler angles. Either stick with Quaternions (which I would advise), a free downloadable LabView library can be found here: https://www.winemantech.com/blog/quaternions-for-rotations-in-native-labview, the labview robotics toolbox also supports quaternions but is paid.

Otherwise keep track of when you approach a singularity (gimbal lock). In the singularity angles may flip instantaneously from 90 to -90 degrees, since in the real world you know this cannot happen you can code around it. Examples how to do this can be found here: http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/

D.J. Klomp
  • 2,429
  • 1
  • 15
  • 30