User Tools

Site Tools


cs401r_w2016:lab7

This is an old revision of the document!


Objective:

To understand state space models, and in particular, the Kalman filter.


Pre-requisite:

You must install the python skimage package. This can be installed via conda install skimage.


Deliverable:

For this lab, you will implement the Kalman filter algorithm on two datasets. Your notebook should produce two visualizations of the observations, the true state, the estimated state, and your estimate of the variance of your state estimates.

For the first dataset, you will implement a simple random accelerations model and use it to track a simple target. Your final visualization should look something like the following:

For the second dataset, you will use a series of '(x,y)' observations that were derived from a vision processing task. For this dataset, you will need to set the parameters of your filter to whatever best values you can, and then show a visualization of the result. The visualization of the result should consist of two parts:

  1. First, a series of frame snapshots showing the estimated position and uncertainty
  2. Second, a plot of how the ball moved around in the field of view

Examples of both are here:


Grading:

Your notebook will be graded on the following elements:

  • 20% Kalman gain is correctly computed
  • 20% State is correctly updated
  • 20% Covariance is correctly computed
  • 20% State and covariance are correctly recorded
  • 20% Final plot is tidy and legible

Description:

For the first dataset, you will perform simple target tracking using the random accelerations model. You should use the equations given in Lecture 17. The data can be found here:

Simple target tracking data

There are two arrays in this .mat file: data contains the actual (noisy) observations at each timestep, while true_data contains the true x,y coordinates at each timestep. Note that your kalman filter should only use the noisy observations; the true x,y coordinates are only given for visualization purposes.

To visualize the uncertainty at each timestep, the code for plotting the 95% confidence interval of a Gaussian, from lab 6, can be used.

The model is given by

# our dynamics are described by random accelerations
A = np.asarray([
    [ 1, 0, 1, 0, 0.5, 0 ],
    [ 0, 1, 0, 1, 0, 0.5 ],
    [ 0, 0, 1, 0, 1, 0 ],
    [ 0, 0, 0, 1, 0, 1 ],
    [ 0, 0, 0, 0, 1, 0 ],
    [ 0, 0, 0, 0, 0, 1 ] ])
 
# our observations are only the position components
C = np.asarray([
    [1, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 0, 0]])
 
# our dynamics noise tries to force random accelerations to account
# for most of the dynamics uncertainty
Q = 1e-2 * np.eye( 6 )
Q[4,4] = 0.5  # variance of accelerations is higher
Q[5,5] = 0.5
 
# our observation noise
R = 20 * np.eye( 2 )
 
# initial state
mu_t = np.zeros(( 6, 1 ))
sigma_t = np.eye( 6 )

Hints:

To avoid numerical instabilities in the calculation of your covariance matrices, you may want to use np.linalg.pinv.

cs401r_w2016/lab7.1455771078.txt.gz · Last modified: 2021/06/30 23:40 (external edit)