This forum has been archived. All content is frozen. Please use KDE Discuss instead.

About EulerAngles Conversion

Tags: None
(comma "," separated)
mfaid
Registered Member
Posts
2
Karma
0

About EulerAngles Conversion

Tue Nov 24, 2015 7:27 am
Hi,

Suppose that I have a 3-dimensional frame with rotation roll = 0, pitch = 0 and yaw = 0 about x, y and z axis respectively.

I want the frame to rotate about x-axis for 3.14159 (Pi) or roll = Pi.

Below is the code for said situation.

The problem is, when I want to convert the matrix rotation back to roll, pitch, and yaw, the code gives different answer.

Instead of roll = Pi, the result is roll = 0, pitch = pi, and yaw = pi.

I think RVC toolbox by Peter Corke on Matlab gives correct answer.

Maybe something is not right with with my program or eulerAngles in Eigen works differently? Please help.

Code:
Code: Select all
#include <iostream>
#include <Eigen/Dense>

int main()
{
   using ::Eigen::AngleAxisd;
   using ::Eigen::Matrix3d;
   using ::Eigen::Vector3d;
   using ::std::cout;
   using ::std::endl;

   Matrix3d R,Rx;

   R =   AngleAxisd(PI, Vector3d::UnitX())
      * AngleAxisd(0, Vector3d::UnitY())
      * AngleAxisd(0, Vector3d::UnitZ());
   Rx =   AngleAxisd(PI, Vector3d::UnitX());

   cout << R << endl << endl;
   cout << Rx << endl << endl;

   Vector3d ea = R.eulerAngles(0,1,2);
   Vector3d eax = Rx.eulerAngles(0,1,2);

   cout << ea << endl << endl;
   cout << eax << endl << endl;

   std::cin.ignore();
   return 0;
}


Output:
Code: Select all
1 0 0
0 -1 0
0 0 -1

1 0 0
0 -1 0
0 0 -1

0
3.14159
3.14159

0
3.14159
3.14159
mfaid
Registered Member
Posts
2
Karma
0

Re: About EulerAngles Conversion

Tue Nov 24, 2015 5:50 pm
Solved! :)


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]