44
Probabilistic Robotics Bayes Filter Implementations

Probabilistic Robotics Bayes Filter Implementations

Embed Size (px)

Citation preview

Page 1: Probabilistic Robotics Bayes Filter Implementations

Probabilistic Robotics

Bayes Filter Implementations

Page 2: Probabilistic Robotics Bayes Filter Implementations

•Prediction

•Correction

Bayes Filter Reminder

111 )(),|()( tttttt dxxbelxuxpxbel

)()|()( tttt xbelxzpxbel

Page 3: Probabilistic Robotics Bayes Filter Implementations

Gaussians

2

2)(

2

1

2

2

2

1)(

:),(~)(

x

exp

Nxp

-

Univariate

)()(2

1

2/12/

1

)2(

1)(

:)(~)(

μxΣμx

Σx

Σμx

t

ep

,Νp

d

Multivariate

Page 4: Probabilistic Robotics Bayes Filter Implementations

),(~),(~ 22

2

abaNYbaXY

NX

Properties of Gaussians

22

21

222

21

21

122

21

22

212222

2111 1

,~)()(),(~

),(~

NXpXpNX

NX

Page 5: Probabilistic Robotics Bayes Filter Implementations

• We stay in the “Gaussian world” as long as we start with Gaussians and perform only linear transformations.

),(~),(~ TAABANY

BAXY

NX

Multivariate Gaussians

12

11

221

11

21

221

222

111 1,~)()(

),(~

),(~

NXpXpNX

NX

Page 6: Probabilistic Robotics Bayes Filter Implementations

6

Discrete Kalman Filter

tttttt uBxAx 1

tttt xCz

Estimates the state x of a discrete-time controlled process that is governed by the linear stochastic difference equation

with a measurement

Page 7: Probabilistic Robotics Bayes Filter Implementations

7

Components of a Kalman Filter

t

Matrix (nxn) that describes how the state evolves from t to t-1 without controls or noise.

tA

Matrix (nxm) that describes how the control ut changes the state from t to t-1.tB

Matrix (kxn) that describes how to map the state xt to an observation zt.tC

t

Random variables representing the process and measurement noise that are assumed to be independent and normally distributed with covariance Rt and Qt respectively.

Page 8: Probabilistic Robotics Bayes Filter Implementations

8

•Prediction

•Correction

Bayes Filter Reminder

111 )(),|()( tttttt dxxbelxuxpxbel

)()|()( tttt xbelxzpxbel

Page 9: Probabilistic Robotics Bayes Filter Implementations

9

Kalman Filter Algorithm

1. Algorithm Kalman_filter( t-1, t-1, ut, zt):

2. Prediction:3. 4.

5. Correction:6. 7. 8.

9. Return t, t

ttttt uBA 1

tTtttt RAA 1

1)( tTttt

Tttt QCCCK

)( tttttt CzK

tttt CKI )(

Page 10: Probabilistic Robotics Bayes Filter Implementations

10

• Dynamics are linear function of state and control plus additive noise:

tttttt uBxAx 1

Linear Gaussian Systems: Dynamics

ttttttttt RuBxAxNxuxp ,;),|( 11

1111

111

,;~,;~

)(),|()(

ttttttttt

tttttt

xNRuBxAxN

dxxbelxuxpxbel

Page 11: Probabilistic Robotics Bayes Filter Implementations

11

• Observations are linear function of state plus additive noise:

tttt xCz

Linear Gaussian Systems: Observations

tttttt QxCzNxzp ,;)|(

ttttttt

tttt

xNQxCzN

xbelxzpxbel

,;~,;~

)()|()(

Page 12: Probabilistic Robotics Bayes Filter Implementations

12

0000 ,;)( xNxbel

Linear Gaussian Systems: Initialization

• Initial belief is normally distributed:

Page 13: Probabilistic Robotics Bayes Filter Implementations

13

Kalman Filter Updates in 1D

Page 14: Probabilistic Robotics Bayes Filter Implementations

14

Kalman Filter Updates

Page 15: Probabilistic Robotics Bayes Filter Implementations

15

Kalman Filter Updates in 1D

tTtttt

tttttt RAA

uBAxbel

1

1)(

2

,2221)(

tactttt

tttttt a

ubaxbel

Page 16: Probabilistic Robotics Bayes Filter Implementations

16

Kalman Filter Updates in 1D

1)(with )(

)()(

tTttt

Tttt

tttt

ttttttt QCCCK

CKI

CzKxbel

2,

2

2

22 with )1(

)()(

tobst

tt

ttt

tttttt K

K

zKxbel

Page 17: Probabilistic Robotics Bayes Filter Implementations

17

Linear Gaussian Systems: Dynamics

tTtttt

tttttt

ttttT

tt

ttttttT

tttttt

ttttttttt

tttttt

RAA

uBAxbel

dxxx

uBxAxRuBxAxxbel

xNRuBxAxN

dxxbelxuxpxbel

1

1

1111111

11

1

1111

111

)(

)()(2

1exp

)()(2

1exp)(

,;~,;~

)(),|()(

Page 18: Probabilistic Robotics Bayes Filter Implementations

18

Linear Gaussian Systems: Observations

1

11

)(with )(

)()(

)()(2

1exp)()(

2

1exp)(

,;~,;~

)()|()(

tTttt

Tttt

tttt

ttttttt

tttT

ttttttT

tttt

ttttttt

tttt

QCCCKCKI

CzKxbel

xxxCzQxCzxbel

xNQxCzN

xbelxzpxbel

Page 19: Probabilistic Robotics Bayes Filter Implementations

19

The Prediction-Correction-Cycle

tTtttt

tttttt RAA

uBAxbel

1

1)(

2

,2221)(

tactttt

tttttt a

ubaxbel

Prediction

Page 20: Probabilistic Robotics Bayes Filter Implementations

20

The Prediction-Correction-Cycle

1)(,)(

)()(

tTttt

Tttt

tttt

ttttttt QCCCK

CKI

CzKxbel

2,

2

2

22 ,)1(

)()(

tobst

tt

ttt

tttttt K

K

zKxbel

Correction

Page 21: Probabilistic Robotics Bayes Filter Implementations

21

The Prediction-Correction-Cycle

1)(,)(

)()(

tTttt

Tttt

tttt

ttttttt QCCCK

CKI

CzKxbel

2,

2

2

22 ,)1(

)()(

tobst

tt

ttt

tttttt K

K

zKxbel

tTtttt

tttttt RAA

uBAxbel

1

1)(

2

,2221)(

tactttt

tttttt a

ubaxbel

Correction

Prediction

Page 22: Probabilistic Robotics Bayes Filter Implementations

22

Kalman Filter Summary

•Highly efficient: Polynomial in measurement dimensionality k and state dimensionality n: O(k2.376 + n2)

•Optimal for linear Gaussian systems!

•Most robotics systems are nonlinear!

Page 23: Probabilistic Robotics Bayes Filter Implementations

23

Nonlinear Dynamic Systems

•Most realistic robotic problems involve nonlinear functions

),( 1 ttt xugx

)( tt xhz

Page 24: Probabilistic Robotics Bayes Filter Implementations

24

Linearity Assumption Revisited

Page 25: Probabilistic Robotics Bayes Filter Implementations

25

Non-linear Function

Page 26: Probabilistic Robotics Bayes Filter Implementations

26

EKF Linearization (1)

Page 27: Probabilistic Robotics Bayes Filter Implementations

27

EKF Linearization (2)

Page 28: Probabilistic Robotics Bayes Filter Implementations

28

EKF Linearization (3)

Page 29: Probabilistic Robotics Bayes Filter Implementations

29

•Prediction:

•Correction:

EKF Linearization: First Order Taylor Series Expansion

)(),(),(

)(),(

),(),(

1111

111

111

ttttttt

ttt

tttttt

xGugxug

xx

ugugxug

)()()(

)()(

)()(

ttttt

ttt

ttt

xHhxh

xx

hhxh

Page 30: Probabilistic Robotics Bayes Filter Implementations

30

EKF Algorithm

1. Extended_Kalman_filter( t-1, t-1, ut, zt):

2. Prediction:3. 4.

5. Correction:6. 7. 8.

9. Return t, t

),( 1 ttt ug

tTtttt RGG 1

1)( tTttt

Tttt QHHHK

))(( ttttt hzK

tttt HKI )(

1

1),(

t

ttt x

ugG

t

tt x

hH

)(

ttttt uBA 1

tTtttt RAA 1

1)( tTttt

Tttt QCCCK

)( tttttt CzK

tttt CKI )(

Page 31: Probabilistic Robotics Bayes Filter Implementations

31

EKF Summary

•Highly efficient: Polynomial in measurement dimensionality k and state dimensionality n: O(k2.376 + n2)

•Not optimal!•Can diverge if nonlinearities are large!•Works surprisingly well even when all

assumptions are violated!

Page 32: Probabilistic Robotics Bayes Filter Implementations

32

Unscented Transform

nin

wwn

nw

nw

ic

imi

i

cm

2,...,1for )(2

1 )(

)1( 2000

Sigma points Weights

)( ii g

n

i

Tiiic

n

i

iim

w

w

2

0

2

0

))(('

'

Pass sigma points through nonlinear function

Recover mean and covariance

Page 33: Probabilistic Robotics Bayes Filter Implementations

33

Linearization via Unscented Transform

EKF UKF

Page 34: Probabilistic Robotics Bayes Filter Implementations

34

UKF Sigma-Point Estimate (2)

EKF UKF

Page 35: Probabilistic Robotics Bayes Filter Implementations

35

UKF Sigma-Point Estimate (3)

EKF UKF

Page 36: Probabilistic Robotics Bayes Filter Implementations

36

UKF Algorithm

Page 37: Probabilistic Robotics Bayes Filter Implementations

37

UKF Summary

•Highly efficient: Same complexity as EKF, with a constant factor slower in typical practical applications

•Better linearization than EKF: Accurate in first two terms of Taylor expansion (EKF only first term)

•Derivative-free: No Jacobians needed

•Still not optimal!

Page 38: Probabilistic Robotics Bayes Filter Implementations

38

Represent belief by random samples

Estimation of non-Gaussian, nonlinear processes

Monte Carlo filter, Survival of the fittest, Condensation, Bootstrap filter, Particle filter

Filtering: [Rubin, 88], [Gordon et al., 93], [Kitagawa 96]

Computer vision: [Isard and Blake 96, 98] Dynamic Bayesian Networks: [Kanazawa et al., 95]d

Particle Filters

Page 39: Probabilistic Robotics Bayes Filter Implementations

39

Particle Filters

Page 40: Probabilistic Robotics Bayes Filter Implementations

40

Particle Filter Algorithm

Page 41: Probabilistic Robotics Bayes Filter Implementations

41

Resampling

• Given: Set S=(w1, w2, …, wM ) of weight samples.

• Wanted : Random sample, where the probability of drawing xi is given by wi.

• Typically done M times with replacement to generate new sample set Xt.

Page 42: Probabilistic Robotics Bayes Filter Implementations

42

Resampling Algorithm

Page 43: Probabilistic Robotics Bayes Filter Implementations

43

w2

w3

w1wn

Wn-1

Resampling

w2

w3

w1wn

Wn-1

• Roulette wheel

• Binary search, n log n

• Stochastic universal sampling

• Systematic resampling

• Linear time complexity

• Easy to implement, low variance

Page 44: Probabilistic Robotics Bayes Filter Implementations

44

Summary

• Particle filters are an implementation of recursive Bayesian filtering

• They represent the posterior by a set of weighted samples.

• In the context of localization, the particles are propagated according to the motion model.

• They 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.