Kalman Filter

I made the demos below after implementing a Kalman filter, for the second time, and having to remind myself of various intracacies and behaviors of the filter. I didn't find any interactive demos on the web that both show a non-trivial implementation and let you change the parameters set in the filter, and see how they affect it's behavior.

I'm not going to repeat the various basic introductory content, which can be found in a web search.

This Kalman filter implementation is seeking to model free motion in two dimensions (such as that of a vehicle, robot, person, etc.), where both the position and the velocity of the object can be observed. That's very similar to the data you would get from a GPS reciever (say a Garmin GPS 18X OEM module).

It does that with a constant velocity model, with process noise in the position. Since the motion in independent in the two axes, two independent trackers are used for the position and velocity on each axis. In practice, I think that velocity may frequently be measured along the direction of travel, while the heading measurement is independent and has it's own error behavior. So the assumption of independent observations along each axis would fall apart, if that were the case. However, assuming the error is small, it seems this approach does perform well.

A more complex process model is tempting, but unless we have a good understanding of how our process should be modeled, I think the simple model is more easily tuned. Although the velocity is constant, the free motion (turns, acceleration) is accounted for in the process noise.

The original Kalman filter implementation was adapted from https://github.com/villoren/KalmanLocationManager, but modified significantly, since that model does not account for velocity observations.

One common task when "tuning" the filter (once we are sure we have a correct implementation) is to select values for the observation noise and the process noise that allow the filter to track with the desired degree of damping. Adjusting the parameters in the animation below will show how the damping is affected.