Extended Kalman Filter

Normal Discrete Kalman FIlter

Initialization

x^00=E[x0],P00=E[(x0x^00)(x0x^00)].\hat{x}_{0|0} = E[x_0], \quad P_{0|0} = E\left[(x_0 - \hat{x}_{0|0})(x_0 - \hat{x}_{0|0})^\top\right].

Prediction Step

x^k+1k=Adx^kk+Bduk,\hat{x}_{k+1|k} = A_d \hat{x}_{k|k} + B_d u_k,

Pk+1k=AdPkkAd+Q.P_{k+1|k} = A_d P_{k|k} A_d^\top + Q.

Measurement Update Step

Lk+1=Pk+1kC(CPk+1kC+R)1.L_{k+1} = P_{k+1|k}C^\top \left(CP_{k+1|k}C^\top + R\right)^{-1}.

x^k+1k+1=x^k+1k+Lk+1(yk+1Cx^k+1k).\hat{x}_{k+1|k+1} = \hat{x}_{k+1|k} + L_{k+1}\left(y_{k+1} - C\hat{x}_{k+1|k}\right).

Pk+1k+1=(ILk+1C)Pk+1k.P_{k+1|k+1} = \left(I - L_{k+1}C\right)P_{k+1|k}.


Let’s remind ourselves how we linearise a typical continuous system. A nonlinear, time-varying system is represented in state space as:

x˙(t)=f(x(t),u(t),t),\dot{x}(t) = f(x(t), u(t), t),

y(t)=h(x(t),u(t),t),y(t) = h(x(t), u(t), t),

The vector field f(x,u)f(x, u) is expanded as (uses the Taylor series formula for multi-variate functions):

f(x,u)=f(x,u)+fx(x,u)xp+fu(x,u)up+higher-order terms,f(x, u) = f(x^*, u^*) + \frac{\partial f}{\partial x}(x^*, u^*) x_p + \frac{\partial f}{\partial u}(x^*, u^*) u_p + \text{higher-order terms},

The linearized system around a nominal trajectory is given by (p standing for pertubations around the trajectory):

x˙p(t)=A(t)xp(t)+B(t)up(t),\dot{x}_p(t) = A(t)x_p(t) + B(t)u_p(t),

where:

- A(t)=fx(x(t),u(t))A(t) = \frac{\partial f}{\partial x}(x^*(t), u^*(t)) is the Jacobian of ff with respect to xx.

- B(t)=fu(x(t),u(t))B(t) = \frac{\partial f}{\partial u}(x^*(t), u^*(t)) is the Jacobian of ff with respect to uu.

ff is a vector that consists of multiple functions.


So now let’s look at the non-linear discrete time system.

State Transition (Process Model):

xk+1=f(xk,uk)+wkx_{k+1} = f(x_k, u_k) + w_k

Observation (Measurement Model):

yk=h(xk)+vky_k = h(x_k) + v_k

Similar to the continuous method, we want to linearise this system by finding matrices A and C. We choose our nominal point to linearise around to be x^kk\hat{x}_{k|k} (and uku_k), which is the estimate of xkx_k at time kk given measurements up to kk.

Notice we are linearising around an estimated state as we are trying to create a Kalman filter. Refer back to the original discrete Kalman filter to see how and where x^kk\hat{x}_{k|k} is used.

Define Jacobians for Dynamics:

Ak=fxx^kk,ukA_k = \left.\frac{\partial f}{\partial x}\right|_{\hat{x}_{k|k}, u_k}

This is the same as our standard linearisation process.

Start with the nonlinear measurement model (shifted by one):

yk+1=h(xk+1)+vk+1y_{k+1} = h(x_{k+1}) + v_{k+1}

Linearise h(xk+1)h(x_{k+1}) around the predicted state x^k+1k\hat{x}_{k+1|k}

We use the first-order Taylor expansion of h(x)h(x) about x^k+1k\hat{x}_{k+1|k}:

h(xk+1)h(x^k+1k)+hxx^k+1k(xk+1x^k+1k)+higher order termsh(x_{k+1}) \approx h(\hat{x}_{k+1|k}) + \left.\frac{\partial h}{\partial x}\right|_{\hat{x}_{k+1|k}} (x_{k+1} - \hat{x}_{k+1|k}) + \text{higher order terms}

This is the standard Taylor expansion, shown previously:

h(x)h(a)+h(a)(xa)+H.O.T.h(x) \approx h(a) + h'(a)(x - a) + \text{H.O.T.}

In our case:

- x=xk+1x = x_{k+1}

- a=x^k+1ka = \hat{x}_{k+1|k}

Now, here’s a trick.

We define the CC Jacobian matrix as the following (since we shifted by one, we use k+1):

Ck+1=hxx^k+1kC_{k+1} = \left.\frac{\partial h}{\partial x}\right|_{\hat{x}_{k+1|k}}

So now we go from

yk+1=h(xk+1)+vk+1y_{k+1} = h(x_{k+1}) + v_{k+1}

to a linearised version (h is now evaluated so no longer a function, we also drop the v after),

yk+1h(x^k+1k)+Ck+1(xk+1x^k+1k)+vk+1\Rightarrow y_{k+1} \approx h(\hat{x}_{k+1|k}) + C_{k+1}(x_{k+1} - \hat{x}_{k+1|k}) + v_{k+1}

Using these ideas (not sure how), we get the following:

Old

New

Prediction Step:

x^k+1k=Adx^kk+Bduk,\hat{x}_{k+1|k} = A_d \hat{x}_{k|k} + B_d u_k,

Pk+1k=AdPkkAd+Q.P_{k+1|k} = A_d P_{k|k} A_d^\top + Q.

Prediction Step:

x^k+1k=f(x^kk,uk).\hat{x}_{k+1|k} = f(\hat{x}_{k|k}, u_k).

Pk+1k=AkPkkAk+Qk.P_{k+1|k} = A_k P_{k|k} A_k^\top + Q_k.

Measurement Update Step:

Lk+1=Pk+1kC(CPk+1kC+R)1.L_{k+1} = P_{k+1|k}C^\top \left(CP_{k+1|k}C^\top + R\right)^{-1}.

x^k+1k+1=x^k+1k+Lk+1(yk+1Cx^k+1k).\hat{x}_{k+1|k+1} = \hat{x}_{k+1|k} + L_{k+1}\left(y_{k+1} - C\hat{x}_{k+1|k}\right).

Pk+1k+1=(ILk+1C)Pk+1k.P_{k+1|k+1} = \left(I - L_{k+1}C\right)P_{k+1|k}.

Measurement Update Step:

Lk+1=Pk+1kCk+1(Ck+1Pk+1kCk+1+Rk+1)1.L_{k+1} = P_{k+1|k} C_{k+1}^\top \left(C_{k+1} P_{k+1|k} C_{k+1}^\top + R_{k+1}\right)^{-1}.

x^k+1k+1=x^k+1k+Lk+1(yk+1h(x^k+1k)).\hat{x}_{k+1|k+1} = \hat{x}_{k+1|k} + L_{k+1} \left(y_{k+1} - h(\hat{x}_{k+1|k})\right).

Pk+1k+1=(ILk+1Ck+1)Pk+1k.P_{k+1|k+1} = (I - L_{k+1} C_{k+1}) P_{k+1|k}.