如何在iOS中使用加速计计算速度 [英] How to calculate speed using accelerometer in ios

查看:199
本文介绍了如何在iOS中使用加速计计算速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一种功能来计算移动物体的速度,但是我不想使用GPS (CLLocationManager )。

I want to implement a functionality to calculate the speed of moving object, but I don't want to use GPS(CLLocationManager).

关于其他计算速度的建议吗?

Any suggestions on other ways to calculate speed?

推荐答案


I想要实现一种功能来计算移动物体的速度,但我不想使用GPS(CLLocation)。

I want to implement a functionality to calculate speed of moving object, but I don't want to using GPS(CLLocation).

一个对象以恒定速度行驶时,加速度计无法承受任何力,因此仅靠加速度计不足以确定速度-您只能测量速度的变化。如果您知道初始速度,例如用户告诉您手机处于停止状态,则可以监控加速度并使用它来确定速度。但是,这很容易出错,并且误差会随着时间的推移而累积,因此您的速度测量结果将变得越来越不准确。

An object traveling at constant velocity doesn't experience any forces for the accelerometer to measure, so the accelerometer alone isn't enough to determine velocity -- you can only measure changes in velocity. If you know the initial velocity, like if the user tells you that the phone is at a standstill, then you can monitor acceleration and use that to determine velocity. That's likely to be quite error-prone, however, and the error will accumulate over time so that your velocity measurement will become less and less accurate.

可能还有其他方法测量速度,例如用相机拍摄几张照片并尝试根据图像的变化确定速度。或者,您可以通过观察离开一个已知wifi SSID到到达另一个SSID的时间来测量两个已知点之间的平均速度。但是确定速度的正确方法实际上是使用位置管理器。

There might be other ways to measure speed, like taking several photos with the camera and trying to determine speed from the changes in the images. Or you could measure average speed between two known points by observing the time between leaving one known wifi SSID and reaching another. But the right way to determine velocity is really to use the Location Manager.

这篇关于如何在iOS中使用加速计计算速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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