EE3901/EE5901 Sensor Technologies
Week 4 Tutorial

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

Question 1

Given a state prediction model of the form

x^kk1=f(x^k1),\hat{\boldsymbol{x}}_{k|k-1}=f(\hat{\boldsymbol{x}}_{k-1}),

the extended Kalman filter predicts the covariance using the equation:

Pkk1=FPk1FT+Qk,P_{k|k-1}=FP_{k-1}F^{T}+Q_{k},

where FF is the Jacobian of f()f\left(\cdot\right) and QkQ_{k} is the process covariance.

Calculate the Jacobian for each prediction model given below.

(a)

f(x)=xx2Δtf(x)=x-x^{2}\Delta t

(b)

f(x)=f(xy)=(x+y2(1Δt)y)f(\boldsymbol{x})=f\left(\begin{array}{c} x\\ y \end{array}\right)=\left(\begin{array}{c} x+y^{2}\\ \left(1-\Delta t\right)y \end{array}\right)

(c)

f(x)=f(xyz)=(xyzyxzzxy)f(\boldsymbol{x})=f\left(\begin{array}{c} x\\ y\\ z \end{array}\right)=\left(\begin{array}{c} x-yz\\ y-xz\\ z-xy \end{array}\right)

(d)

f(x)=f(xyt)=(x+costy+sintt+Δt)f(\boldsymbol{x})=f\left(\begin{array}{c} x\\ y\\ t \end{array}\right)=\left(\begin{array}{c} x+\cos t\\ y+\sin t\\ t+\Delta t \end{array}\right)

Question 2

Develop the equations for an extended Kalman filter for a vehicle moving in a 2D plane as shown in Figure Q2.

Figure Q2: Top-down view of a vehicle with the state variables labelled. Zoom:

The vehicle is described by the state vector

x=(xysθ),\boldsymbol{x}=\left(\begin{array}{c} x\\ y\\ s\\ \theta \end{array}\right),

where xx is the position along the east-west axis, yy is the position along the north-south axis, ss is the speed of movement (where positive ss means forward motion), and θ\theta is the direction of heading measured clockwise from north.

(a) Write a prediction function x^kk1=f(x^k1)\hat{\boldsymbol{x}}_{k|k-1}=f(\hat{\boldsymbol{x}}_{k-1}).

(b) Calculate the Jacobian of ff and hence write the equation for the predicted covariance.

(c) Suppose that the sensors on the vehicle are GPS (measuring position), a speedometer, and a compass. Define which variables would go into the measurement vector z\boldsymbol{z} and hence write down the measurement model hh in the expression zpredicted=h(x^kk1).\boldsymbol{z}_{predicted}=h\left(\hat{\boldsymbol{x}}_{k|k-1}\right).

(d) Suppose that the vehicle has no GPS and the only sensors are a speedometer and compass. Repeat part (c) with a reduced set of sensors.

Question 3

Develop an unscented Kalman filter for the non-linear circuit shown in Figure Q3.1.

Figure Q3.1: The circuit to be analysed for Question 3. Zoom:

This is a second-order system, so it requires two state variables. Choose the following state vector:

x^=(V^1V^2).\hat{\boldsymbol{x}}=\left(\begin{array}{c} \hat{V}_{1}\\ \hat{V}_{2} \end{array}\right).

The measurements are the voltages,

z=(V1V2).\boldsymbol{z}=\left(\begin{array}{c} V_{1}\\ V_{2} \end{array}\right).

The LED is described by the Shockley diode equation,

iD=1012(eV2/0.0261),i_{D}=10^{-12}\left(e^{V_{2}/0.026}-1\right),

where the device parameters (e.g. reverse bias saturation current, ideality factor, and temperature) have already been substituted into the equation. Notice that the voltage across the diode is the same as the voltage across C2\text{C}_{2}. Recall that capacitors are described by i=Cdvdti=C\frac{dv}{dt}.

(a) Analyse the circuit and show that it is described by the following set of differential equations:

dV1dt=V1V2RC1+ViRC1dV2dt=V1V2RC21012C2(eV2/0.0261)+ViRC2.\begin{align*} \frac{dV_{1}}{dt} & =\frac{-V_{1}-V_{2}}{RC_{1}}+\frac{V_{i}}{RC_{1}}\\ \frac{dV_{2}}{dt} & =\frac{-V_{1}-V_{2}}{RC_{2}}-\frac{10^{-12}}{C_{2}}\left(e^{V_{2}/0.026}-1\right)+\frac{V_{i}}{RC_{2}}. \end{align*}

(b) At the point where the diode begins to turns on, these equations are highly non-linear and are numerically challenging to solve. A simple prediction model of the form

(V2)kk1=(V2)k1+(dV2dt)Δt\left(V_{2}\right)_{k|k-1}=\left(V_{2}\right)_{k-1}+\left(\frac{dV_{2}}{dt}\right)\Delta t

fails to converge to the correct solution (unless Δt\Delta t is made impractically small). Figure Q3.2 shows instability resulting from the inadequacies of such a simple prediction model.

Figure Q3.2: Notice the failure of the simple prediction model at the moment where the diode begins to turn on. Zoom:

The instability (indicated with an arrow) would cause problems for any kind of Kalman filter since the prediction model is failing. An improved prediction model requires the use of a differential equation solver that can dynamically choose Δt\Delta t to maintain accuracy. Hence, the prediction step is a computer program, and a derivative-free method like the UKF is required.

Write code to implement an unscented Kalman filter for this system. Starter code is provided that implements an accurate prediction step. Based upon this predictive model, you can build a reliable filter. Write your code and evaluate its performance.