Kalman and extended Kalman filtering

March 24, 2020#Tracking#Kalman Filter#Thesis logbook#maritime-autonomy

Kalman filter

Modeling Assumptions

  • System’s state evolution x_k+1=f(x_k,uk)+wx\mathbf{x}\_{k+1} = f(\mathbf{x}\_k,u_k) + w_{\textit{x}} is linear and driven by
    • Known input uku_k
    • Additive process noise wxw_{\textit{x}} which is assumed to be a zero-mean, white and uncorrelated with known covariance matrix Q(k)Q(k)
  • The measurements zk=h(xk,uk)+wzz_k = h(x_k,u_k) + w_z are linear function of the state vector and the input vector with
    • Additive zero-mean white noise with known covariance R(k)R(k)
  • The initial state vector is a random variable with known mean x_0\mathbf{x}\_0 and covariance P0P_0 (initial uncertainty)

Block diagram of a discrete Kalman filtering algorithm

Under the above assumptions the Kalman Filter is the MMSE state estimator. If the random variables are not Gaussian, but one can still obtain their first two moments, then the KF is still the best linear MMSE estimator.

Why the standard KF is not enough

  • Usually the motion models are nonlinear
  • The measurement models are usually nonlinear
  • Unable to capture mode changes(target maneuveres)
  • Can’t handle cross-correlated noise
  • Single target & unimodal method

Extended Kalman Filter

The EKF is a suboptimal state estimation algorithm for nonlinear systems.

Modeling Assumptions

  • Same as the KF except that the state transition function ff and/or the measurement function hh are nonlinear, note that the noises are still assumed to enter additively into the state update/measurement equations.
  • First order Taylor expansion of the nonlinear functions around the current state is a reasonable approximation of the original nonlinear functions.

Taylor approximation of the CTRV motion models

A nonlinear motion model xk=f(xk−1)x_{k} = f({x}_{k-1}) can be linearised around a known state xk−1x_{k-1}

fk−1≈Fk−1=[∇xk−1fk−1T(xk−1)]xk−1→latest estimateTf_{k-1} \approx F_{k-1} = \begin{bmatrix} \nabla_{x_{k-1}} f_{k-1}^{T}(x_{k-1}) \end{bmatrix}_{x_{k-1} \rightarrow\text{latest estimate}}^{T}

and for the CTRV motion model this leads to

FCTRVk−1=[10sin(h+Tω)−sinh⁡ωυcos(h+Tω)−coshωυsinh−sin(h+Tω)+Tωcos(h+Tω)ω201−cos(h+Tω)−cos(ω)ωυsin(h+Tω)−sinhωυcos(h+Tω)−cosh+Tωsin(h+Tω)ω20010000001]F_{{CTRV}_{k-1}} = \begin{bmatrix}1 &0 &\frac{sin(h+T\omega) - \sinh}{\omega} & \upsilon \frac{cos(h+T\omega)-cosh}{\omega} & \upsilon\frac{sinh -sin(h+T\omega) + T\omega cos(h+T\omega)}{\omega^{2}}\\ 0 &1 &-\frac{cos(h+T\omega) - cos(\omega)}{\omega} &\upsilon \frac{sin(h+T\omega)-sinh}{\omega} & \upsilon\frac{cos(h + T\omega) -cosh + T\omega sin(h+T\omega)}{\omega^{2}}\\ 0 &0 &1 &0 &0 \\ 0 &0 &0 &0 &1\end{bmatrix}

Taylor approximation of the measurement models

similarly, a measurement model zk=h(xk)z_k=h(\mathbf{x_k}) can be linearised around the latest motion propagated estimate xkx_{k} as

hk≈Hk=[∇xkhkT(xk)]xk→motion updated estimateTh_{k} \approx H_{k} = \begin{bmatrix} \nabla_{x_{k}} h_{k}^{T}(x_{k}) \end{bmatrix}_{x_{k} \rightarrow\text{motion updated estimate}}^{T}

