I work with wildlife collars (lions, elephants) which also collect XYZ accelerometer data. From this, I can visualize pitch and roll of the animals in the collar manufacturers web application, but they have not made this data available to download. I can only download the raw XYZ accelerometer data. The manufacturer has specified that the accelerometers are on 2G and has max value of 32 000 and minimum of -32 000. but I am not sure what that refers to.
Ideally, I would like to be able to find a formula that allows me to convert the XYZ data to pitch and roll in Excel, if possible. I have looked at some online tutorials and forums (Arduino) but so far have not been able to find anything that works.
One of the formulas I tried is:
roll = atan2(y_Buff , z_Buff) * 57.3; pitch = atan2((- x_Buff) , sqrt(y_Buff * y_Buff + z_Buff * z_Buff)) * 57.3;
But the pitch and roll data it returns is very different compared to what I can see in the web-based portal.
For example:
| X | Y | Z | Roll from formula | Pitch from formula | Actual roll | Actual pitch |
|---|---|---|---|---|---|---|
| 1626 | 11908 | 9991 | 40.00013 | 95.97879 | 5.97 | -0.01 |
Could you follow the equations from this site: https://mwrona.com/posts/accel-roll-pitch/
It's a pretty standard accelerometer which is outputting a signed 16 bit integer for each of the three axes (X, Y, Z). The 32,000 is an approximation, it's actually 32,767.
You do have one mistake in your post which is you need square root of ( x * x + y * y + z * z), this gives you the overall magnitude of the signal. Ideally this magnitude * 2 'g' / 32768 would be exactly 1.0g, but it often isn't, so the following calculations will include that calculation.
Using these calculations on your example I got: Pitch 5.97 degrees Roll: 50.00 degrees
I don't see this in your post, but looking at the raw data, if Z up is 0/0, then this sensor is a little bit pitched (pitched is around the Y axis, so use ax as the front 'x' is a little bit pointed up). Then roll (around x, but use ay) is significant because the y measurement is greater than z, so y is closer to being up/down than z. It's not significantly more than z, so 50 > 45 checks out in my intuition.
The sensor may also be mounted rotated so the X, Y, and Z axes could be swapped, you can call each what you'd like.
Hope this helps the animals!