66
1 Bayes Filter – Particle Filter and Monte Carlo Localization Introduction to Mobile Robotics Wolfram Burgard

Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

  • Upload
    lamlien

  • View
    240

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

1

Bayes Filter – Particle Filter and Monte Carlo Localization

Introduction to Mobile Robotics

Wolfram Burgard

Page 2: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

2

Recall: Discrete filter Discretize the continuous state space High memory complexity Fixed resolution (does not adapt to the belief)

Particle filters are a way to efficiently represent

non-Gaussian distribution

Basic principle Set of state hypotheses (“particles”) Survival-of-the-fittest

Motivation

Page 3: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Sample-based Localization (sonar)

Page 4: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

4

Set of weighted samples

Mathematical Description

The samples represent the posterior

State hypothesis Importance weight

Page 5: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

5

Particle sets can be used to approximate functions

Function Approximation

The more particles fall into an interval, the higher the probability of that interval

How to draw samples from a function/distribution?

Page 6: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

6

Let us assume that f(x)<1 for all x Sample x from a uniform distribution Sample c from [0,1] if f(x) > c keep the sample

otherwise reject the sample

Rejection Sampling

c

x f(x)

c

x’

f(x’)

OK

Page 7: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

7

We can even use a different distribution g to generate samples from f

By introducing an importance weight w, we can account for the “differences between g and f ”

w = f / g f is called target g is called proposal Pre-condition:

f(x)>0 g(x)>0 Derivation: See

webpage

Importance Sampling Principle

Page 8: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Importance Sampling with Resampling: Landmark Detection Example

Page 9: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Distributions

Page 10: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

10

Distributions

Wanted: samples distributed according to p(x| z1, z2, z3)

Page 11: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

This is Easy! We can draw samples from p(x|zl) by adding noise to the detection parameters.

Page 12: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Importance Sampling

Page 13: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Importance Sampling with Resampling

Weighted samples After resampling

Page 14: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Particle Filters

Page 15: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

)|()(

)()|()()|()(

xzpxBel

xBelxzpw

xBelxzpxBel

ααα

=←

Sensor Information: Importance Sampling

Page 16: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Robot Motion

Page 17: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Sensor Information: Importance Sampling

Page 18: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Robot Motion

Page 19: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

19

Particle Filter Algorithm

Sample the next generation for particles using the proposal distribution

Compute the importance weights : weight = target distribution / proposal distribution

Resampling: “Replace unlikely samples by more likely ones”

Page 20: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

20

1. Algorithm particle_filter( St-1, ut, zt): 2.

3. For Generate new samples

4. Sample index j(i) from the discrete distribution given by wt-1

5. Sample from using and

6. Compute importance weight

7. Update normalization factor

8. Add to new particle set

9. For

10. Normalize weights

11. return

Particle Filter Algorithm

0, =∅= ηtS

Page 21: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

draw xit−1 from Bel(xt−1)

draw xit from p(xt | xi

t−1,ut)

Importance factor for xit:

Particle Filter Algorithm

Page 22: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Resampling

Given: Set S of weighted samples.

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

Typically done n times with replacement to generate new sample set S’.

Page 23: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

w2

w3

w1 wn

Wn-1

Resampling

w2

w3

w1 wn

Wn-1

Roulette wheel Binary search, n log n

Stochastic universal sampling Systematic resampling Linear time complexity Easy to implement, low variance

Page 24: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

1. Algorithm systematic_resampling(S,n):

2. 3. For Generate cdf 4. 5. Initialize threshold

6. For Draw samples … 7. While ( ) Skip until next threshold reached 8. 9. Insert 10. Increment threshold

11. Return S’

Resampling Algorithm

11,' wcS =∅=

ni 2=i

ii wcc += −1

1],,0]~ 11 =− inUu

nj 1=

11

−+ += nuu jj

ij cu >

{ }><∪= −1,'' nxSS i

1+= ii

Also called stochastic universal sampling

Page 25: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

25

Mobile Robot Localization

Each particle is a potential pose of the robot

Proposal distribution is the motion model of the robot (prediction step)

The observation model is used to compute the importance weight (correction step)

[For details, see PDF file on the lecture web page]

Page 26: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Motion Model Reminder

start pose

end pose

According to the estimated motion

Page 27: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Motion Model Reminder

rotation

translation

rotation

Decompose the motion into Traveled distance Start rotation End rotation

Page 28: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Motion Model Reminder

Uncertainty in the translation of the robot: Gaussian over the traveled distance

Uncertainty in the rotation of the robot: Gaussians over start and end rotation

For each particle, draw a new pose by sampling from these three individual normal distributions

Page 29: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Start

Motion Model Reminder

Page 30: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Proximity Sensor Model Reminder

Laser sensor Sonar sensor

Page 31: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

31

Mobile Robot Localization Using Particle Filters (1)

Each particle is a potential pose of the robot

The set of weighted particles approximates the posterior belief about the robot’s pose (target distribution)

Page 32: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

32

Mobile Robot Localization Using Particle Filters (2)

Particles are drawn from the motion model (proposal distribution)

Particles are weighted according to the observation model (sensor model)

Particles are resampled according to the particle weights

Page 33: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

33

Mobile Robot Localization Using Particle Filters (3)

Why is resampling needed?

We only have a finite number of particles

Without resampling: The filter is likely to loose track of the “good” hypotheses

Resampling ensures that particles stay in the meaningful area of the state space

Page 34: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

34

Page 35: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

35

Page 36: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

36

Page 37: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

37

Page 38: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

38

Page 39: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

39

Page 40: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

40

Page 41: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

41

Page 42: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

42

Page 43: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

43

Page 44: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

44

Page 45: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

45

Page 46: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

46

Page 47: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

47

Page 48: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

48

Page 49: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

49

Page 50: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

50

Page 51: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

51

Sample-based Localization (sonar)

Page 52: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

52

Initial Distribution

Page 53: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

53

After Incorporating Ten Ultrasound Scans

Page 54: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

54

After Incorporating 65 Ultrasound Scans

Page 55: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

55

Estimated Path

Page 56: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

56

Localization for AIBO robots

Page 57: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Using Ceiling Maps for Localization

[Dellaert et al. 99]

Page 58: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Vision-based Localization

P(z|x)

h(x)

z

Page 59: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Under a Light

Measurement z: P(z|x):

Page 60: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Next to a Light

Measurement z: P(z|x):

Page 61: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Elsewhere

Measurement z: P(z|x):

Page 62: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

Global Localization Using Vision

Page 63: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

63

Limitations

The approach described so far is able to track the pose of a mobile robot and to globally localize the robot

How can we deal with localization errors

(i.e., the kidnapped robot problem)?

Page 64: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

64

Approaches

Randomly insert a fixed number of samples This assumes that the robot can be

teleported at any point in time Alternatively, insert random samples

proportional to the average likelihood of the particles

Page 65: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

65

Summary – Particle Filters

Particle filters are an implementation of recursive Bayesian filtering

They represent the posterior by a set of weighted samples

They can model non-Gaussian distributions Proposal to draw new samples Weight to account for the differences

between the proposal and the target Monte Carlo filter, Survival of the fittest,

Condensation, Bootstrap filter

Page 66: Introduction to Mobile Robotics Bayes Filter – Particle Filter and ...ais.informatik.uni-freiburg.de/.../ss17/robotics/slides/09-pf-mcl.pdf · 1 Bayes Filter – Particle Filter

66

Summary – PF Localization

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.