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

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

问题描述

我想构建一个应用程序,使用陀螺仪+加速度计计算 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];

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

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天全站免登陆