Introduction to Bayesian Estimation McGill COMP 765 Sept 12 th , - - PowerPoint PPT Presentation

introduction to
SMART_READER_LITE
LIVE PREVIEW

Introduction to Bayesian Estimation McGill COMP 765 Sept 12 th , - - PowerPoint PPT Presentation

Introduction to Bayesian Estimation McGill COMP 765 Sept 12 th , 2017 Where am I? our first core problem Last class: W e can model a robots motions and the world as spatial quantities These are not perfect and therefore


slide-1
SLIDE 1

Introduction to Bayesian Estimation

McGill COMP 765 Sept 12th, 2017

slide-2
SLIDE 2

“Where am I?” – our first core problem

  • Last class:
  • We can model a robot’s motions and the world as spatial quantities
  • These are not perfect and therefore it is up to algorithms to compensate
  • Today:
  • Representing motion and sensing probabilistically
  • Formulation of localization as Bayesian inference
  • Describe and analyze a first simple algorithm
slide-3
SLIDE 3
slide-4
SLIDE 4

Example: Landing on mars

slide-5
SLIDE 5

Complementary input sources

  • A GPS tells our global position, with constant

noise (+/- 5m): appears as jitter around path

  • An IMU tell our relative motion, with

unknown yaw drift: diverges over time

  • A good algorithm will fuse these inputs

intelligently and recover a path which best explains both:

  • Smoother than GPS
  • Less drift than IMU
slide-6
SLIDE 6

Example: Self-driving

Source: Dave Ferguson “Solve for X” talk, July 2013 http://www.youtube.com/watch?v=KA_C6OpL_Ao

slide-7
SLIDE 7

Raw Sensor Data

7

Measured distances for expected distance of 300 cm. It is crucial that we measure the noise well to integrate.

Sonar Laser

slide-8
SLIDE 8

8

Probabilistic Robotics

Key idea: Explicit representation of uncertainty using the calculus of probability theory

  • Perception = state estimation
  • Action

= utility optimization

slide-9
SLIDE 9

9

Discrete Random Variables

  • X denotes a random variable.
  • X can take on a countable number of values

in {x1, x2, …, xn}.

  • P(X=xi), or P(xi), is the probability that the

random variable X takes on value xi.

  • P( ) is called probability mass function.
  • E.g.

