Topic hub

SLAM and mapping

How a robot builds a map while working out where it is in it. Front ends and back ends, lidar and visual SLAM, occupancy grids and other map types, loop closure, and localising in a map you already have.

Updated 14 Nov 2026 · SLAM, lidar SLAM, visual SLAM, visual-inertial odometry, occupancy grid, loop closure, pose graph, localisation, slam_toolbox, ORB-SLAM3

Overview

SLAM, simultaneous localisation and mapping, solves two problems that depend on each other. To build a map you need to know where the robot was when it took each measurement. To know where the robot is you need a map. SLAM estimates both together from the robot’s own sensors, with no external positioning.

Most deployed mobile robots use SLAM once, to build a map during commissioning, and then localise against that map in daily operation. Robots that explore unknown places, such as field robots, drones and some legged robots, run SLAM continuously. This hub is for engineers choosing a SLAM system, tuning one, or working out why a map has a double wall or a corridor that bends.

Key ideas

Front end and back end

Cadena and colleagues’ 2016 survey describes modern SLAM as two parts. The front end turns raw data into constraints: it matches each lidar scan to the last one or tracks image features between frames, giving relative motion, and it decides which observations refer to the same landmark or place. The back end takes those constraints and solves for the trajectory and map that fit them best, usually as a pose graph optimised by nonlinear least squares. That is the factor-graph machinery from /topics/state-estimation/, and Grisetti and colleagues’ tutorial walks through it for SLAM.

The split matters in practice because the two halves fail differently. Front ends fail on data: featureless corridors, glass, motion blur, moving people. Back ends fail on wrong constraints: one bad data association can pull the whole map out of shape.

sensorslidar, camera, IMUfront endscan matching, trackingback endpose-graph optimiserloop closureplace recognitionmapgrid or cloudmap to odomsent to tf2odometryloop constraintskeyframes
A SLAM pipeline. The front end turns raw sensor data into relative motion estimates. Loop-closure detection recognises places seen before and adds constraints between distant poses. The back end optimises the pose graph and publishes the map and the map-to-odom correction that REP 105 assigns to the localisation component.

Lidar and visual SLAM

Lidar SLAM matches point clouds directly. Two-dimensional lidar SLAM on a planar floor is mature: slam_toolbox, which the Nav2 bringup launch files use for mapping, builds a pose graph from scan matching. In 3D, LOAM extracts edge and planar points to register scans, and KISS-ICP argues that plain point-to-point ICP, carefully done, is enough for odometry. Lidar gives metric scale and works in the dark. It struggles in long featureless corridors and open fields where every scan looks alike.

Visual SLAM tracks features or pixel intensities across camera frames. It is cheap and gives rich data for place recognition, but a single camera cannot recover metric scale, and lighting changes and fast motion break tracking. Adding an IMU (visual-inertial odometry) fixes scale and gravity direction and bridges short dropouts. ORB-SLAM3 supports monocular, stereo and RGB-D cameras, with or without an IMU, and keeps several maps that it merges when it recognises a place.

Occupancy grids and other maps

An occupancy grid, introduced by Elfes (1989), divides space into cells and stores the probability that each is occupied. Each range reading raises the probability of the cell it hits and lowers it along the ray. Implementations store log-odds so an update is an addition. Grids are what path planners consume, and 3D versions use voxels. Point-cloud maps keep raw geometry for localisation. Sparse feature maps store only landmarks, which is compact and good for relocalisation but useless for planning on its own.

Loop closure and localisation in a known map

Odometry drift accumulates, so a robot that drives round a building and returns to its start will not line up with where it began. Loop closure recognises the revisited place and adds a constraint between the two poses. The back end then spreads the correction along the whole loop. A correct loop closure straightens the map. A false one, between two similar-looking corridors, can fold it, so systems check geometric consistency before accepting one and use robust cost functions in the optimiser.

Once a map exists, localisation is easier than SLAM. Nav2’s AMCL runs a particle filter against an occupancy grid, and slam_toolbox has its own localisation mode. Both follow REP 105: they compute the robot’s pose in map and publish the map to odom correction, so the odom frame stays continuous for local control.

Where to start

/learn/beginner/07-differential-drive/ gives you odometry and shows how it drifts. /learn/beginner/08-grid-path-planning/ plans on the kind of grid SLAM produces. /learn/beginner/06-sensors-and-noise/ explains the noise that makes the problem hard.

Tools and platforms

Tool What it is for Licence Platform
slam_toolbox 2D lidar SLAM, lifelong mapping and localisation in ROS 2 LGPL-2.1 /platforms/ros/
RTAB-Map Graph SLAM for RGB-D, stereo and lidar with appearance-based loop closure BSD-3-Clause /platforms/ros/
ORB-SLAM3 Feature-based visual and visual-inertial SLAM. The authors offer a separate commercial licence GPL-3.0 /platforms/opensource/
KISS-ICP Lidar odometry with few parameters MIT /platforms/opensource/
Cartographer 2D and 3D SLAM. Its README states it is no longer actively maintained Apache-2.0 /platforms/opensource/
Nav2 AMCL Particle-filter localisation in a known 2D map LGPL-2.1-or-later /platforms/ros/

Common mistakes

  • Mapping with bad odometry and expecting the SLAM back end to fix it. Calibrate wheel radius and track width first.
  • Leaving the lidar-to-base transform wrong by a degree. Every scan is then rotated and walls thicken.
  • Mapping during busy hours. People and pallets become permanent walls.
  • Accepting every loop closure. One false match can ruin a map that took an hour to build.
  • Running full SLAM in production when localisation in a fixed map would be more predictable.

Going deeper

Recent papers

  • RGB-D SLAM on the Edge: Benchmarking and Profiling RTAB-Map and ORB-SLAM3 on the Raspberry Pi 5

    H. Patil, J. Joshi, R. Saluja et al. · arXiv cs.RO · digest

    The authors ran RTAB-Map and ORB-SLAM3 on a Raspberry Pi 5 on six TUM RGB-D sequences, each at three resolutions, and recorded per-frame time, memory use, CPU load, temperature, trajectory error and how much of each sequence stayed tracked, and profiling each system down to function level. With RTAB-Map set to process and retain every frame, its full pipeline took 150 to 462 ms per frame against 26 to 62 ms for ORB-SLAM3, and most of RTAB-Map's time went into optimising a pose graph that grows without limit under its default memory settings. At quarter resolution both systems lost tracking on most sequences, and runs that lost tracking reported lower error on the poses they kept, so error must always be read alongside coverage. This is a dataset benchmark on the board rather than a flight test, and repeating an identical run changed trajectory error by as much as 27%, which leaves the accuracy comparison inconclusive even though timing repeated within 1% to 5%.