Skip to content
RoboLearn
Not completed

Mapping and SLAM

AdvancedAdvanced35 minBefore this: Navigation and route planning, Wheel encoders

What you’ll learn

  • Maps robots use: occupancy grids
  • Localization: where am I on a map?
  • SLAM: building the map and localizing at the same time

Occupancy grids

The world is split into small squares (for example 5 × 5 cm). Each cell holds the probability that it’s occupied: free, wall, or unknown. Distance sensors fill it in: cells along a ray are free, the cell where the ray hits is occupied.

Localization

With a map, the robot compares what its sensors see now with what they should see from each possible position. A popular method keeps many guesses (“particles”) and keeps the ones that match best: Monte Carlo localization.

SLAM

Simultaneous Localization and Mapping solves both at once, a chicken-and-egg problem: you need a map to know where you are, and you need to know where you are to build a map.

  • Odometry (encoders, IMU) gives a first guess of movement, which drifts.
  • Scan matching lines up new sensor data with the map to correct it.
  • Loop closure: when the robot recognises a place it’s seen before, it corrects all the drift around the loop.

Sensors for SLAM

  • 2D lidar (a spinning laser): the classic choice for indoor robots and robot vacuums.
  • Cameras (visual SLAM): cheaper, harder.
  • Depth cameras for 3D maps.

In ROS 2, packages such as slam_toolbox build maps from lidar data, and Nav2 plans routes on them.

Finished this lesson?