Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find distance traveled with a gyroscope and accelerometer?

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?

like image 531
Ruchir Agile Avatar asked Jul 11 '11 08:07

Ruchir Agile


People also ask

Can you use accelerometer to measure distance?

The sensors that are used to measure distance are accelerometer and GPS. For measuring distance, accelerometer will provide more details or information than GPS, in the other hand, GPS has some restrictions, such as points, signals, data resolution and sampling rate.

Can you calculate speed from accelerometer?

Simple answer: you can't. You need the initial speed, and then you can measure how the speed change. If you know the initial speed ( for example 0m/s), then you calculate the speed as v = at + inital speed.

What can you measure with a gyroscope?

The gyroscope maintains its level of effectiveness by being able to measure the rate of rotation around a particular axis. When gauging the rate of rotation around the roll axis of an aircraft, it identifies an actual value until the object stabilizes out.


2 Answers

Basic calculus behind this problem is in the expression

enter image description here

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

enter image description here

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;  } 

and similarly for dy and dz. Here

float acceleration_x[n]; 

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.

like image 152
drlemon Avatar answered Oct 07 '22 01:10

drlemon


You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice.

Here is an explanation why (Google Tech Talk) at 23:20. I highly recommend this video.

Similar questions:

  • track small movements of iphone with no GPS

  • What is the real world accuracy of phone accelerometers when used for positioning?

  • how to calculate phone's movement in the vertical direction from rest?

  • iOS: Movement Precision in 3D Space

  • How to use Accelerometer to measure distance for Android Application Development

  • Distance moved by Accelerometer


Update (24 Feb 2013): @Simon Yes, if you know more about the movement, for example a person walking and the sensor is on his foot, then you can do a lot more. These are called

     domain specific assumptions.

They break miserably if the assumptions do not hold and can be quite cumbersome to implement. Nevertheless, if they work, you can do fun things. See the links in my answer Android accelerometer accuracy (Inertial navigation) at indoor positioning.

like image 36
Ali Avatar answered Oct 07 '22 01:10

Ali