mcgill university - comp765 fall 2017dmeger/comp765/slides/comp765...mcgill comp 765 sept 18th, 2017...

63
EKF and SLAM McGill COMP 765 Sept 18 th , 2017

Upload: others

Post on 09-Jul-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

EKF andSLAM

McGill COMP 765

Sept 18th, 2017

Page 2: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Outline

• News and information

• Instructions for paper presentations

• Continue on Kalman filter: EKF and extension to mapping

• Example of a real mapping system: visual structure from motion

Page 3: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Next 3 Lectures

• Sept 21st

• Normal room

• Lead by Florian and Travis

• Required reading (at least quickly) the 2 papers listed on the list

• Sept 26th and 28th

• MC 103

• Joint with COMP 417

• Lead by Jose Ruis, Professor in intelligent control from Mexico

Page 4: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Paper Presentations

• Presenters:• Read the paper carefully• Prepare roughly 15 minutes of speaking. Can include showing the paper

pdf and using their figures, probably better to show some powerpointsummary, say things in your own words

• Goal is to identify key points of the paper, teach the class something• Goal is not to be a complete expert. It’s OK to raise confusing points.

Remember, all research papers are imperfect!

• Audience:• Read the papers ahead, come up with questions on the spot. Fill out

feedback forms afterwards.

Page 5: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Kalman Filter:

an instance of Bayes’ Filter

Linear dynamics with Gaussian noiseLinear observations with Gaussian noise Initial belief is Gaussian

Assumptions guarantee that if the prior belief before the predictionstep is Gaussian

and the posterior belief (after the update step) will be Gaussian.

then the prior belief after the prediction step will be Gaussian

Page 6: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Kalman Filter:

an instance of Bayes’ Filter

Linear dynamics with Gaussian noiseLinear observations with Gaussian noise Initial belief is Gaussian

Assumptions guarantee that if the prior belief before the predictionstep is Gaussian

and the posterior belief (after the update step) will be Gaussian.

then the prior belief after the prediction step will be Gaussian

Suppose you replace the linear models with nonlinear models.

Does the posterior remainGaussian?

Page 7: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Kalman Filter:

an instance of Bayes’ Filter

Linear dynamics with Gaussian noiseLinear observations with Gaussian noise Initial belief is Gaussian

Assumptions guarantee that if the prior belief before the predictionstep is Gaussian

and the posterior belief (after the update step) will be Gaussian.

then the prior belief after the prediction step will be Gaussian

Suppose you replace the linear models with nonlinear models.

Does the posterior remainGaussian? NO

Page 8: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

8

Linearity Assumption Revisited

If and

then

Page 9: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

9

Nonlinear Function

If andthen y is not necessarilydistributed as a Gaussian.

Page 10: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

10

Nonlinear Function

If andthen y is not necessarilydistributed as a Gaussian.

How can we approximate p(y) using a single Gaussian, without having a formula for p(y)?

IDEA #1: MONTE CARLO SAMPLING- Draw many (e.g. 10^6) samples xi ~ p(x)- Pass them through the nonlinear function yi = g(xi)- Compute the empirical mean (m) and covariance (S) of the samples yi- Return Normal(m, S)

IDEA #2: LINEARIZE THE NONLINEAR FUNCTIONS f, h- Then we are in the case y = Gx +c, so p(y) is a Gaussian

Page 11: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

11

Nonlinear Function

If andthen y is not necessarilydistributed as a Gaussian.

How can we approximate p(y) using a single Gaussian, without having a formula for p(y)?

IDEA #1: MONTE CARLO SAMPLING- Draw many (e.g. 10^6) samples xi ~ p(x)- Pass them through the nonlinear function yi = g(xi)- Compute the empirical mean (m) and covariance (S) of the samples yi- Return Normal(m, S)

IDEA #2: LINEARIZE THE NONLINEAR FUNCTIONS f, h- Then we are in the case y = Gx +c, so p(y) is a Gaussian

This is how we computedthe Gaussian approximationof p(y).

Page 12: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

12

Nonlinear Function

If andthen y is not necessarilydistributed as a Gaussian.

How can we approximate p(y) using a single Gaussian, without having a formula for p(y)?

IDEA #1: MONTE CARLO SAMPLING- Draw many (e.g. 10^6) samples xi ~ p(x)- Pass them through the nonlinear function yi = g(xi)- Compute the empirical mean (m) and covariance (S) of the samples yi- Return Normal(m, S)

