# Is the information on the following link logical?

I am trying to learn IMU's, accelerometers, gyros etc. for a while.

So I came across with this answer below,

https://engineering.stackexchange.com/a/22182/21263

From the accelerator sensor data, you can only calculate pitch and roll. The bellow document from Freescale explains with plenty of information what you need:

[AN3461 - Tilt Sensing Using a Three-Axis Accelerometer][1]

Based on the sayings of the document,

$$\tan \phi_{xyz} = \frac{G_{py}}{G_{pz}}$$

$$\tan \theta_{xyz} = \frac{-G_{px}}{G_{py}\sin \phi + G_{pz}\cos > \phi} = \frac{-G_{px}}{\sqrt{G_{py}^2 + G_{pz}^2}}$$

which equates to:

roll = atan2(accelerationY, accelerationZ)

pitch = atan2(-accelerationX, sqrt(accelerationY*accelerationY + accelerationZ*accelerationZ))


Of course, the result is this only when the rotations are occurring on a specific order (Rxyz):

1. Roll around the x-axis by angle $$\phi$$
2. Pitch around the y-axis by angle $$\theta$$
3. Yaw around z-axis by angle $$\psi$$

Depending on the rotations order, you get different equations. For the $$R_{xyz}$$ rotation order, you can not find the angle $$\psi$$ for the Yaw around z-axis.

But I don't see how the order of turn motions matters in case of getting pitch & roll from accelerometer data. Without the histoy of orders, the accelerometer will give specific outputs at specific orientations.

So what I am actually asking is whether the answer I shared is logical or not. Could you please clear the situation for me?

Thanks.

• google gimbal lock – jsotola Jul 29 at 18:06
• @jsotola I know some about it but how it is related with my question, I could not understand. – muyustan Jul 29 at 18:15

Without the histoy of orders, the accelerometer will give specific outputs at specific orientations.

Correct, but you might define a specific orientation ambiguously, and if you are ambiguous about it then you need to clarify.

Consider this example:

2. Rotate forward 90 degrees about your heel-to-heel axis. Now you're laying on your stomach (face-down), with your head pointed opposite of the direction you were originally facing.

Now, keep the rotations the same, but change the order:

1. Rotate forward 90 degrees about your heel-to-heel axis. Now you're laying on your stomach (face-down), with your head pointed in the same direction as you were originally facing, then

Now, if you had an IMU/accelerometer in your hand, it would clearly give different readings for those two results, but that's because they're two different orientations. You can't just say it's 180 about this and 90 about that, you have to specify which rotation happens first if you want someone else to be able to understand.

The way I think about it is that the order of rotation is an extra parameter in the description of the orientation. An angle about each of three axes and then an ordering of those axes. Four things to track: x, y, z, and the order in which they're applied.

If you want to guarantee you're getting a pose right without having to worry about whether you're using the right formula, you may want to consider quaternions. They also happen to have four parameters, but they're not in any kind of sensible units. You can imagine what a 45 degree rotation about an x-axis looks like, but what does a quaternion look like?

• Hey! You explained well, thanks for that. But you first encourage me to have a look at quaternions and then you say they are hard to imagine. So I assume I don't have to fully understand in order to utilize them? – muyustan Jul 31 at 4:36
• Quaternions make a lot of sense if you bother to learn about them. youtube.com/watch?v=d4EgbgTm0Bg – morbo Jul 31 at 8:11
• @morbo thanks, I did not know 3B1B has that video. – muyustan Aug 1 at 4:36

The Answer is logical simply because its a mathematical statement that explains how calculate Euler angles..from accel measurements...it also explains one of the caveats of using said system. Namely what was suggested in the comments

Gimbal lock

From the wiki animation one can see that the system can get stuck if rotated in a specific way causing them system to lock up and entire angles being completely gone.

Gimbal locked airplane. When the pitch (green) and yaw (magenta) gimbals become aligned, changes to roll (blue) and yaw apply the same rotation to the airplane. -wiki

This is one of the reasons Quaternions Are used as a way to measure angle as the dont suffer from the same issue as Euler angles, but are however difficult to visualize.

Quaternions find uses in both pure and applied mathematics, in particular for calculations involving three-dimensional rotations such as in three-dimensional computer graphics, computer vision, and crystallographic texture analysis.5 In practical applications, they can be used alongside other methods, such as Euler angles and rotation matrices, or as an alternative to them, depending on the application.

However, accels...are generally...useless by themselves if you want to calculate a real angle. As such one generally fuses them with gyros and sometimes magnometers or other sensors to get a more stable and real measurement.

• This is a nice answer, however does not answer my question really. Accel gives some output(stationary lets say, only 1g output) you compose that vector into its xyz components and then calculate p and r using those formulas. So what is the order issue? Is it something like that; those p and r angles found from that specific formulas will give orientation of the body in such way that if one applies them in a particular order, then s/he gets that orientation? Thanks anyway. – muyustan Jul 30 at 4:50
• I did answer your question, if you rotate in a specific way, yaw can be lost, going from a 3DOF system to a 2DOF system....in this case Yaw and roll now describe the same thing....this is gimbal lock...a serious issue with Euler angles and the problem using rotational matrices to rotate a vector. did you not see the animation? Or read any of the provided links? – morbo Jul 30 at 8:18