Top Banner
Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours and simpleBlobDetection functions in OpenCV. Give a 1-2 sentence description of both, and then use one of them 5.Extra credit: use a video
54

Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Dec 29, 2015

Download

Documents

Anis Barton
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Lab 4

1. Get an image into a ROS node2. Find all the orange pixels (suggest HSV)3. Identify the midpoint of all the orange pixels4. Explore the findContours and

simpleBlobDetection functions in OpenCV. Give a 1-2 sentence description of both, and then use one of them

5. Extra credit: use a video rather than an image

Page 2: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.
Page 3: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Matching

®

®®

Global MapLocal Map

…… …

obstacle

Where am I on the global map?

Examine different possible robot positions.

Page 4: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

• General approach:

• A: action• S: pose• O: observationPosition at time t depends on position previous position and action, and current observation

Page 5: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

1. Uniform Prior

2. Observation: see pillar

3. Action: move right

4. Observation: see pillar

Page 6: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Localization

Sense Move

Initial Belief

Gain Information Lose

Information

Page 7: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Bayes Formula

evidence

prior likelihood

)(

)()|()(

yP

xPxyPyxP

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

x

xPxyP

xPxyPyxP

)()|(

)()|()(

Page 8: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Simple Example of State Estimation

• Suppose a robot obtains measurement • What is ?

Page 9: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example

P(z|open) = 0.6 P(z|open) = 0.3 P(open) = P(open) = 0.5

67.03

2

5.03.05.06.0

5.06.0)|(

)()|()()|(

)()|()|(

zopenP

openpopenzPopenpopenzP

openPopenzPzopenP

raises the probability that the door is open.

)()()|(

)|(zP

openPopenzPzopenP

Page 10: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.
Page 11: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

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?

Page 12: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Typical Actions

• Actions are never carried out with absolute certainty.• In contrast to measurements, actions generally increase the

uncertainty. • (Can you think of an exception?)

Page 13: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Modeling Actions

• To incorporate the outcome of an action u into the current “belief”, we use the conditional pdf

• This term specifies the pdf that executing changes the state from to .

Page 14: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example: Closing the door

Page 15: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

for :

If the door is open, the action “close door” succeeds in 90% of all cases.

open closed0.1 1

0.9

0

Page 16: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Integrating the Outcome of Actions

')'()',|()|( dxxPxuxPuxP

)'()',|()|( xPxuxPuxP

Continuous case:

Discrete case:

Applied to status of door, given that we just (tried to) close it?

Page 17: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Integrating the Outcome of Actions

')'()',|()|( dxxPxuxPuxP

)'()',|()|( xPxuxPuxP

Continuous case:

Discrete case:

P(closed | u) = P(closed | u, open) P(open) + P(closed|u, closed) P(closed)

Page 18: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example: The Resulting Belief

1615

83

11

85

109

)(),|(

)(),|(

)'()',|()|(

closedPcloseduclosedP

openPopenuclosedP

xPxuclosedPuclosedP

Page 19: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example: The Resulting Belief

1615

83

11

85

109

)(),|(

)(),|(

)'()',|()|(

closedPcloseduclosedP

openPopenuclosedP

xPxuclosedPuclosedP

OK… but then what’s the chance that it’s still open?

Page 20: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example: The Resulting Belief

)|(1161

83

10

85

101

)(),|(

)(),|(

)'()',|()|(

uclosedP

closedPcloseduopenP

openPopenuopenP

xPxuopenPuopenP

Page 21: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Summary

• Bayes rule allows us to compute probabilities that are hard to assess otherwise.

• Under the Markov assumption, recursive Bayesian updating can be used to efficiently combine evidence.

Page 22: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example

Page 23: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example

s

P(s)

Page 24: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example

Page 25: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example

How does the probability distribution change if the robot now senses a wall?

Page 26: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example 2

0.2 0.2 0.2 0.2 0.2

Page 27: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example 2

0.2 0.2 0.2 0.2 0.2

Robot senses yellow.

Probability should go up.

Probability should go down.

Page 28: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example 2

• States that match observation• Multiply prior by 0.6

• States that don’t match observation• Multiply prior by 0.2

0.2 0.2 0.2 0.2 0.2

Robot senses yellow.

0.04 0.12 0.12 0.04 0.04

Page 29: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example 2

!

The probability distribution no longer sums to 1!

0.04 0.12 0.12 0.04 0.04

Normalize (divide by total)

.111 .333 .333 .111 .111

Sums to 0.36

Page 30: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Nondeterministic Robot Motion

R

The robot can now move Left and Right.

.111 .333 .333 .111 .111

Page 31: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Nondeterministic Robot Motion

R

The robot can now move Left and Right.

.111 .333 .333 .111 .111

When executing “move x steps to right” or left:.8: move x steps.1: move x-1 steps.1: move x+1 steps

Page 32: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Nondeterministic Robot Motion

Right 2

The robot can now move Left and Right.

0 1 0 0 0

0 0 0.1 0.8 0.1

When executing “move x steps to right”:.8: move x steps.1: move x-1 steps.1: move x+1 steps

Page 33: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Nondeterministic Robot Motion

Right 2

The robot can now move Left and Right.

0 0.5 0 0.5 0

0.4 0.05 0.05 0.4 (0.05+0.05)0.1

When executing “move x steps to right”:.8: move x steps.1: move x-1 steps.1: move x+1 steps

Page 34: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Nondeterministic Robot Motion

What is the probability distribution after 1000 moves?

0 0.5 0 0.5 0

Page 35: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example

Page 36: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

ExampleRight

Page 37: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Example

Page 38: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

ExampleRight

Page 39: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Kalman Filter Model

Area under the curve sums to

𝜇

Gaussian

(in for now)

σ2

Page 40: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Kalman Filter

Sense Move

Initial Belief

Gain Information Lose

Information

Bayes Rule(Multiplication)

Convolution(Addition)

Gaussian:μ, σ2

Page 41: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Measurement ExamplePrior Position Estimate Measurement Estimate

μ, σ2

v, r2

Page 42: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Measurement ExamplePrior Position Estimate Measurement Estimate

Where is the new mean ?

μ, σ2

v, r2

Page 43: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Measurement ExamplePrior Position Estimate Measurement Estimate

What is the new covarance ?

μ, σ2

v, r2

σ2’?

Page 44: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Measurement ExamplePrior Position Estimate Measurement Estimate New Estimate

μ, σ2

v, r2

μ', σ2’

To calculate, go through and multiply the two Gaussians and renormalize to sum to 1Also, the multiplication of two Gaussian random variables is itself a Gaussian

Page 45: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Another point of view…

Prior Position Estimate Measurement Estimate New Estimate

μ, σ2

v, r2

μ', σ2’

: p(x): p(z|x): p(x|z)

Page 46: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

ExamplePrior Position Estimate Measurement Estimate

Page 47: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

ExamplePrior Position Estimate Measurement Estimate

Page 48: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

ExamplePrior Position Estimate Measurement Estimate

μ’=12.4σ2’=1.6

Page 49: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Kalman Filter

Sense Move

Initial Belief

LoseInformation

Convolution(Addition)

Gaussian:μ, σ2

Page 50: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Motion Update

• For motion

Model of motion noise

μ’=μ+u

σ2’=σ2+r2

u, r2

Page 51: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Motion Update

• For motion

Model of motion noise

μ’=μ+u

σ2’=σ2+r2

u, r2

Prior Position Estimate

M

Page 52: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Motion Update

• For motion

Model of motion noise

μ’=μ+u=18

σ2’=σ2+r2=10

u, r2

Prior Position Estimate

M

Page 53: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Kalman Filter

Sense Move

Initial Belief

Gaussian:μ, σ2

μ’=μ+uσ2’=σ2+r2

Page 54: Lab 4 1.Get an image into a ROS node 2.Find all the orange pixels (suggest HSV) 3.Identify the midpoint of all the orange pixels 4.Explore the findContours.

Kalman Filter in Multiple Dimensions

2D Gaussian