lecture 04: particle filters + kalman filters

44
Lecture 04: particle filters + Kalman filters Katie DC Jan. 30, 2020 Notes from Probabilistic Robotics Ch. 3, Lukas Luft, and Wolfram Burgard

Upload: others

Post on 05-Jun-2022

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 04: particle filters + Kalman filters

Lecture 04:particle filters + Kalman filters

Katie DC

Jan. 30, 2020

Notes from Probabilistic Robotics Ch. 3,

Lukas Luft, and Wolfram Burgard

Page 2: Lecture 04: particle filters + Kalman filters

Admin

โ€ข HW1 is due tomorrow (Friday)โ€ข Also first homework party is tomorrow

โ€ข Next Tuesday will be a quick tutorial for HW3 and the associated lab

โ€ข Next Thursday is our first Guest Lecture

Page 3: Lecture 04: particle filters + Kalman filters

Who was Rudolf Kalman?

โ€ข Kรกlmรกn was one of the most influential people on control theory today and is most known for his co-invention of the Kalman filter (or Kalman-Bucy Filter)

โ€ข The filtering approach was initially met with vast skepticism, so much so that he was forced to do the first publication of his results in mechanical engineering, rather than in electrical engineering or systems engineering

โ€ข This worked out find as some of the first use cases was with NASA on the Apollo spacecraft

โ€ข Kalman filters are inside every robot, commercial airplanes, uses in seismic data processing, nuclear power plant instrumentation, and demographic models, as well as applications in econometrics

Image Credit: Wikipedia

Page 4: Lecture 04: particle filters + Kalman filters
Page 5: Lecture 04: particle filters + Kalman filters

Particle Filters

โ€ข Particle filters are an implementation of recursive Bayesian filtering, where the posterior is represented by a set of weighted samples

โ€ข Instead of a precise probability distribution, represent belief ๐‘๐‘’๐‘™ ๐‘ฅ๐‘กby a set of particles, where each particle tracks its own state estimate

โ€ข Random sampling used in generation of particles

โ€ข Particles are periodically re-sampled, with probability weighted by likelihood of last generation of particles

โ€ข Nonparametric filter โ€“ can approximate complex probability distributions without explicitly computing the closed form solutions

Page 6: Lecture 04: particle filters + Kalman filters

Particle Filtering Algorithm // Monte Carlo Localization

โ€ข motion model guides the motion of particles

โ€ข ๐‘ค๐‘ก๐‘š

is the importance factor or weight of each particle ๐‘š, which is a function of the measurement model and belief

โ€ข Particles are resampled according to weight

โ€ข Survival of the fittest: moves/adds particles to part of space with higher probability

Page 7: Lecture 04: particle filters + Kalman filters

Particle Filtering Algorithm // Monte Carlo LocalizationStep 1: Initialize particles uniformly distribute over space and assign initial weight

Step 2: Sample the motion model to propagate particles

Step 3: Read measurement model and assign (unnormalized) weight:

๐‘ค๐‘ก[๐‘š]

= expโˆ’๐‘‘2

2๐œŽ

Step 4: Calculate your position update estimate by adding the particle positions scaled by weight Note that weights must be normalized to sum to 1

Step 5: Choose which particles to resample in the next iteration by replacing less likely particles with more likely ones

Page 8: Lecture 04: particle filters + Kalman filters

tim

e =

0ti

me

= 1

tim

e =

2

Particle Filter Localization - Illustration

Images By Daniel Lu - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=25252955

initialize particles

update motion

update motion

sensor update

sensor update

sensor update

resample particles

resample particles

resample particles

Page 9: Lecture 04: particle filters + Kalman filters
Page 10: Lecture 04: particle filters + Kalman filters
Page 11: Lecture 04: particle filters + Kalman filters
Page 12: Lecture 04: particle filters + Kalman filters
Page 13: Lecture 04: particle filters + Kalman filters
Page 14: Lecture 04: particle filters + Kalman filters
Page 15: Lecture 04: particle filters + Kalman filters
Page 16: Lecture 04: particle filters + Kalman filters
Page 17: Lecture 04: particle filters + Kalman filters
Page 18: Lecture 04: particle filters + Kalman filters
Page 19: Lecture 04: particle filters + Kalman filters
Page 20: Lecture 04: particle filters + Kalman filters
Page 21: Lecture 04: particle filters + Kalman filters
Page 22: Lecture 04: particle filters + Kalman filters
Page 23: Lecture 04: particle filters + Kalman filters
Page 24: Lecture 04: particle filters + Kalman filters
Page 25: Lecture 04: particle filters + Kalman filters
Page 26: Lecture 04: particle filters + Kalman filters
Page 27: Lecture 04: particle filters + Kalman filters

