5
$\begingroup$

I have a sensor which gives me Euler angles (roll,pitch,yaw). There is a baseline value of Euler angle (assume it is $5,10,15$) at the beginning.I want to calibrate from this baseline values all subsequent value. How can I get those values? Is it just subtract $5,10,15$ from all values Or is there any rotational matrix for doing so? As an example if any time the value is $5,10,15$ then it should show $0,0,0$ and on the same way show other angle values with respect to the baseline values.I don't know how to do this.

Please advise.

$\endgroup$
6
$\begingroup$

First, you cannot add or subtract Euler angles. They are not vectors. You need to convert the Euler angles to a representation that can be composed such as a rotation matrix or unit quaternion. If $R_b$ is the base line rotation matrix and $R_i$ is a given rotation matrix, then you can measure rotation w.r.t. the baseline using the following formula $R = R_b^{T}R_i$.

To convert from Roll, Pitch, Yaw angles, you need to compose three rotation matrices about the Z, Y and X axes (assuming that Z ~ yaw, Y ~ pitch, and X ~ roll in the local frame). This is just a composition of the three coordinate rotation matrices:

$$R = R_z R_y R_x.$$

To get the euler angles back I refer you to the following: https://stackoverflow.com/questions/11514063/extract-yaw-pitch-and-roll-from-a-rotationmatrix

$\endgroup$
  • $\begingroup$ Thanks Tpofofn. How can I get rotation matrix from euler angles? Also how can I get the final roll,pitch,yaw from resulting rotation matrix R? $\endgroup$ – user2133832 Mar 5 '13 at 3:04
3
$\begingroup$

You cannot add or subtract Euler angles to obtain the relative orientation since Euler angles are highly dependent on the sequence in which they are applied. The easiest conceptual way to think of relative orientation is with rotation matrices, as Tpofofn explains. Here is an example of why you cannot simply subtract Euler angles to obtain the relative orientation.

Imagine we have two sequences of 1-2-3 (aka x-y-z) Euler angles $a,b,c$ and $a',b',c'$, where both sets of angles describe the orientation of an object relative to the same (probably inertial) reference frame. (In your case, the sensor probably uses the orientation at startup as the reference orientation.)

For each set of Euler angles, we can construct a rotation matrix that transforms vectors in the reference frame to the object's frame. For example, to rotate vectors from the reference frame to the first orientation, you would use the rotation matrix

$R_z(c) R_y(b) R_x(a)$

where $R_{n}(\theta)$ denote a rotation of angle $\theta$ about axis $n$. Similarly, to rotate vectors from the reference frame to the second orientation, you would use the rotation matrix

$R_z(c') R_y(b') R_x(a')$

Hence the transformation between the first and second orientations, that is, the rotation matrix required to go from the first to the second orientation, is

$R = R_z(c') R_y(b') R_x(a') ( R_z(c) R_y(b) R_x(a) )^T$

This is the rotation matrix which describes the relative orientation between the first and second sets of Euler angles. To get the Euler angle representation of this rotation matrix, you would need to use some formulas such as in the link provided by Tpofofn. The Euler angles obtained using such formulas will be angles $u,v,w$ such that

$R_z(w) R_y(v) R_x(u) = R$

(assuming that the formulas are those for obtaining 1-2-3 Euler angles from a rotation matrix.)

Conversely, the rotation matrix obtained by simply subtracting the Euler angles is given by

$R_z(c'-c) R_y(b'-b) R_x(a'-a)$

where, in general you will find that

$u \neq a'-a$

$v \neq b'-b$

$w \neq c'-c$

To see that these two matrices are in general different, you just need to write out the symbolic form of these rotation matrices, and compare. For example, since

$R_{1}(a) = \left[\begin{array}{ccc} 1 & 0 & 0 \\ 0 & +\cos(a) & +\sin(a) \\ 0 & -\sin(a) & +\cos(a) \\ \end{array}\right]$

$R_{2}(b) = \left[\begin{array}{ccc} +\cos(b) & 0 & -\sin(b) \\ 0 & 1 & 0 \\ +\sin(b) & 0 & +\cos(b) \\ \end{array}\right]$

$R_{3}(c) = \left[\begin{array}{ccc} +\cos(c) & +\sin(c) & 0 \\ -\sin(c) & +\cos(c) & 0\\ 0 & 0 & 1\\ \end{array}\right]$

we find that the (3,3)-entry of $R$ is given by

$\sin(b) \sin(b') + \cos(a) \cos(a') \cos(b) \cos(b') + \cos(b) \cos(b') \sin(a) \sin(a')$

whereas the (3,3)-entry of $R_z(c'-c) R_y(b'-b) R_x(a'-a)$ is

$\cos(a - a') \cos(b - b')$

Hence the (3,3)-entry of these matrices will only be equal when

$-\sin(b) \sin(b') ( \cos(a - a') - 1) = 0$

which is not true for most rotations.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.