EE3901/EE5901 Sensor Technologies
Week 3 Tutorial

Profile picture
College of Science and Engineering, James Cook University
Last updated: 21 March 2023

Question 1

In lectures we considered a Kalman filter for one dimensional movement. There were two state space variables: position and velocity. In this question we will extend this model to two dimensional movement.

Let position be represented by variables xx and yy, and let velocity be x˙\dot{x} and y˙\dot{y} (where the dot means a time derivative has been applied).

Assume that the underlying physics is a “constant velocity” model of the form:

dxdt=x˙dydt=y˙dx˙dt=0dy˙dt=0\begin{align} \frac{dx}{dt} & =\dot{x}\\ \frac{dy}{dt} & =\dot{y}\\ \frac{d\dot{x}}{dt} & =0\\ \frac{d\dot{y}}{dt} & =0 \end{align}

The differential equations (1.1)-(1.4) can be converted to discrete time steps using the rule

fkk1=fk1+(dfdt)k1Δt,\begin{equation} f_{k|k-1}=f_{k-1}+\left(\frac{df}{dt}\right)_{k-1}\Delta t, \end{equation}

where ff is any state variable.

Write down the state vector for this problem, and then derive the state update matrix FF in the Kalman filter prediction step

x^kk1=Fx^k1.\begin{equation} \hat{\boldsymbol{x}}_{k|k-1} = F\hat{\boldsymbol{x}}_{k-1}. \end{equation}

Question 2

This is a discussion question for the tutorial class.

In Question 1, you used position and velocity in the state vector. Why only these two? Why not include acceleration as well? In general, how do you decide which variables belong in the state vector?

Some hints for your consideration:

  • Consider that a system of point masses is governed by an equation of the form F=ma\sum F = ma or more explicitly F=mx¨\sum F = m\ddot{x}.
    • Is x¨\ddot{x} an independent variable?
  • What does it really mean when someone says that a system is governed by a “first order differential equation” or a “second order differential equation”? In particular, how many initial conditions are required? How many unique variables are there?

Question 3

Consider the resistor-capacitor circuit of Figure Q3.

Figure Q3: A basic RC circuit. Zoom:

Suppose that the capacitor is charged to some initial voltage before it is connected to this circuit. The current flowing in this loop is given by the differential equation

i=RCdidt.\begin{equation} i=-RC\frac{di}{dt}. \end{equation}

You are designing a Kalman filter to estimate the current i(t)i(t). There is a single variable, i.e. the state “vector” collapses to a single number in this case. Similarly, the covariance “matrix” reduces to a scalar variance.

(a) Write the equation for the predicted state i^kk1\hat{i}_{k|k-1}.

Hint: Start with the differential equation above, then write the prediction step (as per question 1).

(b) Suppose that the circuit resistance is not known exactly but is instead subject to some measurement variance σR2\sigma_{R}^{2}. Using your result from part (a) and the law of propagating variance (week 2), estimate the variance in i^kk1\hat{i}_{k|k-1} due to σR2\sigma_{R}^{2}.

(c) Using your results from part (a) and (b), write the equation for the prediction step of the state variance, i.e. the equation for Pkk1P_{k|k-1}.

(d) Suppose that you are not able to measure the current directly, but instead, you can measure the voltage across the resistor. Write the measurement “matrix” (in this case a scalar) in the form

Vpredicted=Hki^kk1\begin{equation} V_{predicted}=H_{k}\hat{i}_{k|k-1} \end{equation}

where VpredictedV_{predicted} is the predicted measurement (i.e. the voltage) and HkH_{k} is the measurement “matrix” (in this case a scalar).

(e) Let VV be the measured voltage with associated variance σV2\sigma_{V}^{2}. Write equations for the measurement residual yky_{k} and variance SkS_{k}.

(f) Write the equations for the Kalman gain, updated state, and updated covariance.

Question 4 — software exercise

Validate the performance of the filter from Question 3 by implementing it on a computer.

Here is Matlab starter code that generates noisy measurement data and plots the results. (You are also welcome to use a different programming language if you prefer.)

A properly designed Kalman filter has an impressive ability to handle measurement noise and produce an accurate estimate. In Figure Q4 , the noisy measurements (red) are used to obtain the filtered state (yellow). Your task is to reproduce this figure using your equations from Question 3.

Figure Q4: The results of using the Kalman filter that you designed in Question 3. Zoom:

The software simulation is a great way to build intuition about the behaviour of the filter in the presence of different kinds of issues. Using your software, evaluate how the filter performs when:

(a) The initial state is wrong, i.e. i^0\hat{i}_{0} does not match the true initial current.

(b) The process variance is very large, i.e. add a constant term to Pkk1P_{k|k-1} so it’s much larger than its true value.

(c) The initial state is wrong and measurement variance is very large, i.e. add a constant term to SkS_{k} so it’s much larger than its true value.

(d) The measurement process is extremely inaccurate, e.g. try σR=50\sigma_{R}=50 Ω and σV=5\sigma_{V}=5 V, but give the filter an accurate initial condition and the true process and measurement variances.

(e) The measurement process is extremely inaccurate and the initial condition is wrong.