For example, the radar model that measures distance and bearing to a target with known state vector xk=[x,y,υ,h,ω]T\mathbf{x}_k = [x,y,\upsilon,h,\omega]^T, can be linearised as:

Hk=[xx2+y2yx2+y2000−yx2+y2xx2+y2000]H_k = \begin{bmatrix} \frac{x}{\sqrt{x^2+y^2}} &\frac{y}{\sqrt{x^2+y^2}} &0 &0 &0 \\ -\frac{y}{x^2+y^2} &\frac{x}{x^2+y^2} &0 &0 &0 \end{bmatrix}

Gaussian PDF propagation through a nonlinear model and taylor-approximation.

Sebastian Thrun, Wolfram Burgard, and Dieter Fox. 2005. Probabilistic Robotics (Intelligent Robotics and Autonomous Agents). The MIT Press.

Simulated EKF performance

  • Motion model CTRV, sample time T = 100ms
  • Measurement models, asynchronous measurements from:
    • Noisy Radar measurements: bearing and distance, Ts=5 s
    • Noisy Camera pixel measurements. The camera is measuring the targets horizontal target pixel location on the image plane every Ts=20s.

Overall estimated trajectory of target using CTRV motion model for 8.3 minutes

Sample time function
Radar 5s n-linear
Camera 20s n-linear
CTRV Motion model 0.1s n-linear

Having a close look at a segment of the trajectory one can observe the effect of using a CTRV model.

  • Clearly the estimator is able to adapt to the step change in the turn rate but the convergence to the real track at the moment of the change is rather slow because the motion model that the filter is using assumes constant turn rate with low process noise.
  • The red ellipses correspond to the estimated state uncertainty PkP_k as propagated through the motion model.
  • The green ellipses correspond to the estimated state uncertainty PkP_k after incorporating a measurement zkz_k, whether that be a radar or a camera measurement.

Close up on the previous trajectory

Illustration Representation Variable
Red ellipse Predicted state-uncertainty 3σ3\sigma area P^k\hat{P}_k
Green ellipse Corrected predicted state-uncertainty 3σ3\sigma area P^k\hat{P}_k
Blue trajectory Target’s real trajectory x0:k\mathbf{x}_{0:k}
Red trajectory Estimated target’s state trajectory x^0:k\hat{\mathbf{x}}_{0:k}
Green cross Noisy radar measurements zradarz_{radar}

Filter performance

Performance graphs

The performance of the EKF single target tracker previously shown in 2D, is outlined in the following figures Performance of the EKF on the previous simulation (right click image open in new tab for zoomable image)

From top to bottom:

  • Predicted target position xpx_p and real target position xx w.r.t Seakeeping own-ship frame
  • Predicted target position ypy_p and real target position yy w.r.t Seakeeping own-ship frame
  • Predicted target heading velocity υp\upsilon_p and real target heading velocity υ\upsilon w.r.t Seakeeping own-ship frame
  • Predicted target heading velocity hph_p and real target heading velocity hh w.r.t Seakeeping own-ship frame
  • Predicted target turn rate ωp\omega_{p} and real target turn rate ω\omega
  • Absolute distance prediction error norm ∣e∣=(x−xp)2+(y−yp)2|e| = \sqrt{(x-x_p)^2+(y-y_p)^2}
  • Innovation norm ∣v∣|v|, is a measure of how accurate the filter is tracking the real target, an unbound innovation norm implies that the observations do not match the predicted trajectory anymore i.e the tracker diverged.
  • Innovation of the range measurements
  • Innovation of the range rate Measurements
  • Innovation of the bearing measurement
  • Innovation of the camera localiser measurements

Determinant of PkP_k

Calculating the determinant ∣∣Pk∣∣||P_k|| of the first two columns and rows of the predicted state covariance matrix provides an indication of the magnitude of the tracking uncertainty of the target on the 2D tracking plane. Or in other words a measure of the surface of the plotted uncertainty ellipses. As seen in the figure below, measurement updates from different sensors are able to keep the uncertainty low.

Predicted state covariance matrix determinant