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

查看:169
本文介绍了通过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天全站免登陆