Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... ·...

45
Robotics: Science and Systems Zhibin (Alex) Li School of Informatics University of Edinburgh Localization: fundamentals & grid localization 1

Transcript of Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... ·...

Page 1: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Robotics: Science and Systems

Zhibin (Alex) LiSchool of Informatics

University of Edinburgh

Localization: fundamentals & grid localization

1

Page 2: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Outline1. Introduction of localization2. Basic concepts3. Grid localization:

a. Spatial discretizationb. Probability and Bayes rulec. Principles (histogram filter)

4. Summary and discussion

2

Page 3: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Recap: What Tools Do We Need?

3

Localisation(Where am I?)

Page 4: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

The kidnapped robot problem

4

A situation where an autonomous robot in operation is carried to an arbitrary location.

Where am I?

Wabian @Waseda University, Japan

In a new and unknown environment, the robot needs to build the map and localize itself at the same time, this is called simultaneous localization and mapping (SLAM).

Page 5: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Localization problemLocalization is a fundamental task for an autonomous mobile robot to determine its location in a known environment. This problem is originated from mobile robots but is generalized for any system with mobility: wheeled robots, legged robots as well.

5Global positioning system (GPS) has limited accuracy (large variation, 5-10 m) and latencies for high speed applications.

Page 6: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Localization problemLocalization in robotics, location includes the information of position & orientation for example, to represent the robot as a whole.

6

Mobile robot Legged robot

Multiple info is needed, eg features from environment, lane markers, objects, edges, etc.

Page 7: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Localization in practicalFor example in the practicals, a mobile robot needs to know where it is in the arena by detecting what surroundings are, where the map of arena is known.

7

Page 8: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Real-time localizationIn some real-world applications, localization needs to be accurate and has small latency:❏ Good accuracy: <10cm ❏ Real time, or fast enough

8

Page 9: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Localization

9

Page 10: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Concept

10

Page 11: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Concept

11

Initial Belief

?Belief

Position

Page 12: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Concept: first measurement

12

Belief

Position

How it affects our belief?

After the first measurement, the belief changes, and we call it posterior belief. The posterior function is the probability distribution that represents the current belief.

Page 13: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Concept: move to a new location

13

Belief

PositionIncreased uncertainty!

σProbability propagates with movements: convolution.

What will happen if the robot moves?

Move

Page 14: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Concept: second measurement updates the belief

14

Belief

Position

What will happen if the robot sees a valve again?

The 2nd guess where it possibly can be.

Page 15: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Localization

15

Required information:1. Internal measurement,

odometry, kinematics;2. External measurement (camera,

laser scan, infrared sensor, sonar). Observation of external environment (global reference) is important, because measurement of odometry (dead-reckoning) drifts.

Improving position tracking of a mobile robot

Page 16: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Grid Localization

16

Page 17: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Grid localizationThe previous conceptual example is built on our human cognitive understanding, but how to represent these mathematically in the form of algorithms?

Key elements:1. Discretization of space: to convert a continuous space (infinite) to a

discrete space (finite). Search in a set of real numbers instead of infinite real numbers.

2. Probability theory3. Bayes’ rule

17

Grid localization is a probabilistic map-based localization, where map is given.

Page 18: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Discretization of space

18

1 2 3 4 5 6 7 8

xx Picture source:

www.pirobot.org

y

Page 19: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Discretization of space

Continuous map

19

Discrete map

Page 20: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

DefinitionsProbability: How likely an event will happen.Example: Tossing a coin, two possible outcomes with equal likelihood, for heads and tails, their probability is both 50%. These two events are independent, and exclusive (it cannot be heads and tails at the same time).

Probability of an event =

Probability theory

20

Number of ways an event occur ________________________________________________Total number of outcomes

Example of throw a single die: Sample space is all possible outcomes (6)A sample point is one possible outcome

Page 21: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Laws of probabilities

21

Definition: and are two events, and are the corresponding probabilities.A basic rules of probability:

1. , probability of event 2. , probability of no event 3. , probability of event or 4. , probability of event and (if independent)5. , probability of event given the event (if

independent)

Page 22: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Total probabilityLaw of total probability: the total probability of an outcome which can possibly happen from a finite number of different events. Mathematically, it is:

22

Page 23: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Posterior probability: the conditional probability of an event that is assigned after the relevant test evidence is taken into account.

● Posterior probability ∝ Prior probability × Likelihood

Posterior probability

23

Prior Probability

Test Evidence

Posterior Probability

Page 24: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Bayes’ ruleBayes' theorem is stated mathematically as follows:

- and are the probability of observing and regardless of each other.- : the conditional probability of observing event given that is true.- : the conditional probability of observing event given that is true.

24

