Filtering and Robot Localization Robert Platt Northeastern - - PowerPoint PPT Presentation

filtering and robot localization
SMART_READER_LITE
LIVE PREVIEW

Filtering and Robot Localization Robert Platt Northeastern - - PowerPoint PPT Presentation

Filtering and Robot Localization Robert Platt Northeastern University Where am I? Image: Berkeley CS188 course notes (downloaded Summer 2015) Robot localization example Robot is actually located here, but it doesn't know it. Prob Gray level


slide-1
SLIDE 1

Filtering and Robot Localization

Robert Platt Northeastern University

Where am I?

Image: Berkeley CS188 course notes (downloaded Summer 2015)

slide-2
SLIDE 2

Robot localization example

1 Prob

Image: Berkeley CS188 course notes (downloaded Summer 2015)

Robot is actually located here, but it doesn't know it. Goal: localize the robot based on sequential observations – robot is given a map of the world; robot could be in any square – initially, robot doesn't know which square it's in Gray level denotes estimated probability that robot is in that square

slide-3
SLIDE 3

Robot localization example

1 Prob

Image: Berkeley CS188 course notes (downloaded Summer 2015)

Gray level denotes estimated probability that robot is in that square On each time step, the robot moves, and then observes the directions in which there are walls. – observes a four-bit binary number – observations are noisy: there is a small chance that each bit will be flipped. Robot perceives that there are walls above and below, but no walls either left or right

slide-4
SLIDE 4

Robot localization example

1 Prob

Image: Berkeley CS188 course notes (downloaded Summer 2015)

slide-5
SLIDE 5

Robot localization example

1 Prob

Image: Berkeley CS188 course notes (downloaded Summer 2015)

slide-6
SLIDE 6

Robot localization example

1 Prob

Image: Berkeley CS188 course notes (downloaded Summer 2015)

slide-7
SLIDE 7

Robot localization example

1 Prob

Image: Berkeley CS188 course notes (downloaded Summer 2015)

Question: how do we update this probability distribution from time t to t+1?

slide-8
SLIDE 8

Hidden Markov Models (HMMs)

State, , is assumed to be unobserved However, you get to make one observation, , on each timestep. Called an “emission”

slide-9
SLIDE 9

Hidden Markov Models (HMMs)

Process dynamics: Observation dynamics: How the system changes from

  • ne time step to the next

What gets observed as a function of what state the system is in

slide-10
SLIDE 10

Hidden Markov Models (HMMs)

Process dynamics: Observation dynamics: How the system changes from

  • ne time step to the next

What gets observed as a function of what state the system is in Let's assume (for now) that these probability distributions are given to us.

slide-11
SLIDE 11

Hidden Markov Models (HMMs)

Process dynamics: Observation dynamics:

slide-12
SLIDE 12

Hidden Markov Models (HMMs)

Process dynamics: Observation dynamics: Markov assumptions

slide-13
SLIDE 13

HMM example

Rt Rt+1 P(Rt+1|Rt) +r +r 0.7 +r

  • r

0.3

  • r

+r 0.3

  • r
  • r

0.7 Rt Ut P(Ut|Rt) +r +u 0.9 +r

  • u

0.1

  • r

+u 0.2

  • r
  • u

0.8

Images: Berkeley CS188 course notes (downloaded Summer 2015)

slide-14
SLIDE 14

Bayes Filtering

How do we go from this distribution to this distribution?

slide-15
SLIDE 15

Bayes Filtering

slide-16
SLIDE 16

Bayes Filtering

Process update Observation update

slide-17
SLIDE 17

Process update

slide-18
SLIDE 18

Process update

Different states from which x_{t+1} can be reached Marginalize over next states

slide-19
SLIDE 19

Process update

Marginalize over next states Different states from which x_{t+1} can be reached

slide-20
SLIDE 20

Process update

Image: Thrun, Probabilistic Robotics, 2006

Before process update

slide-21
SLIDE 21

Process update

Image: Thrun, Probabilistic Robotics, 2006

This is a little like convolution... After process update

