# [racket] what initial velocity to use when calculating velocity from acceleration (peripherally moby-related...)

 From: Will M. Farr (wmfarr at gmail.com) Date: Tue Nov 30 16:02:01 EST 2010

```On Nov 30, 2010, at 2:52 PM, Joe Marshall wrote:

> An integrator is likely to `drift' over time.  In theory, when you
> stop moving you
> should have to apply exactly the same acceleration in reverse from when you
> started.  In practice, however, the two accelerations won't quite
> cancel (there will
> be errors in measurement and error accumulation in the integrator).
> You'll have to
> re-zero the integration every now and then to keep it at a sane value.
>
> Alternatively, you could use GPS or some other position data to supply an upper
> bound on the velocity and acceleration and then try to correct the integration
> that way.
>
> In any case, this is an officially difficult problem which has no
> known `solution'.
> You're going to learn a lot!

In particular, combining noisy measurements in the context of an ODE that describes the evolution of a system (in this case, you measure a = dv/dt = d^x/dt^2, and want to "integrate" to find x(t)) is often done using a Kalman filter:

http://en.wikipedia.org/wiki/Kalman_filter

This is also almost certainly the approach you would take if you want to combine data from a GPS unit with the accelerometer data.  Kalman filters are often used in commercial inertial navigation systems (i.e. in planes) to track position as well.  The literature on the subject is *very* extensive, if you enjoy that sort of reading.  Alternately, from the basic description it can be fun to work out a lot of the simple results yourself (depending, of course, on how much you enjoy math and what your level of experience with statistics and differential equations are).  In practice (from someone who is not in the field of inertial navigation, but has heard talks about it) it seems like the "tuning" of the filter is as much art as science, so I wouldn't necessarily assign too much weight to the prior literature in your case.

Have fun!

Will
```

 Posted on the users mailing list.