如何通过陀螺仪和加速度计找到行进距离? [英] How can I find distance traveled with a gyroscope and accelerometer?

查看:993
本文介绍了如何通过陀螺仪和加速度计找到行进距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个应用程序,使用陀螺+加速度计计算iPhone(非长距离)行进的精确距离。这里不需要GPS。

I want to build an app that calculates accurate Distance travelled by iPhone (not long distance) using Gyro+Accelerometer. No need for GPS here.

我应该如何处理这个问题?

How should I approach this problem?

推荐答案

这个问题背后的基本演算是在表达式

Basic calculus behind this problem is in the expression

(以及y和z中位移的类似表达式)和基本几何是毕达哥拉斯定理

(and similar expressions for displacements in y and z) and basic geometry is the Pythagorean theorem

因此,一旦你的加速度计信号通过一个低通滤波器并在采样间隔dt中及时分箱,你就可以找到x中的位移(原谅我的C ......

So, once you have your accelerometer signals passed through a low-pass filter and binned in time with sampling interval dt, you can find the displacement in x as (pardon my C...)

float dx=0.0f;
float vx=0.0f;
for (int i=1; i<n; i++)
 {
   vx+=(acceleration_x[i-1] + acceleration_x[i])/2.0f*dt;
   dx+=vx*dt;
 }

同样适用于dy和dz。这里

and similarly for dy and dz. Here

float acceleration_x[n];

包含从测量开始到结束的x加速度值,时间为0,dt,2 * dt, 3 * dt,...(n-1)* dt。

contains x-acceleration values from start to end of measurement at times 0, dt, 2*dt, 3*dt, ... (n-1)*dt.

要查找总排水量,您只需

To find the total displacement, you just do

dl=sqrt(dx*dx + dy*dy + dz*dz);

陀螺仪不是必需的,但是如果你测量线性距离,你可以使用陀螺仪读数控制设备的旋转不是太大。如果旋转太强,请让用户重新进行测量。

Gyroscope is not necessary for this, but if you are measuring linear distances, you can use the gyroscope reading to control that rotation of the device was not too large. If rotation was too strong, make the user re-do the measurement.

这篇关于如何通过陀螺仪和加速度计找到行进距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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