slide-22
SLIDE 22

Process update

Image: Thrun, Probabilistic Robotics, 2006

Each time you execute a process update, belief gets more disbursed – i.e. Shannon entropy increases – this makes sense: as you predict state further into the future, your uncertainty grows. After process update

slide-23
SLIDE 23

Bayes Filtering

Process update Observation update

slide-24
SLIDE 24

Observation update

slide-25
SLIDE 25

Observation update

Probability of seeing observation from state

slide-26
SLIDE 26

Observation update

Where is a normalization factor

slide-27
SLIDE 27

Observation update

After observation update Before observation update

slide-28
SLIDE 28

Weather HMM example

Rt

Rt+1 P(Rt+1|Rt)

+r +r 0.7 +r

  • r

0.3

  • r

+r 0.3

  • r
  • r

0.7 Rt Ut P(Ut|Rt) +r +u 0.9 +r

  • u

0.1

  • r

+u 0.2

  • r
  • u

0.8 Umbrella1 Umbrella2 Rain0 Rain1 Rain2 B(+r) = 0.5 B(-r) = 0.5

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-29
SLIDE 29

Weather HMM example

Rt Rt+1 P(Rt+1|Rt)

+r +r 0.7 +r

  • r

0.3

  • r

+r 0.3

  • r
  • r

0.7 Rt Ut P(Ut|Rt) +r +u 0.9 +r

  • u

0.1

  • r

+u 0.2

  • r
  • u

0.8 Umbrella1 Umbrella2 Rain0 Rain1 Rain2 B(+r) = 0.5 B(-r) = 0.5 B’(+r) = 0.5 B’(-r) = 0.5

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-30
SLIDE 30

Weather HMM example

Rt Rt+1 P(Rt+1|Rt)

+r +r 0.7 +r

  • r

0.3

  • r

+r 0.3

  • r
  • r

0.7 Rt Ut P(Ut|Rt) +r +u 0.9 +r

  • u

0.1

  • r

+u 0.2

  • r
  • u

0.8 Umbrella1 Umbrella2 Rain0 Rain1 Rain2 B(+r) = 0.5 B(-r) = 0.5 B’(+r) = 0.5 B’(-r) = 0.5 B(+r) = 0.818 B(-r) = 0.182

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-31
SLIDE 31

Weather HMM example

Rt Rt+1 P(Rt+1|Rt)

+r +r 0.7 +r

  • r

0.3

  • r

+r 0.3

  • r
  • r

0.7 Rt Ut P(Ut|Rt) +r +u 0.9 +r

  • u

0.1

  • r

+u 0.2

  • r
  • u

0.8 Umbrella1 Umbrella2 Rain0 Rain1 Rain2 B(+r) = 0.5 B(-r) = 0.5 B’(+r) = 0.5 B’(-r) = 0.5 B(+r) = 0.818 B(-r) = 0.182 B’(+r) = 0.627 B’(-r) = 0.373

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-32
SLIDE 32

Weather HMM example

Rt Rt+1 P(Rt+1|Rt)

+r +r 0.7 +r

  • r

0.3

  • r

+r 0.3

  • r
  • r

0.7 Rt Ut P(Ut|Rt) +r +u 0.9 +r

  • u

0.1

  • r

+u 0.2

  • r
  • u

0.8 Umbrella1 Umbrella2 Rain0 Rain1 Rain2 B(+r) = 0.5 B(-r) = 0.5 B’(+r) = 0.5 B’(-r) = 0.5 B(+r) = 0.818 B(-r) = 0.182 B’(+r) = 0.627 B’(-r) = 0.373 B(+r) = 0.883 B(-r) = 0.117

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-33
SLIDE 33

Robot localization example

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-34
SLIDE 34

Robot localization example

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-35
SLIDE 35

Robot localization example

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-36
SLIDE 36

Robot localization example

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-37
SLIDE 37

Robot localization example

1 Prob

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-38
SLIDE 38

Robot localization example

1 Prob

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-39
SLIDE 39

Robot localization example

