IOS: can I get feed / yaw / roll from accelerometer data?

I want to know what pitch, yaw and roll are on the iPad 1. Since I donโ€™t have deviceMotion, can I get this data from the accelerometer? I assume that I can use a vector that it returns for comparison with a reference vector, i.e. gravity.

Does iOS detect when the device remains, and then perceives it as a gravity vector? Or should I do this? Thanks.

+6
source share
1 answer

You can definitely calculate Pitch and Roll from accelerometer data, but Yaw requires additional information (of course, maybe a gyroscope, but maybe a compass).

As an example, consider Hungry Shark for iOS . Based on how their ui tilt calibration works, I'm sure they use an accelerometer instead of a gyroscope.

In addition, here are some formulas I found in a blog post from Taylor-Robotic for calculating pitch and pitch:

Now that we have 3 outputs, expressed in g, we must be able to calculate the pitch and roll. This requires two more equations.

pitch = atan (x / sqrt(y^2 + z^2)) roll = atan (y / sqrt(x^2 + z^2)) 

This will result in pitch and roll in radians, to convert them into we multiply by 180, then divide by PI.

  pitch = (pitch * 180) / PI roll = (roll * 180) / PI 

The thing I'm still looking for is how to calibrate the pitch and clip values โ€‹โ€‹depending on how the user holds the device. If I canโ€™t figure it out soon, I can open a separate question. Good luck

+4
source

Source: https://habr.com/ru/post/896989/


All Articles