<p>I’m trying to use a tri-axial accelerometer as an inclinometer, measuring the so called roll and pitch angles. The underlined principle is that in stationary conditions an accelerometer senses only the gravity acceleration. For this reason, instead of acquiring accelerometer data in various orientation, I simulated the output of an accelerometer starting from two known values of the roll and pitch (user-defined values) and from it I calculated the two angles. More precisely, I defined for each simulation a couple of roll and pitch values belonging to the four quadrants. The output of an accelerometer in stationary conditions can be simulated according to equation 24 of this document</p>
<p><a href="https://www.nxp.com/files-static/sensors/doc/app_note/AN3461.pdf" rel="nofollow noreferrer">https://www.nxp.com/files-static/sensors/doc/app_note/AN3461.pdf</a></p>
<p>I attach below the values of the accelerometer outputs, their ratios, and the true and calculated angles.</p>
<p><a href="https://i.sstatic.net/t8dRo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/t8dRo.png" alt="enter image description here" /></a></p>
<p>As you can see, in most of the cases the calculated angles are different from the true ones. But these discrepancies can be avoided identifying the orientation from the accelerometer values and their ratios signs, and subsequently, adding or subtracting 90° or 180°. Unfortunately, there are two couple of orientations which can not be distinguished using this workaround: the first one corresponds to true values of (296.3, 321.8 – row 5) and (106.3, 221.8 – row 10) of roll and pitch respectively; the second one corresponds to true values of (26.3, 131.8 – row 6) and (206.3, 51.8 – row 12) of roll and pitch respectively. In these two couple of conditions, the values of acceleration and their ratios have the same sign and so cannot be distinguished in order to correct them.
My question is about the most accurate way to calculate the roll and pitch angles from the output of a tri-axial accelerometer considering that the accelerometer can be oriented in whatever pose.</p>

CC BY-SA 4.0
2022-07-04T16:59:22.563Z
This would be particularly helpful to me as well. For a brief, shining moment I had access to the WIT Motion JY61P module that also produced Euler angles directly, but they don't make that thing any longer. I tried using other WIT Motion parts to no avail. So, I'm back to using the MPU6050 and some complex math. If you find a solution please get back to me. I'll do the same for you if I find something.
MartySchrader
CC BY-SA 4.0
2022-07-08T06:39:28.770Z
Wait, do you accept that this only works in "stationary conditions"? What use is it for an aircraft? Generally speaking, you can't possibly tell the effect of acceleration from the effect of gravity. And an aircraft accelerates a lot (for stabilisation and path control). Consider an extreme case: in a free fall, all 3 acceleration components will be close to zero, rendering the solution NAN or extremely noisy. It is possible to use this method in some cases, but with an external cue that acceleration is minimal.
Zeus
<imu>
How to calculate roll and pitch from an accelerometer in whatever orientation?
user4411
# How to calculate roll and pitch from an accelerometer in whatever orientation?

(Asked by: username_0 on 2022-06-16)

I’m trying to use a tri-axial accelerometer as an inclinometer, measuring the so called roll and pitch angles. The underlined principle is that in stationary conditions an accelerometer senses only the gravity acceleration. For this reason, instead of acquiring accelerometer data in various orientation, I simulated the output of an accelerometer starting from two known values of the roll and pitch (user-defined values) and from it I calculated the two angles. More precisely, I defined for each simulation a couple of roll and pitch values belonging to the four quadrants. The output of an accelerometer in stationary conditions can be simulated according to equation 24 of this document

<https://www.nxp.com/files-static/sensors/doc/app_note/AN3461.pdf>

I attach below the values of the accelerometer outputs, their ratios, and the true and calculated angles.

[![enter image description here](https://i.sstatic.net/t8dRo.png)](https://i.sstatic.net/t8dRo.png)

As you can see, in most of the cases the calculated angles are different from the true ones. But these discrepancies can be avoided identifying the orientation from the accelerometer values and their ratios signs, and subsequently, adding or subtracting 90° or 180°. Unfortunately, there are two couple of orientations which can not be distinguished using this workaround: the first one corresponds to true values of (296.3, 321.8 – row 5) and (106.3, 221.8 – row 10) of roll and pitch respectively; the second one corresponds to true values of (26.3, 131.8 – row 6) and (206.3, 51.8 – row 12) of roll and pitch respectively. In these two couple of conditions, the values of acceleration and their ratios have the same sign and so cannot be distinguished in order to correct them.
My question is about the most accurate way to calculate the roll and pitch angles from the output of a tri-axial accelerometer considering that the accelerometer can be oriented in whatever pose.

**Tags:** imu
> **Comments:**
> **username_1**: This would be particularly helpful to me as well. For a brief, shining moment I had access to the WIT Motion JY61P module that also produced Euler angles directly, but they don't make that thing any longer. I tried using other WIT Motion parts to no avail. So, I'm back to using the MPU6050 and some complex math. If you find a solution please get back to me. I'll do the same for you if I find something.  
> **username_2**: Wait, do you accept that this only works in "stationary conditions"? What use is it for an aircraft? Generally speaking, you can't possibly tell the effect of acceleration from the effect of gravity. And an aircraft accelerates a lot (for stabilisation and path control). Consider an extreme case: in a free fall, all 3 acceleration components will be close to zero, rendering the solution NAN or extremely noisy. It is possible to use this method in some cases, but with an external cue that acceleration is minimal.  

---

## 0 answers

