iOS:我可以从加速度计数据中获取俯仰/偏航/滚转吗? [英] iOS: Can I get the pitch/yaw/roll from accelerometer data?

查看:29
本文介绍了iOS:我可以从加速度计数据中获取俯仰/偏航/滚转吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 iPad 1 上找出俯仰、偏航和滚动.由于没有 deviceMotion 工具,我可以从加速度计获取这些数据吗?我假设我可以使用它返回的向量与参考向量(即重力)进行比较.

I want to find out the pitch, yaw, and roll on an iPad 1. Since there is no deviceMotion facility, can I get this data from the accelerometer? I assume that I can use the vector that it returns to compare against a reference vector i.e. gravity.

iOS 是否检测到设备何时静止,然后将其作为重力向量?还是我必须这样做?谢谢.

Does iOS detect when the device is still and then take that as the gravity vector? Or do I have to do that? Thanks.

推荐答案

绝对可以根据加速度计数据计算俯仰和滚转,但偏航需要更多信息(当然是陀螺仪,但可能可以使指南针工作).

It's definitely possible to calculate the Pitch and Roll from accelerometer data, but Yaw requires more information (gyroscope for sure but possibly compass could be made to work).

例如查看 Hungry SharkiOS .根据他们的倾斜校准用户界面的工作原理,我很确定他们使用的是加速度计而不是陀螺仪.

For an example look at Hungry Shark for iOS . Based on how their tilt calibration ui works I'm pretty sure they're using the accelerometer instead of the gyroscope.

此外,这里是我在 Taylor-Robotic 的博文,用于计算俯仰和滚转:

Also, here are some formula's I found on a blog post from Taylor-Robotic a for calculating pitch and roll:

既然我们有 3 个以 g 表示的输出,我们应该能够计算俯仰和滚转.这需要另外两个方程.

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

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

这将产生以弧度表示的俯仰和滚转,将它们转换为我们将友好度乘以 180,然后除以 PI.

This will produce the pitch and roll in radians, to convert them into friendly degrees 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 roll values based on how the user is holding the device. If I can't figure it out soon, I may open up a separate question. Good Luck!

这篇关于iOS:我可以从加速度计数据中获取俯仰/偏航/滚转吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