27

Page 28: Lecture 04: particle filters + Kalman filters

Initial Distribution

Page 29: Lecture 04: particle filters + Kalman filters

After Incorporating Ten Ultrasound Scans

Page 30: Lecture 04: particle filters + Kalman filters

After Incorporating 65 Ultrasound Scans

Page 31: Lecture 04: particle filters + Kalman filters

Part 1 Summaryโ€ข Particle filters are an implementation of recursive Bayesian filtering,

where the posterior is represented by a set of weighted samples

โ€ข The particles are propagated according to the motion model and are then weighted according to the likelihood of the observations

โ€ข In a re-sampling step, new particles are drawn with a probability proportional to the likelihood of the observation

โ€ข Limitations:โ€ข Some errors are particularly hard to deal with (e,g., the kidnapped robot problem)

โ€ข The success of your filter is highly reliant on the number of particles โ†’ PF can be very memory intensive

Page 32: Lecture 04: particle filters + Kalman filters

Homework 3 and Lab 3: Particle Filtering Algorithm // Monte Carlo Localization

Instead of a homework 3, youโ€™ll be given a skeleton to implement your own particle filter. This will be checked by your lab TA and used in Lab 3.

Page 33: Lecture 04: particle filters + Kalman filters

Kalman Filters

Page 34: Lecture 04: particle filters + Kalman filters

Bayes Filter Reminder๐‘๐‘’๐‘™ ๐‘ฅ๐‘ก = ๐œ‚๐‘ ๐‘ง๐‘ก ๐‘ฅ๐‘ก โˆซ ๐‘ ๐‘ฅ๐‘ก| ๐‘ข๐‘ก , ๐‘ฅ๐‘กโˆ’1 ๐‘๐‘’๐‘™ ๐‘ฅ๐‘กโˆ’1 ๐‘‘๐‘ฅ๐‘กโˆ’1โ€ข Prediction

๐‘๐‘’๐‘™ ๐‘ฅ๐‘ก = โˆซ ๐‘ ๐‘ฅ๐‘ก| ๐‘ข๐‘ก, ๐‘ฅ๐‘กโˆ’1 ๐‘๐‘’๐‘™ ๐‘ฅ๐‘กโˆ’1 ๐‘‘๐‘ฅ๐‘กโˆ’1โ€ข Correction

๐‘๐‘’๐‘™ ๐‘ฅ๐‘ก = ๐œ‚๐‘ ๐‘ง๐‘ก ๐‘ฅ๐‘ก ๐‘๐‘’๐‘™ ๐‘ฅ๐‘ก

Page 35: Lecture 04: particle filters + Kalman filters

Bayes Filter Reminder๐‘๐‘’๐‘™ ๐‘ฅ๐‘ก = ๐œ‚๐‘ ๐‘ง๐‘ก ๐‘ฅ๐‘ก โˆซ ๐‘ ๐‘ฅ๐‘ก| ๐‘ข๐‘ก , ๐‘ฅ๐‘กโˆ’1 ๐‘๐‘’๐‘™ ๐‘ฅ๐‘กโˆ’1 ๐‘‘๐‘ฅ๐‘กโˆ’1โ€ข Prediction

๐‘๐‘’๐‘™ ๐‘ฅ๐‘ก = โˆซ ๐‘ ๐‘ฅ๐‘ก| ๐‘ข๐‘ก, ๐‘ฅ๐‘กโˆ’1 ๐‘๐‘’๐‘™ ๐‘ฅ๐‘กโˆ’1 ๐‘‘๐‘ฅ๐‘กโˆ’1โ€ข Correction

๐‘๐‘’๐‘™ ๐‘ฅ๐‘ก = ๐œ‚๐‘ ๐‘ง๐‘ก ๐‘ฅ๐‘ก ๐‘๐‘’๐‘™ ๐‘ฅ๐‘ก

What if we have a good model of our (continuous) system dynamics and we assume a Gaussian model for our uncertainty?

โ†’ Kalman Filters!

Page 36: Lecture 04: particle filters + Kalman filters

Review of Gaussians

Page 37: Lecture 04: particle filters + Kalman filters

Linear Systems with Gaussian Noise

Suppose we have a system that is governed by a linear difference equation:

๐‘ฅ๐‘ก = ๐ด๐‘ก๐‘ฅ๐‘กโˆ’1 + ๐ต๐‘ก๐‘ข๐‘ก + ๐œ–๐‘ก

with measurement

๐‘ง๐‘ก = ๐ถ๐‘ก๐‘ฅ๐‘ก + ๐›ฟ๐‘ก

๐ด๐‘ก a ๐‘› ร— ๐‘› matrix that describes how the state evolves from ๐‘ก โˆ’ 1 to ๐‘ก without controls or noise

