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
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With