Object Tracking using the Kalman Filter

Track an object using the Kalman filter to reconstruct it's trajectory and velocity from noisy measurements in real time. The object, indicated by a blue pentagon, undergoes motion in a gravitional potential of adjustable magnitude created by an external mass, indicated by Mars, whose position can be controlled by the user in the pane on the right. The boundary conditions at the box edge are reflective. At regular intervals in time, measurements of the object's position are made with some additive measurement noise, drawn from a zero-mean Gaußian distribution. The Kalman filter is used to reconstruct both the trajectory of the object, shown in red, and the object's velocity, whose magnitude is indicated in the plot on the bottom left. The mean square error (MSE) between the reconstructed and true state vectors is shown as an estimate of the filter's performance in the middle left pane. The trace of the state covariance matrix is also shown in the middle right plane.
  • Contributed by: Oliver K. Ernst

THINGS TO TRY

SnapshotsSectionGroupMaker[Transpose[{}]]

DETAILS

Snapshot 1: the filtered trajectory as well as it's velocity are reconstructed in real time.
Snapshot 2: at high measurement noise, the accuracy of the filter deteriorates.
Snapshot 3: it is possible to adjust the magnitude of the gravitational potential to be repulsive (negative), as well as an optional constant deacceleration.
The object undergoes motion in a gravitational field, experiencing an acceleration
Here, is the vector from the planet Mars to the object, is the strength of the potential, adjustable by the user to be either positive (attractive) or negative (repulsive), and is a constant acceleration in the direction opposite the velocity of the object, also adjustable by the user. In the case of a collision between the object and Mars, the object is stopped on the planet's surface, while the walls of the box are reflective.
The Kalman filter is used to reconstruct the position and velocity of the object from noisy position measurements. For a detailed description of the Kalman filter, see e.g. [1,3,4]. Following the notation in [1], the model for the object's discrete time evolution can be expressed as
where denotes the state vector, and denotes the noisy position measurements made, is the process noise, is the measurement noise, and
;
The measurement noise covariance matrix is assumed to be known
where is the two dimensional identity matrix and is the measurement noise variance set by the user. The process noise covariance is given by
where is the variance of the component of the acceleration, and similarly for . The variances are determined from a sample of the true accelerations experienced by the object (with sample size equal to the variable number of data points), although in practice this information is not available and other methods must be employed (see e.g. [2]).
To determine the performance of the filter, two measures are updated in real time: (i) the MSE, , and (ii) the trace of the state covariance matrix.
References
[1] Wikipedia, the free encyclopedia. Kalman filter. https://en.wikipedia.org/wiki/Kalman_filter.
[2] Fernando V. Lima and Murali R. Rajamani. Autocovariance Least-Squares (ALS) Toolbox. http://jbrwww.che.wisc.edu/software/als/index.html.
[3] Cuevas, E., Zaldivar, D., and Rojas, R, "Kalman filter for vision tracking." 2005.
[4] Kalman, R. E. "A New Approach to Linear Filtering and Prediction Problems." Trans. ASME Ser. D. J. Basic Eng. 82, 35-45, 1960.

RELATED LINKS