IDEA #2: LINEARIZE THE NONLINEAR FUNCTIONS f, h- Then we are in the case y = Gx +c, so p(y) is a Gaussian

Bad idea to use in Kalman Filter because we want to approximate p(y) efficiently.

Page 13: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

13

Linearization

Notice how the Linearization approximation differs from the Monte Carlo approximation (whichis better, provided sufficiently many samples).

That said, the Linearization approximationcan be computed efficiently, and can be integrated into the Kalman Filter estimator Extended Kalman Filter

Page 14: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

14

Linearization with low approximation error

The quality of the linearization approximation depends on the uncertaintyof p(x) but also on the shape of the nonlinearity g(x).

In this example p(x) has small variance so most points will be concentrated around 0.5 and will pass through a very small region of g(x), where g(x) is close to linear.

In this case p(y) is nearly Gaussian,and the Linearization approximationmatches the Monte Carlo approximation.

Page 15: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

15

Linearization with high approximation error

The quality of the linearization approximation depends on the uncertaintyof p(x) but also on the shape of the nonlinearity g(x).

In this example p(x) has high variance so points g(x) will be spread out around g(0.5), where g(x) is not close to linear.

In this case p(y) is multimodal,and the Linearization approximationmatches the Monte Carlo approximation are both suboptimal approximations. Again Monte Carlo is better, provided sufficient samples.

Page 16: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

How do we linearize?

• Using the first order Taylor expansion around the mean of the previous update step’s state estimate:

Constant term with respect tothe state

Recall how to compute the Jacobianmatrix. For example, if

then the Jacobian of f with respect to at is

Page 17: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

How do we linearize?

• Using the first-order Taylor expansion around the mean of the previous prediction step’s state estimate:

Constant term with respect tothe state

Recall how to compute the Jacobianmatrix. For example, if

then the Jacobian of f with respect to at is

Page 18: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Extended Kalman Filter: an instance of Bayes’ Filter

Linear dynamics with Gaussian noiseLinear observations with Gaussian noise Initial belief is Gaussian

Assumptions guarantee that if the prior belief before the predictionstep is Gaussian

and the posterior belief (after the update step) will be Gaussian.

then the prior belief after the prediction step will be Gaussian

Page 19: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

EKF in N dimensions

Prediction Step

Update Step

Received measurement but expected to receive

Prediction residual is a Gaussian random variable where the covariance of the residual is

Kalman Gain (optimal correction factor):

Dynamics Measurements

Init

Page 20: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

20

• Efficient: Polynomial in measurement dimensionality k and state dimensionality n:

O(k2.376 + n2)

• Not optimal (unlike the Kalman Filter for linear systems)

• Can diverge if nonlinearities are large

• Works surprisingly well even when all assumptions are violated

EKF Summary

As in KF, inverting the covariance of theresidual is O(k^2.376)

Page 21: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

21

Example #1: EKF-Localization

• Given• Map of the environment.• Sequence of sensor measurements.

• Wanted• Estimate of the robot’s position.

• Problem classes• Position tracking• Global localization• Kidnapped robot problem (recovery)

“Using sensory information to locate the robot in its environment is the most fundamental problem to providing a mobile robot with autonomous capabilities.” [Cox ’91]

Page 22: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

22

Landmark-based Localization

Landmarks, whoseposition in the world is known.

Each robot measuresits range and bearingfrom each landmarkto localize itself.

State of a robot:

Page 23: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

23

Landmark-based Localization

Measurement at time t,

is a variable-sized vector, depending on the landmarks that arevisible at time t.

Each measurement is a 2D vector, containing range and bearing fromthe robot to a landmark.

Page 24: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

24

Estimation Sequence (1)

Page 25: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

25

Estimation Sequence (2)

Page 26: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

26

Comparison to true trajectory

Page 27: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Introducing: The SLAM problem

• So far we have assumed measurement model is only a function of the state and observation: this assumes knowledge of the world map (example 3 doors environment)

• Robots often have the need to navigate without a pre-known map. This requires simultaneously building a map and localizing the robot: the SLAM problem (example, jointly determine where the doors and robot are located)

Page 28: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

28

Given:

• The robot’s controls

