29
An Introduction to Kalman Filtering by Arthur Pece [email protected]

An Introduction to Kalman Filtering by Arthur Pece [email protected]

Embed Size (px)

Citation preview

Page 1: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

An Introduction toKalman Filtering

byArthur [email protected]

Page 2: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Generative model for a generic signal

Page 3: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Basic concepts in tracking/filtering

• State variables x; observation y: both are vectors

• Discrete time: x(t), y(t), x(t+1), y(t+1)

• Probability P

• pdf [density] p(v) of vector variable v :

p(v*) = lim P(v* < v < v*+dv) / dv dv->0 .

Page 4: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Basic concepts:Gaussian pdf

A Gaussian pdf is completely characterized by 2 parameters:

• its mean vector

• its covariance matrix

Page 5: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Basic concepts: prior and likelihood

• Prior pdf of variable v: in tracking, this is usually the probability conditional on the previous estimate: p[ v(t) | v(t-1) ]

• Likelihood: pdf of the observation, given the state variables: p[ y(t) | x(t) ]

Page 6: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Basic concepts:Bayes’ theorem

• Posterior pdf is proportional to prior pdf times likelihood:

p[ x(t) | x(t-1), y(t) ] =

p[ x(t) | x(t-1) ] p[ y(t) | x(t) ] / Zwhere

Z = p[ y(t) ]

Page 7: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Basic concepts:recursive Bayesian estimation

Posterior pdf given the set y(1:t) of all observations up to time t:

p[ x(t) | y(1:t) ] =

p[ y(t) | x(t) ] . p[ x(t) | x(t-1) ] .

p[ x(t-1) | y(1:t-1) ] / Z1

Page 8: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Basic concepts:recursive Bayesian estimation

p[ x(t) | y(1:t) ] =

p[ y(t) | x(t) ] . p[ x(t) | x(t-1) ] .

p[ y(t-1) | x(t-1) ] . p[ x(t-1) | x(t-2) ] .

p[ x(t-2) | y(1:t-2) ] / Z2

Page 9: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Basic concepts:recursive Bayesian estimation

p[ x(t) | y(1:t) ] =

p[ y(t) | x(t) ] . p[ x(t) | x(t-1) ] .

p[ y(t-1) | x(t-1) ] . p[ x(t-1) | x(t-2) ] .

p[ y(t-2) | x(t-2) ] . p[ x(t-2) | x(t-3) ] .

… / Z*

Page 10: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman model

Page 11: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman model in words

• Dynamical model: the current state x(t) is a linear (vector) function of the previous state x(t-1) plus additive Gaussian noise

• Observation model: the observation y(t) is a linear (vector) function of the state x(t)

plus additive Gaussian noise

Page 12: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Problems in visual tracking

• Dynamics is nonlinear, non-Gaussian

• Pose and shape are nonlinear, non-Gaussian functions of the system state

• Most important: what is observed is not image coordinates, but pixel grey-level values: a nonlinear function of object shape and pose, with non-additive, non-Gaussian noise

Page 13: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

More detailed model

Page 14: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Back to Kalman

• A Gaussian pdf, propagated through a linear system, remains Gaussian

• If Gaussian noise is added to a variable with Gaussian pdf, the resulting pdf is still Gaussian (sum of covariances)

---> The predicted state pdf is Gaussian if the previous state pdf was Gaussian

---> The observation pdf is Gaussian if the state pdf is Gaussian

Page 15: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman dynamics

Page 16: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman observation

Page 17: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman posterior pdf

• The product of 2 Gaussian densities is still Gaussian (sum of inverse covariances)

---> the posterior pdf of the state is Gaussian if prior pdf and likelihood are Gaussian

Page 18: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman filter

• Operates in two steps: prediction and update

• Prediction: propagate mean and covariance of the state through the dynamical model

• Update: combine prediction and innovation (defined below) to obtain the state estimate with maximum posterior pdf

Page 19: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Note on the symbols

• From now on, the symbol x represents no longer the ”real” state (which we cannot know) but the mean of the posterior Gaussian pdf

• The symbol A represents the covariance of the posterior Gaussian pdf

• x and A represent mean and covariance of the prior Gaussian pdf

Page 20: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman prediction

• Prior mean: previous mean vector times dynamical matrix:

x(t) = D x(t-1)

• Prior covariance matrix: previous covariance matrix pre- AND post-multiplied by dynamical matrix PLUS noise covariance:

A(t) = DT A(t-1) D + N

Page 21: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman update

In the update step, we must reason backwards, from effect (observation) to cause (state): we must ”invert” the generative process.

Hence the update is more complicated than the prediction.

Page 22: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman update (continued)

Basic scheme:

• Predict the observation from the current state estimate

• Take the difference between predicted and actual observation (innovation)

• Project the innovation back to update the state

Page 23: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman innovation

Observation matrix F

The innovation v is given by:

v = y - F x

Observation-noise covariance R

The innovation has covariance W:

W = F T A F + R

Page 24: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman update: state mean vector

• Posterior mean vector: add weighted innovation to predicted mean vector

• weigh the innovation by the relative covariances of state and innovation:

larger covariance of the innovation

--> larger uncertainty of the innovation

--> smaller weight of the innovation

Page 25: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman gain

• Predicted state covariance A

• Innovation covariance W

• Observation matrix F

• Kalman gain K = A F T W-1

• Posterior state mean:

s = s + K v

Page 26: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman update: state covariance matrix

• Posterior covariance matrix: subtract weighted covariance of the innovation

• weigh the covariance of the innovation by the Kalman gain:

A = A - K T W K• Why subtract? Look carefully at the equation:

larger innovation covariance

--> smaller Kalman gain K

--> smaller amount subtracted!

Page 27: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman update: state covariance matrix (continued)

• Another equivalent formulation requires matrix inversion (sum of inverse covariances)

Advanced note:• The equations given here are for the usual

covariance form of the Kalman filter • It is possible to work with inverse covariance

matrices all the time (in prediction and update): this is called the information form of the Kalman filter

Page 28: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Summary of Kalman equations• Prediction :

x(t) = D x(t-1)

A(t) = DT A(t-1) D + N• Update:innovation: v = y - F x

innov. cov: W = F T A F + R

Kalman gain: K = A F T W-1

posterior mean: s = s + K v

posterior cov: A = A - K T W K

Page 29: An Introduction to Kalman Filtering by Arthur Pece aecp@diku.dk

Kalman equationswith control input u

• Prediction :x(t) = D x(t-1) + C u(t-1)

A(t) = DT A(t-1) D + N• Update:innovation: v = y - F x

innov. cov: W = F T A F + R

Kalman gain: K = A F T W-1

posterior mean: s = s + K v

posterior cov: A = A - K T W K