Tech Arcanist
Get in touch

58Chapter 58 of 74

Where Is the Robot? Local and Global Localization

Introduction

The tf2 library is now part of the toolbox: it keeps track of every frame and every transform between them. With it we can start to answer one of the most important questions in mobile robotics: where is the robot?

The goal is to estimate, at any moment in time, the position of the robot from the information its sensors give us. This problem is called localization. In this chapter the problem is set up with reference frames and transforms, and split into two smaller problems that are easier to solve.

Three reference frames

We keep the ROS 2 convention for describing the position of a robot in a two dimensional space, and define three reference frames:

FrameWhat it marksDoes it move?
RThe robot itself. It is attached to the robot and moves along with it.Yes, with the robot
OThe initial position of the robot: the place where the motion started.No
MA fixed point of the map that is taken as its origin, the centre of the map.No
Three frames on a plane: M at the map origin, O where the robot started, R on the robot. An arrow T_MO goes from M to O, an arrow T_OR from O to R, and a dashed arrow T_MR from M to R.
The three frames and the transforms that connect them

Localization as a chain of transforms

With these three frames, the localization problem becomes the calculation of two transformation matrices:

  • T_OR: the transform that connects the frame O with the frame R, so where the robot is compared with its starting point.
  • T_MO: the transform that connects the frame M with the frame O, so where the starting point is in the map.

Once both are known, we only have to compose them, which means multiplying them, to get the overall transform that connects the frame M to the frame R. That transform is the answer to the question "where is the robot?"

T_MR = T_MO × T_OR

Breaking the problem in two

As always with a complex problem, we can break it down into smaller and easier sub problems, solve them separately and then combine the results to solve the original problem. This is also the classic way to approach localization in robotics.

Instead of trying to find the relationship between M and R directly, and so the pose of the robot in the map, we first find the pose of the robot relative to its starting point.

Local localization

Finding the relationship between the frame O and the frame R, so the transform T_OR, is called local localization. It answers: how far and in which direction has the robot moved since it started, and how much has it turned?

Global localization

Based on that, we can then work out where the starting point of the robot is in the map, the transform T_MO. Composing it with T_OR gives the transform between M and R, and so the position of the robot in the map. This is called global localization.

Local localizationGlobal localization
TransformT_OR (O to R)T_MO, and with it T_MR (M to R)
Question it answersWhere is the robot compared with where it started?Where is the robot in the map?
Needs a map?NoYes

Drive the same path from three different starting points below. The local pose is identical every time, while the pose in the map depends on where the robot started.

The next chapters focus on the first problem, local localization: strategies to give an accurate estimate of the position of the robot relative to its starting point. Global localization, finding the robot in a map of its environment, belongs together with mapping and is a topic of its own.