• Observations of nearby features

Estimate:

• Map of features

• Path of the robot

First method: EKF-SLAM

A robot is exploring an unknown, static environment.

Page 29: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

29

Structure of Landmark-based SLAM

Page 30: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

30

Why is SLAM a hard problem?SLAM: robot path and map are both unknown

Robot path error correlates errors in the map

Page 31: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

31

Why is SLAM a hard problem?

• In the real world, the mapping between observations and landmarks is unknown

• Picking wrong data associations can have catastrophic consequences

• Pose error correlates data associations

Robot pose

uncertainty

Page 32: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

32

2

2

2

2

2

2

2

1

21

2221222

1211111

21

21

21

,),(

NNNNNN

N

N

N

N

N

llllllylxl

llllllylxl

llllllylxl

lllyx

ylylylyyxy

xlxlxlxxyx

N

tt

l

l

l

y

x

mxBel

• Map with N landmarks: (3+2N)-dimensional Gaussian

• Can handle hundreds of dimensions

EKF-SLAM

Page 33: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

33

EKF-SLAM

Map Covariance matrix

Page 34: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

34

EKF-SLAM

Map Covariance matrix

Page 35: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

35

EKF-SLAM

Map Covariance matrix

Page 36: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

36

Properties of EKF-SLAM (Linear Case)

Theorem:

The determinant of any sub-matrix of the map covariance matrix decreases monotonically as successive observations are made.

Theorem:

In the limit the landmark estimates become fully correlated

[Dissanayake et al., 2001]

Page 37: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Example 2: Particle Filter SLAM (the dumb way)• Augment each particle’s state estimate with full map

information

• Each particle contains a full copy of the map

• What are the practical implications of this?

Page 38: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Example 3: Rao-Blackwellized Particle Filters (the modern way)

Page 39: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

• Visual SLAM• Localization and mapping with measurements usually coming from tracking image features:

• keypoints/corners

• edges

• image intensity patches

• Can use one or more cameras

• Visual Odometry• Real-time localization with measurements usually coming from tracking image features:

• keypoints/corners

• edges

• image intensity patches

• Can use one or more cameras

Page 40: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Structure from Motion

How can we estimate both 3D point positions and the relative camera transformations?

Sometimes alsocalled bundle adjustment

Q: Why is it different thanSLAM?

A: SLAM potentially includes

- loop closure- dynamics constraints- velocities, accelerations

Page 41: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Basic underlying component in many of these problems:

keypoint detection and

matching across images

Page 42: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 43: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Ideally, we want the descriptor to be invariant (i.e. little tono change) when there are

- viewpoint changes(small rotation or translation of the camera)

- scale-changes

- illumination changes

Page 44: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 45: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 46: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Corner detectors

• Harris

• FAST

• Laplacian of Gaussian detector

• SUSAN

• Forstner

Page 47: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 48: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Scale-space representation

Feature detection:

search for “corners”/keypointsacross many scales, and returna list of (x, y, scale) keypoints

Page 49: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 50: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 51: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 52: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 53: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 54: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Many other local descriptors

• ORB

• BRIEF

• FREAK

• RootSIFT-PCA

Page 55: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Feature matching

Page 56: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue
Page 57: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Structure from Motion

How can we estimate both 3D point positions and the relative camera transformations?

Sometimes alsocalled bundle adjustment

Q: Why is it different thanSLAM?

Page 58: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Structure from Motion

How can we estimate both 3D point positions and the relative camera transformations?

Sometimes alsocalled bundle adjustment

Q: Why is it different thanSLAM?

A: SLAM potentially includes

- loop closure- dynamics constraints- velocities, accelerations

Page 59: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Loop Closure in Visual SLAM

ORB-SLAM, Mur-Artal, Tardos, Montiel, Galvez-Lopez

Page 60: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Bundler (bundle adjustment/structure from motion)

Page 61: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Structure from Motion as Least Squares

Indicates the frame of the k-th camera.

Page 62: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Structure from Motion as Least Squares

Expected pixel projection of3D point onto camera k

Actual pixel measurement of3D point from camera k

Page 63: McGill University - COMP765 Fall 2017dmeger/comp765/slides/COMP765...McGill COMP 765 Sept 18th, 2017 Outline •News and information •Instructions for paper presentations •Continue

Structure from Motion as Least Squares