Roll feed and yaw from rotation matrix with its own library

I need to extract the roll pitch angles from the rotation matrix, and I want to be sure that what I am doing is correct.

    Eigen::Matrix< simFloat, 3, 1> rpy = orientation.toRotationMatrix().eulerAngles(0,1,2);
    const double r = ((double)rpy(0));
    const double p = ((double)rpy(1));
    const double y = ((double)rpy(2));

      

It's right? Because I was reading here: http://eigen.tuxfamily.org/dox/group__Geometry__Module.html#gad118fececd448d7485ffea4858775e5a

And I was a little confused when at the end of the description it says in what intervals the angles are defined.

+7


source to share


2 answers


I think this is what you are looking for. Depending on how we use m.eulerAngles(0, 1, 2)

; Here is the code that gets rotx, roty, rotz, which is reverse engineered withrotx*roty*rotz

Matrix3f m;

m = AngleAxisf(0.25*M_PI, Vector3f::UnitX())
  * AngleAxisf(0.5*M_PI, Vector3f::UnitY())
  * AngleAxisf(0.33*M_PI, Vector3f::UnitZ());

cout << "original rotation:" << endl;
cout << m << endl << endl;

Vector3f ea = m.eulerAngles(0, 1, 2); 
cout << "to Euler angles:" << endl;
cout << ea << endl << endl;

Matrix3f n;
n = AngleAxisf(ea[0], Vector3f::UnitX())
  * AngleAxisf(ea[1], Vector3f::UnitY())
  * AngleAxisf(ea[2], Vector3f::UnitZ()); 

cout << "recalc original rotation:" << endl;
cout << n << endl;

      



Thanks for your link! I also primarily use Eigen. It just saves a lot of work!

+10


source


Shawn Le's answer is correct, but I think the line should be

Vector3f ea = m.eulerAngles(2, 1, 0);

      



It ea

will then hold the pitch and roll value in that order. The angle of rotation of the Eulers ZYX is equivalent to the rotation of the fixed axis XYZ, which is nothing more than the pitch and yaw of the roll.

+5


source







All Articles