Rotation Matrices - omega phi kappa vs yaw pitch roll

118 views (last 30 days)
Hello,
I have omega phi kappa and corresponding yaw (Z) pitch (Y) roll (X) measurements from a sensor.
Both are in degrees but I convert them to rads.
I try to do some tranformations for a photogrammetry project.
While using the yaw, pitch, roll values and the Robotics Toolbox function:
R_euler = eul2r(yaw_rad, pitch_rad, roll_rad)
the result of the transformation is as expected (visually)
However, I need to calculate the rotation matrix also based on the omega, phi, kappa values.
I use my own rotation matrix for (w,f,k) = (omega, phi, kappa) that I have used successfuly in the past for similar transformation problems:
R=[ cos(f)*cos(k) cos(w)*sin(k)+sin(w)*sin(f)*cos(k) sin(w)*sin(k)-cos(w)*sin(f)*cos(k)
-cos(f)*sin(k) cos(w)*cos(k)-sin(w)*sin(f)*sin(k) sin(w)*cos(k)+cos(w)*sin(f)*sin(k)
sin(f) -sin(w)*cos(f) cos(w)*cos(f)];
but I do not get the same result, and indeed it looks not as good. I tried various transformations, also using the inverted
R = R'
but it doesn't work.
I am wondering which transformation matrix is used in the Robotics Toolbox function, as I could not find anything in the documentation.
Just in case, I give you my exaple values in degrees:
omega phi kappa = 3.927820353,4.052795303,44.806238302
and corresponding
roll pitch yaw = -174.358491845,0.100258014,44.950203063
Any help? Thanks!
  4 Comments
Elisavet Konstantina Stathopoulou
@Bjorn Gustavsson I guess I make the same mistake, I tried different combinations but cannot get it right

Sign in to comment.

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 27 Oct 2021
If you have mixed up the order of the rotations you might step through the different combinations of rotations and sign-conventions by separating your R-matrix into the different single-matrix components:
Rx = @(w) [1 0 0;0,cos(w) -sin(w);0 sin(w) cos(w)];
Ry = @(phi) [cos(phi) 0 sin(phi);0 1 0;-sin(phi) 0 cos(phi)];
Rz = @(k) [cos(k) -sin(k) 0;sin(k) cos(k) 0; 0 0 1];
Then you can combine them in different order:
R_1 = @(w,phi,kappa) Rx(w)*Ry(phi)*Rz(kappa);
R_2 = @(w,phi,kappa) Rx(w)*Rz(kappa)*Ry(phi);
R_3 = @(w,phi,kappa) Ry(phi)*Rx(w)*Rz(kappa);
R_4 = @(w,phi,kappa) Ry(phi)*Rz(kappa)*Rx(w);
R_5 = @(w,phi,kappa) Rz(kappa)*Ry(phi)*Rx(w);
R_6 = @(w,phi,kappa) Rz(kappa)*Rx(w)*Ry(phi);
After that you should be able to find the correct one by stepping through the different sign-combinations for w, phi, and kappa. That should at worst be 2^3 cases for each of the 6 matrices, so 48 combinations...
HTH
  3 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 28 Oct 2021
Well then you either have to read the code of the eul2r function and figure out which order and what sign-convention is used, or use the method I proposed on that end of your problem, simply plug in a couple of yaw, pitch and roll-angles and see which combination of my 6 rotation-matrix-functions gives you the same rotation-matrices.
Remo Pillat
Remo Pillat on 2 Apr 2024 at 2:14
Edited: Remo Pillat on 2 Apr 2024 at 2:19
Just like Bjorn mentioned, you can find the source code for eul2r on GitHub. You can see that the rotation matrix is composed of a Z-rotation, a Y-rotation, and a Z-rotation: R = rotz(phi) * roty(theta) * rotz(psi). You can find the source code of the rotz and roty functions in the same repository.
If you have a copy of Robotics System Toolbox, you can easily convert between Euler angles and a rotation matrices with the eul2rotm function. You can specify any axis order you want, but for your example, you get the same result as in eul2r by calling:
eul2rotm([-174.358491845,0.100258014,44.950203063], "ZYZ")
ans = 3x3
-0.8236 -0.5671 0.0000 0.5643 -0.8195 0.1001 -0.0568 0.0824 0.9950
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!