# Gyro measurement to absolute angles

Let us assume we have a gyro that is perfectly aligned to a global frame ($X,Y,Z$).

From what I know the gyro data give me the angular rate with respect to the gyro axis ($x,y,z$). So let's say I got $\omega_x,\omega_y,\omega_z$. Since I know that the 2 frames are perfectly aligned I perform the following operations:

• $\theta_X = dt * \omega_x$
• $\theta_Y = dt * \omega_y$
• $\theta_Z = dt * \omega_z$

where $\theta_X$ is the rotation angle around $X$ and so on.

My question is: what is this update like in the following steps? Because this time the measurement that I get are no more directly related to the global frame (rotated with respect to the gyro frame).

Thank you!

Your first step works because it is implied that your frames are "aligned", meaning that:

$$\theta_{X_0} = 0 \\ \theta_{Y_0} = 0 \\ \theta_{Z_0} = 0 \\$$

In general (as with any integration!), you have some starting angles(initial condition), $\theta_{(X,Y,Z)_0}$, and you proceed to update from there, such that:

$$\theta_{X_N} = \theta_{X_{N-1}} + \omega_{X_N} dT \\ \theta_{Y_N} = \theta_{Y_{N-1}} + \omega_{Y_N} dT \\ \theta_{Z_N} = \theta_{Z_{N-1}} + \omega_{Z_N} dT \\$$

Note that when your initial conditions are as you use in your example, the $\theta_{N-1}$ terms vanish leaving you with the equations you originally stated.

• That's my actual problem. I would do like you've just shown, but where do I get the angular velocities with respect to the global frame (i.e. $\omega_X$)? Because from the gyro I only get $\omega_x$ (with respect to the gyro frame) and so on. Oct 14 '15 at 13:34
• @charles - that's covered with your other question regarding transforming angular velocities from one frame to another, where my answer is: just use a regular 4x4 transform. If you have questions/comments on this please go to your other question and update the question text or add comments to my answer. Oct 14 '15 at 14:58
• Thank you, that was clarifying. But the thing is: assuming we have the 3 current angles and we want to find the rotation matrix R. How should I do? I thought about RPY, is that correct? And in case, why the rotation composition is in this exact sequence and not PRY for example? Thank you again Oct 14 '15 at 15:05
• @charles - Finding the rotation matrix $R$ is hard because, as you mention, multiplication order matters. This is why some people might prefer to use unit quaternions for rotation instead. This question of "why order matters" is more complicated than can be answered in a comment, but you could read more here or here, but, basically, order matters because it changes your point of reference for the next rotation. Oct 14 '15 at 16:01