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

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

问题描述

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



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

解决方案

绝对有可能从加速度计数据计算出俯仰和滚动,但是Yaw需要更多信息(陀螺仪肯定但可能指南针可以工作)。



举例来看适用于iOS的饥饿鲨鱼。根据他们的倾斜校准ui 如何工作,我很确定他们使用的是加速度计而不是陀螺仪。 / p>

此外,这里有一些我在来自Taylor-Robotic的博客文章 a用于计算音高和滚动:


现在我们有3个以g表示的输出,我们应该可以
计算音高和滚动。这需要另外两个方程式。

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

这将产生以弧度为单位的俯仰和滚动,将它们转换为
友好度,我们乘以180,然后除以PI。

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


我还在寻找的是如何校准俯仰和滚转值基于用户如何握住设备。如果我不能很快解决,我可能会提出一个单独的问题。祝你好运!


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.

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).

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.

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

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))

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天全站免登陆