Skip to the lesson
FixTheRobot Explore Robotics / Localization & SLAM / M1 SLAM Foundations / M1-T2

Localization & SLAM · Theory · M1

M1-T2 — Localization vs Mapping vs SLAM

Three problems that sound alike and need different tools. Which is yours depends on what you already have.

  • Lesson 2 of 6
  • Module 1: SLAM Foundations
  • Theory
  • About 7 minutes to read

Before choosing an algorithm, ask one question: what do I already know? A known map turns the task into localization. Known poses turn it into mapping. If you know neither, you need SLAM, and the other two are the special cases it contains.

Learning objectives

After this lesson, you should be able to:

  • Classify a robotics task as localization, mapping or SLAM from what is given and what must be estimated.
  • Compute a 2D pose from known landmark positions and relative measurements.
  • Explain what changes when the “known” input is itself noisy.
  • Choose the problem formulation that matches a real deployment (a warehouse, a new building, a mapped city).

The intuition

Think of three versions of a treasure hunt. In the first you have the treasure map and need to find yourself on it: localization. In the second, a surveyor tells you exactly where you stand at each moment and you draw the map: mapping. In the third there is neither, and you draw the map while working out where you are standing: SLAM.

Three problems by what is knownThree boxes. Localization: map known, pose unknown. Mapping: poses known, map unknown. SLAM: both unknown, estimated together.Localizationknown: map unknown: pose Mappingknown: poses unknown: map SLAMknown: neither estimate both Where am I?What is there?Both, at once In every case the robot has controls u and measurements z
The three problems differ only in which of {pose, map} is given. The inputs from the robot (controls and measurements) are the same.

The cleanest way to keep them apart is a table of what is an input and what is an output.

The three estimation problems compared
ProblemGivenEstimatedTypical use
LocalizationMap, controls, measurementsPose xt (and its uncertainty)A warehouse robot running on a pre-built map
Mapping with known posesPoses, measurementsMap mMapping from a motion-capture rig or surveyed positions
SLAMControls, measurementsPoses x1:t and map mFirst visit to any new place
Global localization (kidnapped robot)Map, measurements; the start pose is unknownPose, from scratchRobot restarted somewhere unknown

The mathematics

All three are posterior distributions. Writing them side by side shows exactly what differs.

Localization:  p( xt       |  z1:t , u1:t , m )   m is given
Mapping:       p( m         |  z1:t , x1:t )       x is given
SLAM:          p( x1:t , m |  z1:t , u1:t )     neither given
xt
robot pose at time t.
m
the map.
zt
sensor measurement at time t.
ut
control or odometry from t−1 to t.
p(a | b)
the probability of a, given that b is known. The bar means “given”.

The localization geometry

Suppose a robot sees a landmark whose world position L = (Lx, Ly) is in the map. It measures the landmark in its own frame as r = (rx, ry) (forward and left of the robot). If the robot has heading θ and position p, the geometry says

Landmark observation geometry
L=p+R(θ) rL=p+R(\theta )\,r
R(θ)=[cos⁡θ−sin⁡θ]R(\theta )=[\cos \theta -\sin \theta ]
[sin⁡θ cos⁡θ][\sin \theta \,\cos \theta ]

The matrix R(θ) rotates a vector from the robot frame into the world frame. One landmark with a known range and bearing gives a constraint on the pose, but it cannot fix the heading and position at once. With two or more non-coincident landmarks, the heading is the rotation that aligns the measured directions with the map directions, and the position follows:

Pose from two landmarks
θ=atan2(ΔLy, ΔLx)−atan2(Δry, Δrx)\theta =\mathrm{atan}2(\Delta L_{y},\,\Delta L_{x})-\mathrm{atan}2(\Delta r_{y},\,\Delta r_{x})
p=L−R(θ) rp=L-R(\theta )\,r

where ΔL = L2 − L1 and Δr = r2 − r1. This is the simplest closed-form localization. Real systems use many landmarks and a least-squares fit, because measurements are noisy.

Assumptions

  • Landmarks are identified: the robot knows landmark 1 from landmark 2. Without this, data association must be solved first.
  • The map is correct in localization. If the map has errors, they become pose errors.
  • The poses are correct in mapping. If they are drifting odometry, the map blurs (the next lab shows this).

SLAM contains the other two as special cases: fix the map and you get localization; fix the poses and you get mapping.

A worked example: localization from two landmarks

