2
$\begingroup$

I cannot comment on the original answer, so I had to ask like this.

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.

[1]: https://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf
[2]: https://i.sstatic.net/hSXgP.png

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.

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

2 Answers 2

0
$\begingroup$

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:

  1. Rotate 180 degrees about your head-to-toe axis. Now you're facing the opposite direction as your original pose, then
  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
  2. Rotate 180 degrees about your head-to-toe axis. Now you are laying on your back (face-up), with your head pointed in the same direction as it was originally.

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?

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$
    – muyustan
    Commented Jul 31, 2019 at 4:36
  • $\begingroup$ Quaternions make a lot of sense if you bother to learn about them. youtube.com/watch?v=d4EgbgTm0Bg $\endgroup$ Commented Jul 31, 2019 at 8:11
  • $\begingroup$ @morbo thanks, I did not know 3B1B has that video. $\endgroup$
    – muyustan
    Commented Aug 1, 2019 at 4:36
1
$\begingroup$

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

thing

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.

$\endgroup$
2
  • $\begingroup$ 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. $\endgroup$
    – muyustan
    Commented Jul 30, 2019 at 4:50
  • $\begingroup$ 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? $\endgroup$ Commented Jul 30, 2019 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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