通过 iPhone SDK 测量速度 [英] Measuring velocity via iPhone SDK

查看:31
本文介绍了通过 iPhone SDK 测量速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现一个本机 iPhone 应用程序来测量手机的速度(基本上是一个速度计).我知道您可以通过 CoreLocation API 轻松完成此操作,但我担心电池消耗,因为这是一种实时测量,一次最多可以使用几个小时.我的理解是,当您从 LocationManager 主动监控事件时(即使我实际上并不关心 GPS 位置),它会消耗大量电池.

I need to implement a native iPhone app to measure the velocity of the phone (basically a speedometer). I know that you can do so via the CoreLocation API fairly easily, but I am concerned about battery consumption since this is to be a real-time measurement that could be used for up to a couple of hours at a time. My understanding is that while you are actively monitoring for events from the LocationManager (even though I don't actually care about GPS location) it is battery-intensive.

另一个明显的探索选项是使用加速度计来尝试计算速度,但 API 中没有任何内容可以帮助您这样做.根据我的研究,应该可以做到这一点,但似乎非常复杂且容易出错.从加速度到速度的转换一开始可能很棘手,而且 iPhone 加速度计数据可能会嘈杂".我熟悉演示使用低/高通过滤等的 SDK 示例——但我没有在任何地方看到一个显示计算速度的好示例.

The other obvious option to explore would be using the accelerometers to try and calculate speed, but there is nothing in the API to help you do so. Based on my research, it should be possible to do this, but seems extremely complicated and error-prone. Translating from acceleration to velocity can be tricky to begin with, plus the iPhone accelerometer data can be "noisy". I'm familiar with the SDK example that demonstrates using low/high pass filtering, etc. -- but I have not seen a good example anywhere that shows calculating velocity.

有没有人有这方面的实际经验可以分享?代码会很棒,但我真的只想知道是否有人成功地做到了这一点(对于一个长期存在的应用程序)以及他们采取了什么方法.

Does anyone have any real-world experience with this they can share? Code would be fantastic, but really I just want to know if anyone has successfully done this (for a long-lived app) and what approach they took.

编辑:我有一个使用 LocationManager API 的工作原型.它工作正常,但更新周期远不适合实时测量速度.根据情况,有时可能需要 4-5 秒才能更新.以给定速度巡航往往可以正常工作,但从用户交互的角度来看,加速/减速往往会非常滞后.此外,我需要将速度输入到我正在做的其他一些计算中,而精度并不是我真正需要的.

EDIT: I've got a working prototype that uses the LocationManager API. It works OK, but the update cycle is far from ideal for a real-time measurement of velocity. Depending on circumstances, it can take up to 4-5 seconds sometimes to update. Cruising at a given speed tends to work OK, but accel/decel tend to lag very badly from a user interaction standpoint. Also, I need to feed velocity into some other calculations that I'm doing and the precision is not really what I need.

基于我见过的(很少)其他应用程序,这似乎是可能的,特别是 gMeter声称不使用 GPS,但准确计算速度.我真的很惊讶在我能找到的任何地方都没有参考资料或任何示例代码来演示这一点.我意识到这很复杂,但肯定有一些东西在那里.

It seems possible based on (very few) other apps I've seen, notably gMeter which claims to make no use of GPS but calculates velocity accurately. I'm really surprised there are no references or any sample code that demonstrates this anywhere that I can find. I realize it's complex, but surely there's something out there.

推荐答案

由于 GPS 和加速度计有不同的弱点,您最好的选择可能是组合方法 - 每分钟左右从 GPS 获取一次测量值,然后添加实时更改从加速度计.

Since the GPS and accelerometer have different weaknesses, your best option is probably a combined approach - Get a measurement from the GPS every minute or so, then add realtime changes from the accelerometer.

这篇关于通过 iPhone SDK 测量速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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