5

I'm using Eigen's eulerAngles to get the roll, pitch, and yaw angles from a rotation matrix like so:

const Eigen::Vector3f yaw_pitch_roll = rotation.eulerAngles(2, 1, 0);

where rotation is some valid rotation matrix of type Eigen::Matrix3f.

What I'm observing: If all three angles are close to zero, i.e. if the rotation matrix is close to the identity, some or all three resulting angles are sometimes off by Pi, i.e. by 180 degrees.

This may happen with certain other rotations as well, but I've only observed it close to the identity so far.

  1. Can I avoid this somehow?
  2. What other angles apart from (0, 0, 0) might be singular points?
Alex
  • 3,316
  • 4
  • 26
  • 52
  • Euler angles will always have singularities ... The easiest and best way is to throw them in thrash and use [homogenuous uniform 4x4 transform matrices](https://stackoverflow.com/a/28084380/2521214) instead. If you insist on Euler angles there are 2 approaches... a nightmare bunch of `if/else` expressions to handle edge cases (and always missing some case) or transform actual transformation into matrix and then back to euler or vice versa ... see [Is there a way to calculate 3D rotation on X and Y axis from a 4x4 matrix](https://stackoverflow.com/a/56950130/2521214) – Spektre Apr 08 '20 at 09:11
  • Unfortunately you need euler angles sometimes if you control a joint that can rotate around 1 or more axes. – oarfish Jan 27 '23 at 09:46
  • I recommend having a look at the [unsupported Euler-Angles module](https://eigen.tuxfamily.org/dox-devel/unsupported/group__EulerAngles__Module.html) of Eigen. Also see this (somewhat) related question: https://stackoverflow.com/questions/57988747/two-similar-pose-has-a-big-relative-euler-angle – chtz Feb 23 '23 at 15:00

0 Answers0