iPhone 加速度计速度和距离
我想从加速度计事件中查找行驶距离和速度。就像 iphone 的 gMeter 应用程序正在做的那样。
有什么建议吗?我应该使用哪个值或公式?
提前致谢。
I want to find distance traveled and velocity from accelerometer events. Like iphone's gMeter application is doing.
Any suggestion, by which value or formula I should use for that?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用加速度计的加速度值来测量速度和距离。有一篇非常好的论文(使用加速度计实现定位算法)解释了从加速度计获得的误差以及从加速度值获取速度和位置的技术。
一些伪代码:
速度[i] = (加速度[i] + 加速度[i-1])/2 * 间隔 + 速度[i-1]
距离[i] = (速度[i] + 速度[i-1])/2 * 间隔 + 距离[i-1]
间隔
是之间的时间>acceleration/velocity[i]
和acceleration/velocity[i-1]
与加速度计的更新频率有关。为了提高准确性,您必须过滤正手的加速度值。我在 iPhone 3GS 上实现了这样的算法,效果非常好。加速度计可让您测量 30 厘米的距离,误差约为 1 厘米。我还没有测试更长的距离。
You can use the acceleration values from the accelerometer to measure the velocity and distance. There is really good paper (Implementing Positioning Algorithms Using Accelerometers) which explains the errors you get from the accelerometer and the techniques to get the velocity and position from the acceleration values.
Some pseudo code:
velocity[i] = (acceleration[i] + acceleration[i-1])/2 * interval + velocity[i-1]
distance[i] = (velocity[i] + velocity[i-1])/2 * interval + distance[i-1]
interval
is the time betweenacceleration/velocity[i]
andacceleration/velocity[i-1]
which is related to the update frequency of the accelerometer.To increase accuracy you have to filter the acceleration values in the forehand. I've implemented such an algorithm on an iPhone 3GS and it worked pretty good. The accelerometer let's you measure distances of 30 cm with an error of approximately 1 cm. I didn't tested longer distances yet.