We can use quaternions, Euler Angles, and rotation matrices in Eigen to demonstrate how they are transformed. We will also provide a visualization program to help the reader understand the relationship between these transformations.
The Eigen/Geometry module provides a variety of rotation and translation representations, such as a 3D rotation matrix directly using Matrix3d or Matrix3f.
The rotation vector uses AngleAxis, the underlying layer is not directly Matrix, but the operation can be treated as a matrix (because the operator is overloaded).
Rotation matrices can be assigned directly:
Coordinate transformation with AngleAxis:
Coordinate transformation using a rotation matrix
You can convert the rotation matrix directly into Euler angles
Euclidean transformation matrix using Eigen::Isometry:
Using the transformation matrix for coordinate transformation:
For affine and projective transformations, use Eigen::Affine3d and Eigen::Projective3d.
You can assign AngleAxis directly to quaternions, and vice versa Quaterniond q = Quaterniond(rotation_vector);
Note that the order of coefficients is (x, y, z, w), w is the real part, the first three are the imaginary part. We can also assign a rotation matrix to it
Robot 1 and Robot 2 are located in the world coordinate system.
World coordinate: W
Robot coordinate systems: R1,R2
The pose of Robot 1 is:
q1=[0.35,0.2,0.3,0.1]T
t1=[0.3,0.1,0.1]T
The pose of Robot 2 is:
q2=[−0.5,0.4,−0.1,0.2]
t2=[−0.1,0.5,0.3]T
Here, q and t express TRk,W, where k=1,2, which are the robot transform matrices. Now, assume that Robot 1 sees a point in its own coordinate system with coordinates of pR1=[0.5,0,0.2]T. We want to find the coordinates of the vector in the robot 2’s coordinate system.