A robot sees two landmarks. The map says L1 = (4, 2) and L2 = (4, 6). In its own frame the robot measures r1 = (2, 0) and r2 = (2, 4). We solve for the pose and then check it.

  1. Difference of map points. ΔL = (0, 4), length 4. Difference of measurements. Δr = (0, 4), length 4. The lengths match, which is a sanity check: a rigid motion preserves distances. If they did not match, the data association or the map would be wrong.
  2. Heading. atan2(4, 0) − atan2(4, 0) = 90° − 90° = 0. The robot faces along the world x axis.
  3. Position. p = L1 − R(0) r1 = (4, 2) − (2, 0) = (2, 2). The robot is at (2, 2), facing +x.
  4. Verify with the second landmark. p + R(0) r2 = (2, 2) + (2, 4) = (4, 6) = L2. ✓
  5. Now make it noisy. If r2 were measured as (2.2, 3.9), the two landmarks would give slightly different poses. Using only two landmarks, you choose one or average them. With many landmarks you solve a least-squares problem to find the single pose that fits all of them best.

Mapping is the same equation solved for the other unknown: if p and θ are given, then L = p + R(θ) r places the landmark. Doing that for many measurements builds the map. The risk is visible: if p is wrong by 0.2 m, L is wrong by 0.2 m.

Engineering implications and limitations

Choosing between them in practice

  • A building you can map once and reuse (a warehouse, a hospital floor): run SLAM once to build the map, then run localization against it every day. Localization is cheaper, more reliable and does not drift, because the map does not change.
  • A building that changes: pure localization breaks when the map is stale. Use localization with map updates, or lifelong SLAM (Module 8).
  • Never visited before: SLAM is the only option.
  • Outdoors with good GPS: GPS gives the pose, so mapping with known poses is nearly adequate; SLAM still helps where GPS fails (under bridges, indoors).
  • After a power cycle or a lifted robot: global localization. The robot has a map but no idea where it is.

Limits of the closed-form view

The two-landmark solution above is a teaching tool. It assumes exact identification of landmarks and perfect measurements. With noise it is not optimal and can be unstable when the landmarks are close together or collinear with the robot. Real systems use all the measurements in a probabilistic estimator (Modules 3 and 4).

Common misconceptions

“Localization is easy, mapping is the hard part.”

Each is easy only when the other is given. Localization against a wrong or sparse map can fail completely, especially in repetitive environments.

“A robot that has a map is doing SLAM.”

If the map is fixed and only the pose is estimated, it is localization. SLAM implies the map is also being estimated.

“Mapping needs no pose estimation.”

A map is built from measurements placed using poses. If the poses are uncertain, the map is uncertain, which is why mapping with unknown poses is SLAM.

Engineering takeaways

  1. The three problems differ only in which of {pose, map} is given.
  2. Localization places the robot in a known map; mapping places the world around known poses; SLAM does both.
  3. Closed-form pose from landmarks is rigid alignment: rotation from directions, then translation.
  4. A wrong “known” input becomes a wrong output: fixed-map localization inherits map errors, and known-pose mapping inherits pose errors.
  5. Production robots often use SLAM once, then localization in the saved map.

References and further reading

Primary papers and authoritative documentation.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

A delivery robot is given a floor plan of a hospital and must report its position. Which problem is this, and which input would you check first if its position estimates are wrong?

Explanation

It is localization. Check the map first: if the floor plan is outdated or has a wrong dimension, the pose estimate will be wrong however good the algorithm, because the map is treated as truth.

Question 2

A motion-capture system reports the exact pose of a robot arm camera at every frame. The task is to build a 3D model of a table. Why is this not SLAM?

Explanation

The poses are given, so only the map is unknown. This is mapping with known poses, which is a simpler problem. If the poses were estimated from the images themselves, it would become SLAM.

Question 3

In the two-landmark example the lengths of ΔL and Δr must match. What does a mismatch suggest?

Explanation

A rigid motion preserves distances, so a mismatch means the data association is wrong (the robot saw a different landmark), the map is wrong, or the measurements are too noisy. It is a cheap consistency check before trusting the pose.

What’s next

Now try it: the first lab has you compute a pose from landmarks, build a map from poses, and see what happens when the poses are the drifting kind.

Practice this lesson

Understand Localization, Mapping, and SLAM

A robot has a landmark map but no pose, or poses but no map, or neither: decide what can be estimated and compute the first two.

Next lesson

M1-T3 — Why SLAM Is Difficult

Explain the coupling of pose and map errors, drift, ambiguity, dynamic scenes and computational cost.

Nothing below is required to finish this lesson.