1 Prob

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-40
SLIDE 40

Robot localization example

1 Prob

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-41
SLIDE 41

Robot localization example

1 Prob

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-42
SLIDE 42

Robot localization example

1 Prob

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-43
SLIDE 43

Applications of HMMs

  • Speech recogniton HMMs:
  • Observatons are acoustc signals (contnuous valued)
  • States are specifc positons in specifc words (so, tens of thousands)
  • Machine translaton HMMs:
  • Observatons are words (tens of thousands)
  • States are translaton optons
  • Robot tracking:
  • Observatons are range readings (contnuous)
  • States are positons on a map (contnuous)

Slide: Berkeley CS188 course notes (downloaded Summer 2015)

slide-44
SLIDE 44

Particle Filter

Image: Berkeley CS188 course notes (downloaded Summer 2015)

Why must I be confined to this grid? Standard Bayes filtering requires discretizing state space into grid cells Can do Bayes filtering w/o discretizing? – yes: particle filtering or Kalman filtering

slide-45
SLIDE 45

Particle Filter

Image: Thrun CS223b Course Notes (downloaded Summer 2015)

Sequential Bayes Filtering is great, but it's not great for continuous state spaces. – you need to discretize the state space (e.g. a grid) in order to use Bayes filtering – but, doing filtering on a grid is not efficient... Therefore: – particle filters – Kalman filters Two different ways of filtering in continuous state spaces

slide-46
SLIDE 46

Particle Filter

Image: Thrun CS223b Course Notes (downloaded Summer 2015)

Key idea: represent a probability distribution as a finite set of points – density of points encodes probability mass. – particle filtering is an adaptation of Bayes filtering to this particle representation

slide-47
SLIDE 47

Monte Carlo Sampling

Image: Thrun CS223b Course Notes (downloaded Summer 2015)

Suppose you are given an unknown probability distribution, Suppose you can't evaluate the distribution analytically, but you can draw samples from it What can you do with this information? where are samples drawn from

slide-48
SLIDE 48

Importance Sampling

Image: Thrun CS223b Course Notes (downloaded Summer 2015)

Suppose you are given an unknown probability distribution, Suppose you can't evaluate the distribution analytically, but you can draw samples from it What can you do with this information? Suppose you can't even sample from it? Suppose that all you can do is evaluate the function at a given point?

slide-49
SLIDE 49

Importance Sampling

Image: Thrun CS223b Course Notes (downloaded Summer 2015)

Question: how estimate expected values if cannot draw samples from f(x) – suppose all we can do is evaluate f(x) at a given point...

slide-50
SLIDE 50

Importance Sampling

Image: Thrun CS223b Course Notes (downloaded Summer 2015)

Answer: draw samples from a different distribution and weight them Question: how estimate expected values if cannot draw samples from f(x) – suppose all we can do is evaluate f(x) at a given point...

slide-51
SLIDE 51

Importance Sampling

Image: Thrun CS223b Course Notes (downloaded Summer 2015)

where are samples drawn from and Proposal distribution Answer: draw samples from a different distribution and weight them Question: how estimate expected values if cannot draw samples from f(x) – suppose all we can do is evaluate f(x) at a given point...

slide-52
SLIDE 52

Particle Filter

Prior distribution

slide-53
SLIDE 53

Particle Filter

Prior distribution Process update

slide-54
SLIDE 54

Particle Filter

Prior distribution Process update Observation update

slide-55
SLIDE 55

Particle Filter

Prior distribution Process update Observation update Resample w/ prob Do this n times

slide-56
SLIDE 56

Particle Filter

Prior distribution

slide-57
SLIDE 57

Particle Filter

Measurement update Prior distribution

slide-58
SLIDE 58

Particle Filter

Process update Resampling

slide-59
SLIDE 59

Particle Filter

Measurement update

slide-60
SLIDE 60

Particle Filter

Process update Measurement update

slide-61
SLIDE 61

Particle Filter Example

slide-62
SLIDE 62

Particle Filter Example

slide-63
SLIDE 63

Particle Filtering

