16
Kalman Filtering Jur van den Berg

Kalman filtering

Embed Size (px)

Citation preview

Page 1: Kalman filtering

Kalman Filtering

Jur van den Berg

Page 2: Kalman filtering

Kalman Filtering

• (Optimal) estimation of the (hidden) state of a linear dynamic process of which we obtain noisy (partial) measurements

• Example: radar tracking of an airplane. What is the state of an airplane given noisy radar measurements of the airplane’s position?

Page 3: Kalman filtering

Model

• Discrete time steps, continuous state-space• (Hidden) state: xt , measurement: yt

• Airplane example:

• Position, speed and acceleration

tt

t

t

t

t x

x

x

x~,

yx

Page 4: Kalman filtering

Dynamics and Observation model

• Linear dynamics model describes relation between the state and the next state, and the observation:

• Airplane example (if process has time-step ):

),(~

),(~

,

,1

RNV

QNW

C

A

tt

tt

tt

tt

t

t

0v

0w

vx

wx

y

x

001,

100

10

1 221

CA

Page 5: Kalman filtering

Normal distributions

• Let X0 be a normal distribution of the initial state x0

• Then, every Xt is a normal distribution of hidden state xt. Recursive definition:

• And every Yt is a normal distribution of observation yt. Definition:

• Goal of filtering: compute conditional distribution

ttt WAXX 1

ttt VCXY

ttt YYX yy ,,| 00

Page 6: Kalman filtering

Normal distribution

• Because Xt’s and Yt’s are normal distributions, is also a normal distribution

• Normal distribution is fully specified by mean and covariance

• We denote:

Problem reduces to computing xt|t and Pt|t

stst

sstsst

sstst

PN

YYXYYXN

YYXX

||

0000

00|

,,|Var,,,|E

,,|

x

yyyy

yy

ttt YYX yy ,,| 00

Page 7: Kalman filtering

Recursive update of state

• Kalman filtering algorithm: repeat…– Time update:

from Xt|t, compute a priori distrubution Xt+1|t

– Measurement update: from Xt+1|t (and given yt+1), compute a

posteriori distribution Xt+1|t+1

X0 X1 X2 X3 X4 X5

Y1 Y2 Y3 Y4 Y5

Page 8: Kalman filtering

Time update

• From Xt|t, compute a priori distribution Xt+1|t:

• So,

QAAPAN

WAXAWXAN

WAXWAXN

WAXX

Ttttt

tT

ttttt

tttttt

ttttt

||

||

||

||1

VarVar,EE

Var,E

x

QAAPP

AT

tttt

tttt

||1

||1 ˆˆ xx

Page 9: Kalman filtering

Measurement update

• From Xt+1|t (and given yt+1), compute Xt+1|t+1.

• 1. Compute a priori distribution of the observation Yt+1|t from Xt+1|t:

RCCPCN

VCXCVXCN

VCXVCXN

VCXY

Ttttt

tT

ttttt

tttttt

ttttt

|1|1

1|11|1

1|11|1

1|1|1

VarVar,EE

Var,E

x

Page 10: Kalman filtering

Measurement update (cont’d)

• 2. Look at joint distribution of Xt+1|t and Yt+1|t:

where

RCCPCP

CPP

CN

YXY

YXX

Y

XNYX

Ttttt

Ttttt

tt

tt

tttttt

tttttt

tt

tttttt

|1|1

|1|1

|1

|1

|1|1|1

|1|1|1

|1

|1|1|1

ˆ

Var,Cov

,CovVar,

E

E,

x

x

tt

tt

ttttttt

tttttttt

CP

XCXVXXC

XVCXXY

|1

|1

|11|1|1

|11|1|11

Var,Cov,Cov

,Cov,Cov

Page 11: Kalman filtering

Measurement update (cont’d)

• Recall from undergrad that if

then

• 3. Compute Xt+1|t +1 = (Xt+1|t|Yt+1|t = yt+1):

2221

1211

2

121 ,,

NZZ

21122121122

122121221 ,| zz NZZ

ttT

ttT

tttt

tttT

ttT

tttt

ttttttt

CPRCCPCPP

CRCCPCPN

YXX

|1

1

|1|1|1

|11

1

|1|1|1

1|1|11|1

,ˆˆ

|

xyx

y

Page 12: Kalman filtering

Measurement update (cont’d):

• Often written in terms of Kalman gain matrix:

ttttttt

tttttttt

Ttt

Tttt

CPKPP

CK

RCCPCPK

|11|11|1

|111|11|1

1

|1|11

ˆˆˆ

xyxx

Page 13: Kalman filtering

Kalman filter summary

• Model:

• Algorithm: repeat…– Time update:

– Measurement update:QAAPP

AT

tttt

tttt

||1

||1 ˆˆ xx

ttttttt

tttttttt

Ttt

Tttt

CPKPP

CK

RCCPCPK

|11|11|1

|111|11|1

1

|1|11

ˆˆˆ

xyxx

),(~

),(~

,

,1

RNV

QNW

C

A

tt

tt

tt

tt

t

t

0v

0w

vx

wx

y

x

Page 14: Kalman filtering

Initialization

• Choose distribution of initial state by picking x0 and P0

• Start with measurement update given measurement y0

• Choice for Q and R (identity)– small Q: dynamics “trusted” more– small R: measurements “trusted” more

Page 15: Kalman filtering

Conclusion

• Kalman filter can be used in real time• Use xt|t’s as optimal estimate of state at time t,

and use Pt|t as a measure of uncertainty.

Page 16: Kalman filtering

Extensions

• Dynamic process with known control input• Non-linear dynamic process• Kalman smoothing: compute optimal

estimate of state xt given all data y1, …, yT, with T > t (not real-time).

• Automatic parameter (Q and R) fitting using EM-algorithm