๐ต๐‘ก a ๐‘› ร— ๐‘š matrix that describes how the control ๐‘ข๐‘ก changes the state from ๐‘ก โˆ’1 to ๐‘ก

๐ถ๐‘ก a ๐‘˜ ร— ๐‘› matrix that describes how to map the state ๐‘ฅ๐‘ก to an observation ๐‘ง๐‘ก

๐œ–๐‘ก & ๐›ฟ๐‘ก random variables representing the process and measurement noise, and are assumed to be independent and normally distributed with zero mean and covariance ๐‘„๐‘ก and ๐‘…๐‘ก, respectively

Page 38: Lecture 04: particle filters + Kalman filters

What is a Kalman Filter?Suppose we have a system that is governed by a linear difference equation:

๐‘ฅ๐‘ก = ๐ด๐‘ก๐‘ฅ๐‘กโˆ’1 + ๐ต๐‘ก๐‘ข๐‘ก + ๐œ–๐‘กwith measurement

๐‘ง๐‘ก = ๐ถ๐‘ก๐‘ฅ๐‘ก + ๐›ฟ๐‘กโ€ข Tracks the estimated state of the system by the mean and variance of

its state variables -- minimum mean-square error estimator

โ€ข Computes the Kalman gain, which is used to weight the impact of new measurements on the system state estimate against the predicted value from the process model

โ€ข Note that we no longer have discrete states or measurements!

Page 39: Lecture 04: particle filters + Kalman filters

Kalman Filter Exampleti

me

= 1

tim

e =

2

Page 40: Lecture 04: particle filters + Kalman filters

Linear Gaussian Systems: Dynamics

Page 41: Lecture 04: particle filters + Kalman filters

Linear Gaussian Systems: Observations

Page 42: Lecture 04: particle filters + Kalman filters

Kalman Filter Algorithm

1. Algorithm Kalman_Filter(๐œ‡๐‘กโˆ’1, ฮฃ๐‘กโˆ’1, ๐‘ข๐‘ก , ๐‘ง๐‘ก):

2. Prediction1. เดฅ๐œ‡๐‘ก = ๐ด๐‘ก๐œ‡๐‘กโˆ’1 + ๐ต๐‘ก๐‘ข๐‘ก2. เดคฮฃ๐‘ก = ๐ด๐‘กฮฃ๐‘กโˆ’1๐ด๐‘ก

โŠค + ๐‘„๐‘ก

3. Correction:1. ๐พ๐‘ก = เดฅฮฃ๐‘กC๐‘ก

โŠค ๐ถ๐‘ก เดคฮฃ๐‘ก๐ถ๐‘กโŠค + ๐‘…๐‘ก

โˆ’1

2. ๐œ‡๐‘ก = าง๐œ‡๐‘ก + ๐พ๐‘ก(๐‘ง๐‘ก โˆ’ ๐ถ๐‘ก าง๐œ‡๐‘ก)

3. ฮฃ๐‘ก = ๐ผ โˆ’ ๐พ๐‘ก๐ถ๐‘ก เดคฮฃ๐‘ก

4. Return ๐œ‡๐‘ก,ฮฃ๐‘ก

Page 43: Lecture 04: particle filters + Kalman filters

Prediction1. เดฅ๐œ‡๐‘ก = ๐ด๐‘ก๐œ‡๐‘กโˆ’1 + ๐ต๐‘ก๐‘ข๐‘ก2. เดคฮฃ๐‘ก = ๐ด๐‘กฮฃ๐‘กโˆ’1๐ด๐‘ก

โŠค + ๐‘„๐‘ก

Correction:1. ๐พ๐‘ก = เดฅฮฃ๐‘กC๐‘ก

โŠค ๐ถ๐‘ก เดคฮฃ๐‘ก๐ถ๐‘กโŠค + ๐‘…๐‘ก

โˆ’1

2. ๐œ‡๐‘ก = าง๐œ‡๐‘ก + ๐พ๐‘ก(๐‘ง๐‘ก โˆ’ ๐ถ๐‘ก าง๐œ‡๐‘ก)3. ฮฃ๐‘ก = ๐ผ โˆ’ ๐พ๐‘ก๐ถ๐‘ก เดคฮฃ๐‘ก

Apply control action

Get sensor measurement

Page 44: Lecture 04: particle filters + Kalman filters

Part 2 Summary

โ€ข Kalman filters give you the optimal estimate for linear Gaussian systemsโ€ข However, most systems arenโ€™t linear

โ€ข Nonetheless, this filter (and its extensions) is highly efficient and widely used in practice

โ€ข For a nice 2D example, check out:โ€ข How a Kalman filter works, in pictures by Tim Babb