Pros: – works in continuous spaces – can represent multi-modal distributions Cons: – parameters to tune – sample impoverishment

slide-64
SLIDE 64

Sample Impoverishment

Pros: – works in continuous spaces – can represent multi-modal distributions Cons: – parameters to tune – sample impoverishment No particles nearby the true system state

slide-65
SLIDE 65

Sample Impoverishment

Prior distribution Process update Observation update Resample w/ prob Do this n times If there aren't enough samples, then we might ``resample away'' the true state...

slide-66
SLIDE 66

Sample Impoverishment

Prior distribution Process update Observation update Resample w/ prob Do this n times If there aren't enough samples, then we might ``resample away'' the true state... One solution: add an additional k samples drawn completely at random

slide-67
SLIDE 67

Sample Impoverishment

Prior distribution Process update Observation update Resample w/ prob Do this n times If there aren't enough samples, then we might ``resample away'' the true state... One solution: add an additional k samples drawn completely at random BUT: there's always a chance that the true state won't be represented well by the particles...

slide-68
SLIDE 68

Kalman Filtering

Image: UBC, Kevin Murphy Matlab toolbox

Another way to adapt Sequential Bayes Filtering to continuous state spaces – relies on representing the probability distribution as a Gaussian – first developed in the early 1960s (before general Bayes filtering); used in Apollo program

slide-69
SLIDE 69

Kalman Idea

update initial position x y x y prediction x y measurement x y

Image: Thrun et al., CS233B course notes

slide-70
SLIDE 70

Kalman Idea

Image: Thrun et al., CS233B course notes

prior Measurement evidence posterior

Image: Thrun et al., CS233B course notes

slide-71
SLIDE 71

Gaussians

  • Univariate

Gaussian:

  • Multivariate

Gaussian:

slide-72
SLIDE 72

Playing w/ Gaussians

  • Suppose:
  • Calculate:

x y x y

slide-73
SLIDE 73

In fact

  • Suppose:
  • Then:
slide-74
SLIDE 74

Illustration

Image: Thrun et al., CS233B course notes

slide-75
SLIDE 75

And

Suppose: Then: Marginal distribution

slide-76
SLIDE 76

Does this remind us of anything?

slide-77
SLIDE 77

Does this remind us of anything?

Process update (discrete): Process update (continuous):

slide-78
SLIDE 78

Does this remind us of anything?

Process update (discrete): Process update (continuous): prior transition dynamics

slide-79
SLIDE 79

Does this remind us of anything?

Process update (discrete): Process update (continuous): prior transition dynamics

slide-80
SLIDE 80

Observation update

Observation update: Where:

slide-81
SLIDE 81

Observation update

Observation update: Where:

slide-82
SLIDE 82

Observation update

Observation update: Where:

slide-83
SLIDE 83

Observation update

But we need:

slide-84
SLIDE 84

Another Gaussian identity...

Suppose: Calculate:

slide-85
SLIDE 85

Observation update

But we need:

slide-86
SLIDE 86

To summarize the Kalman filter

Prior: Process update: Measurement update: System:

slide-87
SLIDE 87

Suppose there is an action term...

Prior: Process update: Measurement update: System:

slide-88
SLIDE 88

To summarize the Kalman filter

Prior: Process update: Measurement update: This factor is often called the “Kalman gain”

slide-89
SLIDE 89

Things to note about the Kalman filter

Process update: Measurement update: – covariance update is independent of observation – Kalman is only optimal for linear-Gaussian systems – the distribution “stays” Gaussian through this update – the error term can be thought of as the different between the

  • bservation and the prediction
slide-90
SLIDE 90

Kalman in 1D

Image: Thrun et al., CS233B course notes

prior Measurement evidence posterior

Image: Thrun et al., CS233B course notes

Process update: Measurement update: System:

slide-91
SLIDE 91

Kalman Idea

Image: Thrun et al., CS233B course notes

initial position prediction measurement

˙ x

x

˙ x

x

˙ x

x

update

˙ x

x

slide-92
SLIDE 92