02 . , 08 . , 2 . , 7 . ) (  Room P

.

slide-10
SLIDE 10

10

Continuous Random Variables

  • X takes on values in the continuum.
  • p(X=x), or p(x), is a probability density

function.

  • E.g.

 

b a

dx x p b a x ) ( )) , ( Pr(

x p(x)

slide-11
SLIDE 11

11

Joint and Conditional Probability

  • P(X=x and Y=y) = P(x,y)
  • If X and Y are independent then

P(x,y) = P(x) P(y)

  • P(x | y) is the probability of x given y

P(x | y) = P(x,y) / P(y) P(x,y) = P(x | y) P(y)

  • If X and Y are independent then

P(x | y) = P(x)

slide-12
SLIDE 12

12

Law of Total Probability, Marginals

y

y x P x P ) , ( ) (

y

y P y x P x P ) ( ) | ( ) (

x

x P 1 ) (

Discrete case

1 ) ( dx x p

Continuous case

 dy y p y x p x p ) ( ) | ( ) (

 dy y x p x p ) , ( ) (

slide-13
SLIDE 13

13

Bayes Formula evidence prior likelihood ) ( ) ( ) | ( ) ( ) ( ) | ( ) ( ) | ( ) , (       y P x P x y P y x P x P x y P y P y x P y x P

slide-14
SLIDE 14

14

Normalization

) ( ) | ( 1 ) ( ) ( ) | ( ) ( ) ( ) | ( ) (

1

x P x y P y P x P x y P y P x P x y P y x P

x

   

 

y x x y x y x

y x P x x P x y P x

| | |

aux ) | ( : aux 1 ) ( ) | ( aux :       

Algorithm:

slide-15
SLIDE 15

15

Conditioning

  • Law of total probability:

  

   dz y z P z y x P y x P dz z P z x P x P dz z x P x P ) | ( ) , | ( ) ( ) ( ) | ( ) ( ) , ( ) (

slide-16
SLIDE 16

16

Bayes Rule with Background Knowledge

) | ( ) | ( ) , | ( ) , | ( z y P z x P z x y P z y x P 

slide-17
SLIDE 17

17

Conditioning

  • Total probability:

  

   dz z P z y x P y x P dz z P z x P x P dz z x P x P ) ( ) , | ( ) ( ) ( ) | ( ) ( ) , ( ) (

slide-18
SLIDE 18

18

Conditional Independence

) | ( ) | ( ) , ( z y P z x P z y x P  ) , | ( ) ( y z x P z x P  ) , | ( ) ( x z y P z y P 

equivalent to and

slide-19
SLIDE 19

19

Simple Example of State Estimation

  • Suppose a robot obtains measurement z
  • What is P(open|z)?
slide-20
SLIDE 20

20

Causal vs. Diagnostic Reasoning

  • P(open|z) is diagnostic.
  • P(z|open) is causal.
  • Often causal knowledge is easier to obtain.
  • Bayes rule allows us to use causal knowledge:

) ( ) ( ) | ( ) | ( z P

  • pen

P

  • pen

z P z

  • pen

P 

count frequencies!

slide-21
SLIDE 21

21

Example

  • P(z|open) = 0.6

P(z|open) = 0.3

  • P(open) = P(open) = 0.5

67 . 3 2 5 . 3 . 5 . 6 . 5 . 6 . ) | ( ) ( ) | ( ) ( ) | ( ) ( ) | ( ) | (       

 z

  • pen

P

  • pen

p

  • pen

z P

  • pen

p

  • pen

z P

  • pen

P

  • pen

z P z

  • pen

P

  • z raises the probability that the door is open.
slide-22
SLIDE 22

22

Combining Evidence

  • Suppose our robot obtains another observation z2.
  • How can we integrate this new information?
  • More generally, how can we estimate

P(x| z1...zn )?

slide-23
SLIDE 23

23

Recursive Bayesian Updating

) , , | ( ) , , | ( ) , , , | ( ) , , | (

1 1 1 1 1 1 1   

n n n n n n

z z z P z z x P z z x z P z z x P    

Assumption: zn is independent of z1,...,zn-1 if we know x.

) ( ) | ( ) , , | ( ) | ( ) , , | ( ) , , | ( ) | ( ) , , | (

... 1 ... 1 1 1 1 1 1 1 1

x P x z P z z x P x z P z z z P z z x P x z P z z x P

n i i n n n n n n n n

   

        

slide-24
SLIDE 24

24

Example: Second Measurement

  • P(z2|open) = 0.5

P(z2|open) = 0.6

  • P(open|z1)=2/3

625 . 8 5 3 1 5 3 3 2 2 1 3 2 2 1 ) | ( ) | ( ) | ( ) | ( ) | ( ) | ( ) , | (

1 2 1 2 1 2 1 2

      

 z

  • pen

P

  • pen

z P z

  • pen

P

  • pen

z P z

  • pen

P

  • pen

z P z z

  • pen

P

  • z2 lowers the probability that the door is open.
slide-25
SLIDE 25

25

A Typical Pitfall

  • Two possible locations x1 and x2
  • P(x1)=0.99
  • P(z|x2)=0.09 P(z|x1)=0.07
  • Integrate same z repeatedly
  • What are we doing wrong?

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 5 10 15 20 25 30 35 40 45 50 p( x | d) Number of integrations p(x2 | d) p(x1 | d)

slide-26
SLIDE 26

26

Actions

  • Often the world is dynamic since
  • actions carried out by the robot,
  • actions carried out by other agents,
  • or just the time passing by

change the world.

  • How can we incorporate such actions?
slide-27
SLIDE 27

27

Typical Actions

  • The robot turns its wheels to move
  • The robot uses its manipulator to grasp an object
  • Plants grow over time…
  • Actions are never carried out with absolute certainty.
  • In contrast to measurements, actions generally

increase the uncertainty.

slide-28
SLIDE 28

28

Modeling Actions

  • To incorporate the outcome of an

action u into the current “belief”, we use the conditional pdf P(x|u,x’)

  • This term specifies the pdf that

executing u changes the state from x’ to x.

slide-29
SLIDE 29

29

Example: Closing the door

slide-30
SLIDE 30

30

State Transitions P(x|u,x’) for u = “close door”: If the door is open, the action “close door” succeeds in 90% of all cases.

  • pen

closed 0.1 1 0.9

slide-31
SLIDE 31

31

Integrating the Outcome of Actions

 ' ) ' ( ) ' , | ( ) | ( dx x P x u x P u x P

 ) ' ( ) ' , | ( ) | ( x P x u x P u x P

Continuous case: Discrete case:

slide-32
SLIDE 32

32

Example: The Resulting Belief

) | ( 1 16 1 8 3 1 8 5 10 1 ) ( ) , | ( ) ( ) , | ( ) ' ( ) ' , | ( ) | ( 16 15 8 3 1 1 8 5 10 9 ) ( ) , | ( ) ( ) , | ( ) ' ( ) ' , | ( ) | ( u closed P closed P closed u

  • pen

P

  • pen

P

  • pen

u

  • pen

P x P x u

  • pen

P u

  • pen

P closed P closed u closed P

  • pen

P

  • pen

u closed P x P x u closed P u closed P                  

 

slide-33
SLIDE 33

33

Bayes Filters: Framework

  • Given:
  • Stream of observations z and action data u:
  • Sensor model P(z|x).
  • Action model P(x|u,x’).
  • Prior probability of the system state P(x).
  • Wanted:
  • Estimate of the state X of a dynamical system.
  • The posterior of the state is also called Belief:

) , , , | ( ) (

1 1 t t t t

z u z u x P x Bel   } , , , {

1 1 t t t

z u z u d  

slide-34
SLIDE 34

34

Markov Assumption

Underlying Assumptions

  • Static world
  • Independent noise
  • Perfect model, no approximation errors

) , | ( ) , , | (

1 : 1 : 1 1 : 1 t t t t t t t

u x x p u z x x p

 

) | ( ) , , | (

: 1 : 1 : t t t t t t

x z p u z x z p 

slide-35
SLIDE 35

1 1 1

) ( ) , | ( ) | (

  

t t t t t t t

dx x Bel x u x P x z P 

Bayes Filters

) , , , | ( ) , , , , | (

1 1 1 1 t t t t t

u z u x P u z u x z P    

Bayes z = observation u = action x = state

) , , , | ( ) (

1 1 t t t t

z u z u x P x Bel  

Markov

) , , , | ( ) | (

1 1 t t t t

u z u x P x z P   

Markov

1 1 1 1 1

) , , , | ( ) , | ( ) | (

  

t t t t t t t t

dx u z u x P x u x P x z P  

1 1 1 1 1 1 1

) , , , | ( ) , , , , | ( ) | (

  

t t t t t t t t

dx u z u x P x u z u x P x z P   

Total prob. Markov

1 1 1 1 1 1

) , , , | ( ) , | ( ) | (

   

t t t t t t t t

dx z z u x P x u x P x z P  

slide-36
SLIDE 36

36

Bayes Filter Algorithm

1.

Algorithm Bayes_filter( Bel(x),d ): 2. 0 3. If d is a perceptual data item z then 4. For all x do 5. 6. 7. For all x do 8. 9. Else if d is an action data item u then 10. For all x do 11. 12. Return Bel’(x)

) ( ) | ( ) ( ' x Bel x z P x Bel  ) ( ' x Bel    ) ( ' ) ( '

1

x Bel x Bel

 ' ) ' ( ) ' , | ( ) ( ' dx x Bel x u x P x Bel

1 1 1

) ( ) , | ( ) | ( ) (

  

t t t t t t t t

dx x Bel x u x P x z P x Bel 

slide-37
SLIDE 37

We have the math, what’s left?

  • Choose a data structure to represent Bel(x)
  • Create update rules that integrate the motions and measurements
  • Feed in data, and out come your results
  • For the rest of this section, we will consider a huge variety of

methods that roughly fall within this framework. First examples:

  • Fixed-resolution discretization of Bel : Markov Localization
  • Variable-resolution discretization of Bel : Particle Filters
  • Restriction of Bel to a simple parametric family : Kalman Filters
slide-38
SLIDE 38

Discrete Bayes Filter Algorithm

1.

Algorithm Discrete_Bayes_filter( Bel(x),d ): 2. 0 3. If d is a perceptual data item z then 4. For all x do 5. 6. 7. For all x do 8. 9. Else if d is an action data item u then 10. For all x do 11. 12. Return Bel’(x)

) ( ) | ( ) ( ' x Bel x z P x Bel  ) ( ' x Bel    ) ( ' ) ( '

1

x Bel x Bel



'

) ' ( ) ' , | ( ) ( '

x

x Bel x u x P x Bel

slide-39
SLIDE 39

Piecewise Constant Bel(x)

slide-40
SLIDE 40

Piecewise Constant – What about Angle?

) , , (    y x x Bel

t

slide-41
SLIDE 41

Implementation (1)

  • To update the belief upon sensory input and to carry out

the normalization one has to iterate over all cells of the grid.

  • Especially when the belief is peaked (which is generally the

case during position tracking), one wants to avoid updating irrelevant aspects of the state space.

  • One approach is not to update entire sub-spaces of the

state space.

  • This, however, requires to monitor whether the robot is de-

localized or not.

  • To achieve this, one can consider the likelihood of the
  • bservations given the active components of the state

space.

slide-42
SLIDE 42

Implementation (2)

  • To efficiently update the belief upon robot motions, one typically

assumes a bounded Gaussian model for the motion uncertainty.

  • This reduces the update cost from O(n2) to O(n), where n is the

number of states.

  • The update can also be realized by shifting the data in the grid

according to the measured motion.

  • In a second step, the grid is then convolved using a separable

Gaussian Kernel.

  • Two-dimensional example:

1/4 1/4 1/2 1/4 1/2 1/4

+ 

1/16 1/16 1/8 1/8 1/8 1/4 1/16 1/16 1/8

  • Fewer arithmetic operations
  • Easier to implement
slide-43
SLIDE 43

43

Grid-based Localization

slide-44
SLIDE 44

44

Sonars and Occupancy Grid Map

slide-45
SLIDE 45

Conclusion:

  • Bayesian estimation gives a framework to integrate evidence

assuming only local knowledge.

  • The math tells us the correct operations to fuse the knowledge,

properly representing the posterior distribution

  • Discrete Bayes Filters are never used: we must think of smarter ways

to represent our distributions and to compute updates (next time!)