iPhone加速度计的速度和距离 [英] iphone accelerometer speed and distance
问题描述
我想从加速度计事件中找到行进距离和速度。就像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?
谢谢。
推荐答案
您可以使用加速度计中的加速度值来测量速度和距离。确实有很好的论文(使用加速度计实现定位算法)解释了您从加速度计获得的误差以及从加速度值获取速度和位置的技术。
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.
一些伪代码:
velocity [i] =(acceleration [i] +加速度[i-1])/ 2 *间隔+速度[i-1]
距离[i] =(速度[i] +速度[i -1])/ 2 *间隔+距离[i-1]
时间间隔
是介于加速度/速度[i]
和加速度/速度[i-1]
之间的时间,
interval
is the time between acceleration/velocity[i]
and acceleration/velocity[i-1]
which is related to the update frequency of the accelerometer.
要提高精度,您必须在正手中过滤加速度值。我已经在iPhone 3GS上实现了这样的算法,效果很好。加速度计可让您测量30 cm的距离,误差约为1 cm。我还没有测试更长的距离。
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.
这篇关于iPhone加速度计的速度和距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!