iOS/Android 设备方向(俯仰、偏航、滚动)。加速度计好还是陀螺仪好?

发布于 2025-01-05 20:41:16 字数 800 浏览 1 评论 0原文

我已经研究了一段时间,现在我必须决定走哪条路。

地雷要求:需要知道设备相对于真实航向的方向(地理北极,而不是磁极)。 为此,我必须使用指南针,现在我必须决定使用其他东西,加速度计还是陀螺仪。

因为这对我来说是新事物,所以我花了几个小时阅读堆栈和维基百科文章,但我仍然感到困惑。

我的目标是两个平台(iOS 和 Android),并且我正在使用 Appcelerator Titanium 开发它们。使用 Titanium,我可以轻松获得加速度计的值 (x,y,z) 和 trueHeading。

由于 iPhone 3GS 显然没有陀螺仪,因此我无法在该设备上使用它。较新的 iPhone 和 Android 设备都有此功能。

所以问题是:

  1. 加速度计的 XYZ 和指南针的 TrueHeading 数据是否足以让我计算设备的俯仰、滚动和偏航?但它必须准确。

  2. 使用罗盘中的 TrueHeading 并使用陀螺仪的值而不是加速度计的值是否更准确?

  3. 将加速度计和陀螺仪与 TrueHeading 结合起来是否明智?

如果我选择第一条路,我就不必编写 Titanium 模块来获取陀螺仪数据,因为它只提供加速度计数据,而且我也可以在 3GS iPhone 上使用它。

如果我选择第二条路,我必须编写两个模块(iOS 和 Android)来获取陀螺仪数据,并且我会失去 3GS 支持。

如果我走第三条路,我必须再次编写 Titanium 模块,并且失去 3GS 支持。

I've been researching for a bit now and now I have to decide which road to take.

Mine requirements: Need to know device's orientation relative to the true heading (geographic north pole, not magnetic pole).
For that I must use compass and now I have to decide which other thing, accelerometer or gyroscope.

Since this is a new thing to me I've spent last few hours reading stacks and wikipedia articles and still I am confused.

I am targeting both platforms (iOS and Android) and I am developing them with Appcelerator Titanium. With Titanium I can easily get accelerometer's values (x,y,z) and trueHeading.

Since iPhone 3GS does not have gyroscope obviously I can't use it on that device. Newer iPhones and Android devices have it.

So the questions are:

  1. Is accelerometer's XYZ and compas's TrueHeading data enough for me to calculate device pitch, roll and yaw? But it has to be accurate.

  2. Is it more accurate to use TrueHeading from compas and use gyroscope's values instead of accelerometer's?

  3. Is it clever to combine both accelerometer and gyroscope with TrueHeading?

If I take the first road I don't have to write Titanium module for fetching the gyroscope data since it gives me only accelerometer data and I can use this on 3GS iPhone also.

If I take the second road I have to write two modules (iOS and Android) to fetch me gyroscope data and I lose 3GS support.

If I take the third road I again have to write Titanium modules and I lose 3GS support.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

轻许诺言 2025-01-12 20:41:16

首先,如果您没有庞大的 3GS 用户安装基础,但编写新应用程序,则不必关心旧硬件。 IMO 从经济角度来看这没有意义,但会减少系统架构中的替代方案数量。

您正在寻找的称为传感器融合。因此,执行此操作需要一些繁重的数学运算,例如卡尔曼滤波器等。好消息是它存在于 iPhone 上(Core Motion)和 AFAIK 在 Andriod 上也是如此(听起来像是在 在 Android 上实现传感器融合?)。

除了名称之外,我对 appcelerator 知之甚少,因此无法透露使用它的简单方法。无论如何,如果不是在抽象层上实现,我认为 appcelerator 为您提供了执行本机 API 调用的可能性。因此,您应该能够嵌入本机 API(经过一段时间的摆弄之后;-)。

一般来说,这取决于您的要求。您需要越快获得准确的结果,我就越推荐使用真正的传感器融合,包括所有 3 个传感器。如果您愿意接受较慢的响应时间,指南针和加速度计的组合就可以了。

First of all if you don't have a huge installed base of 3GS users but write a new app, don't care about old hardware. IMO it doesn't make sense from an economical point of view but will shrink your number of alternatives in system architecture.

What you are looking for is called sensor fusion. Doing this consequently requires some heavy math like Kalman Filters etc. The good news is that it exists on iPhone (Core Motion) and AFAIK on Andriod as well (sounds like it is in Sensor fusion implemented on Android?).

I don't know much about appcelerator aside from the name and thus cannot say anything about an easy way to use it. Anyway if not implemtented on an abstract layer, I assume appcelerator provides you with the possibility to do native API calls. Thus you should be able to embed the native API (after fiddling around some time;-).

In general it depends on your requirements. The faster you need to have an exact result the more I'd recommend real sensor fusion including all 3 sensors. If you are fine with a slower response time, a combination of compass and accelerometer will do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文