Page 25: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Bayes’ ruleFor the previous localization, define x as the event, z as the observation/measurement, and the probability, so the probability of event x given measurement of z is .According to Bayes’ rule:

How do we understand this?

25

False positive paradox from Bayes’ rule

Page 26: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Grid localization is a non-parametric approach that approximates the posterior using a histogram filter over a grid decomposition of the pose space.

Grid localization is a probabilistic approach that computes the probability distribution of the robot configuration in operation space using acquired sensor information from a sequence of actions.

Grid localization

26

Exploration

Page 27: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Grid localizationGrid localization: discretize the operational space uniformly.

27

1 2 3 4 5 6 7 8

Suppose the map is known, it is decomposed into grids, eg 1-D case here.

Page 28: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

ProbabilityIn the beginning without perception, the robot doesn’t know where it is, so the robot can be in any of this grid cell, what is the probability of each grid?

28

? ?

Page 29: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Apply Bayes’ ruleDefine by the grid cell, the measurement at, and the probability.Define the probability that is measured at the location of the grid cell as .Bayes’ rule:

Let’s say measurement is the detection of an object, eg valve, there are multiple possibilities where this is measured (grid 2, 4, 7). is the possibility of the location of grid cell, in our case, possibility is equal in the beginning for all cells, so . is the conditional probability, the probability of having measurement at . Normally, measurement is noisy, so the successful detection of has probability less than 1. For simplicity, we assume at the orange cell, and at the grey cell. 29

Page 30: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Apply law of total probabilityBayes’ rule:

The sum of all the probabilities is equal to unit of 1. So is a way to normalise so the sum of equals to 1.

In an ideal case here, .

For grid cell 2,4, 7, , , so

So , for ; , otherwise.

The sum of follows exactly the law of total probability.

30

Page 31: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Apply law of total probabilityNon-normalised version of Bayes’ rule:

The normalization factor s ensures law of total probability holds.

Therefore, if we want to rule out what the probability is of being at while seeing , we only need to reason about the probability of a location and the probability of measuring at the location of .

31Key:

Page 32: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Principles: notion

32

Belief

Probability of sensor measurement: , is the grid cell, is the measurement at .

Belief of location: , is the set/vector of grid cells at .

Probability

Page 33: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Sense

Measurement update turns the prior into the posterior.33

Prior

Belief

1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/8

Posterior

Probability: correct detection has a higher probability.

Page 34: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Next, what we do?

Without movements, sensors produce the same reading, thus no new info can be generated to update the belief. The robot needs to move for getting new sensor measurements.

34

Recall what we learned

Page 35: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Acquire new sensor feedback by actions

Obtain new information by a variety of actions: move to new observation point, scan camera, etc..

35Adapted from Robot Localization using ArUco @youtube

Page 36: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Move/Act

Here, for simplicity, we assume a perfect movement without any uncertainty.36

Belief

Posterior

Convolution

Move 2 grids

Page 37: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Sense

37

Belief

Posterior

New measurement

Page 38: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Summary of grid localizationMovement introduces uncertainties, it loses some information. Sensing, however, regains new information.The iteration/loop of ‘move’ and ‘sense’ is a process of losing, gaining and updating information. Bayes’ rule is the core to update the belief.

38

Sense Move/Act

Page 39: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Pseudo code of discrete Bayes filter

39(See details in Thrun et al., Probabilistic Robotics: chapters 8.2)

Page 40: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

An exampleGrid localization to correct accumulated errors from dead-reckoning by matching sonar information with fine grid maps.

40

Page 41: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Pros:1. Grid localization is a straightforward implementation of discrete

Bayes filter, it is simple and easy. 2. Easy to recover from localization errors.

Rethink critically, what are the pros and cons?

41

Page 42: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

Rethink critically, what are the pros and cons?

42

The resolution of the grid is a key variable in the grid localization. The localization error reduces as the resolution increases, ie, smaller and finer grids. However, it demands more computation power and time in return. For a mobile robot in 2D, each discretized pose consists of , for a 10m x 10m area, resolution of 0.05m and 5 degrees results in: 200∙200∙72=2,880,000 states. Cons:1. This indicates scalability issue. A fine fixed-size discretization results

in a huge state space and memory consumption.2. Significant computational power for a large map with high resolution.

Page 43: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

RSS PracticalGeometric representation of arena.

43

Page 44: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

RSS PracticalDiscretization of geometric space: conceptual grids.

44

Page 45: Robotics: Science and Systemswcms.inf.ed.ac.uk/ipab/rss/lecture-notes-2018-2019... · 1.Discretization of space: to convert a continuous space (infinite) to a discrete space (finite).

RSS PracticalDiscretization of arena: practical representation by matrix.

45