Elio Saade
Note

Extended Kalman Filter

Topics: State Estimation

Introduction

The Extended Kalman Filter (EKF) is one of the nonlinear versions of the Kalman Filter. It can handle nonlinear state and measurement equations. It works by linearizing the nonlinear model around the current best guess using Jacobians.

Algorithm

A nonlinear model is represented by the following equations:

xk=f(xk−1,uk−1)+wk−1yk=h(xk)+nk\begin{gather} x_k=f(x_{k-1}, u_{k-1}) + w_{k-1} \\ y_k = h(x_k) + n_k \end{gather}

where ff and hh are nonlinear functions. They don't have to be both nonlinear; one of them can be linear.

Similarly to the linear Kalman Filter, the EKF includes a prediction phase and an update phase. The equations are similar except that the state transition matrix AA and the observation matrix CC of the linear model are changed to be the Jacobians FF and HH of ff and hh of the nonlinear model.

The detailed EKF algorithm is presented below. The - superscript is used for predicted values and the + superscript is used for estimated values.

Jacobians

The Jacobians of the nonlinear equations need to be computed at every step:

Fk=∂f∂x∣x^k−1+,  uk−1Hk=∂h∂x∣x^k\begin{gather} F_k = \frac{\partial f}{\partial x} \Bigg \vert _{\hat{x}_{k-1}^+, \; u_{k-1}} \\ \\ H_k = \frac{\partial h}{\partial x} \Bigg \vert _{\hat{x}_k} \end{gather}

I. Prediction

  1. Predict the state x^k−\hat{x}_k^- using the state equation, previous estimate, and the input
x^k−=f(x^k−1+,uk−1)\hat{x}_k^- = f(\hat{x}_{k-1}^+, u_{k-1})
  1. Calculate the Jacobian matrix FkF_k
  2. Predict the error covariance
    Pk−=Fk  Pk−1+  Fk⊤+QP_{k}^{-} = F_k \; P_{k-1}^{+} \; F_k^{\top} + Q
  3. Predict the system output y^k\hat{y}_k using the output equation
    y^k=h(x^k−)\hat{y}_k=h(\hat{x}_k^-)

II. Update

  1. Calculate the Jacobian matrix HkH_k
  2. Calculate the Kalman gain
    Lk=Pk−  Hk⊤[Hk  Pk−  Hk⊤+R]−1L_{k} = P_{k}^{-} \; H_k^{\top}[H_k \; P_{k}^{-} \; H_k^{\top} + R] ^ {-1}
  3. Correct the state prediction based on the output error to get the new estimate x^k+=x^k−+Lk(yk−y^k)\hat{x}_{k}^{+} = \hat{x}_{k}^{-} + L_{k}(y_k - \hat{y}_k)
  4. Update the error covariance matrix
    Pk+=(I−Lk  Hk)Pk−P_{k}^{+} = (I - L_{k} \; H_{k}) P_{k}^{-}

References

  1. https://en.wikipedia.org/wiki/Kalman_filter

Connections

Direct relationships to this note.