Example: estimate velocity

Image: Thrun et al., CS233B course notes

past measurements prediction

slide-93
SLIDE 93

Example: filling a tank

Level of tank Fill rate Process: Observati

  • n:
slide-94
SLIDE 94

Example: estimate velocity

slide-95
SLIDE 95

But, my system is NON-LINEAR!

What should I do?

slide-96
SLIDE 96

But, my system is NON-LINEAR!

  • What should I do?

Well, there are some options...

slide-97
SLIDE 97

But, my system is NON-LINEAR!

  • What should I do?

Well, there are some options...

  • But none of them are great.
slide-98
SLIDE 98

But, my system is NON-LINEAR!

  • What should I do?

Well, there are some options... But none of them are great. Here's one: the Extended Kalman Filter

slide-99
SLIDE 99

Extended Kalman filter

Take a Taylor expansion: Where: Where:

slide-100
SLIDE 100

Extended Kalman filter

Take a Taylor expansion: Where: Where: Then use the same equations...

slide-101
SLIDE 101

To summarize the EKF

Prior: Process update: Measurement update:

slide-102
SLIDE 102

Extended Kalman filter

Image: Thrun et al., CS233B course notes

slide-103
SLIDE 103

Extended Kalman filter

Image: Thrun et al., CS233B course notes

slide-104
SLIDE 104

EKF Mobile Robot Localization

Suppose we have a mobile robot wandering around in a 2-d world ... Process noise is assumed to be Gaussian: noise Odometry measurement state Process dynamics:

slide-105
SLIDE 105

Process dynamics: noise Odometry measurement

EKF Mobile Robot Localization

slide-106
SLIDE 106

But, wheels slip – odometry is not always correct... How do we localize? Extended Kalman Filter! Actual path of robot Estimated path based

  • n odometry

EKF Mobile Robot Localization

slide-107
SLIDE 107

EKF uncertainty estimate Dynamics: Linearized dynamics: Where:

EKF Process Update

slide-108
SLIDE 108

With no observations, uncertainty grows

  • ver time...

EKF uncertainty estimate Dynamics: Linearized dynamics: Where:

EKF Process Update

Process update:

slide-109
SLIDE 109

Landmarks (i.e. features of the env't) Observations: range bearing Observations: – range and bearing of a landmark

Observations

slide-110
SLIDE 110

Observations: where:

Observations

Landmarks (i.e. features of the env't)

slide-111
SLIDE 111

EKF Mobile Robot Localization

Process Update: Observation Update:

slide-112
SLIDE 112

Mapping using the EKF

How do we use the EKF to estimate landmark positions? State: Positions of each of the M landmarks (base frame)

slide-113
SLIDE 113

Mapping using the EKF

Process update (no new detections): est position of new landmark covariance of new landmark Process update (new detections): where:

slide-114
SLIDE 114

Mapping using the EKF

Observation update:

slide-115
SLIDE 115

SLAM using the EKF

Estimate both robot position and landmark positions: Landmark positions robot position Landmark covariance Vehicle covariance Vehicle/landmark covariance

slide-116
SLIDE 116

SLAM using the EKF

Process update: Vehicle portion of update Map portion of update No new landmarks New landmarks Same observation update, but using:

slide-117
SLIDE 117

SLAM using the EKF

Image: Thrun

Landmark covariance drops significantly as soon as “loop closure”

  • ccurs.
slide-118
SLIDE 118

SLAM using the EKF

slide-119
SLIDE 119

Mapping using the EKF

slide-120
SLIDE 120

Process update

T = 1 T = 2 T = 5

Images: Berkeley CS188 course notes (downloaded Summer 2015)

Each time you execute a process update, belief gets more disbursed – i.e. Shannon entropy increases – this makes sense: as you predict state further into the future, your uncertainty grows. This is a little like convolution...

slide-121
SLIDE 121

Observation update

Before observaton Afuer observaton

Images: Berkeley CS188 course notes (downloaded Summer 2015)

Process update increases uncertainty Observation update decreases uncertainty – observations give you more information