title: How to avoid Gimbal lock when converting from Quaternion to Roll Pitch Yaw
body: <p>I have a IMU sensor that gives me orientation in terms of Quaternion and I would like to change it to readable RPY angles.</p>
  
  <p>I found the formula to convert them intrinsically from Wiki</p>
  
  <p>for a quaternion q= qr+qi+qj+qk</p>
  
  <pre><code>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))
  </code></pre>
  
  <p>I understand there can be gimbal lock problem when representing in RPY. How could I avoid this when pitch approaches +/- 90 degrees</p>
  
  <p>P.S. I am coding in LabVIEW</p>