SLAM Basics (Simultaneous Localization and Mapping)
The chicken-and-egg problem SLAM solves
SLAM stands for Simultaneous Localization and Mapping: the problem of figuring out where you are (localization) while also building a map of the environment around you (mapping) — at the same time, with neither one available in advance. This is genuinely circular: to know where you are, you'd normally check your position against a known map; to build a map, you'd normally need to know your own position as you record each observation. SLAM algorithms solve both problems jointly, using the structure of the problem to bootstrap each from the other as a device moves through an unknown space. It's the core technology behind robot navigation, autonomous vehicles, and AR devices that anchor virtual objects to real-world surfaces.
The building blocks: sensing, estimating motion, and mapping
A SLAM system typically combines three ingredients. Sensors provide raw observations of the environment — cameras, LiDAR, or depth sensors are common, often combined with an inertial measurement unit (IMU) that senses acceleration and rotation. Odometry (specifically visual odometry when derived from cameras) estimates how the device has moved between consecutive sensor readings by tracking how recognizable features in the scene shift between frames. Mapping accumulates observations, tagged with their estimated positions, into a persistent representation of the environment — which might be a point cloud, a grid of occupied/free cells, or a set of recognizable landmarks.
Drift: the problem that makes SLAM hard
Every individual motion estimate between two consecutive frames has some small error. Because each new position estimate builds on the previous one, these small errors accumulate over time — a phenomenon called drift. After navigating a long corridor and several turns, a SLAM system's belief about its own position can be meters away from the truth, even if each individual step was only slightly wrong. Left uncorrected, drift means the resulting map slowly warps and positions become unreliable the longer a device explores.
Note
Filter-based vs. graph-based SLAM
Classic SLAM implementations used probabilistic filters — notably the Extended Kalman Filter (EKF) — to maintain and update a running estimate of position and map uncertainty with each new observation. These work well for small, simple environments but scale poorly as the number of tracked landmarks grows, since the underlying math involves operations that get expensive with the map's size. Modern SLAM systems more commonly use graph-based (pose graph) optimization: each estimated position over time becomes a node in a graph, each motion estimate or loop closure becomes an edge encoding a relative constraint between nodes, and a global optimization step adjusts all nodes simultaneously to best satisfy every constraint at once. Graph-based methods handle loop closure corrections and large-scale maps considerably more gracefully.
Filter-based vs. graph-based SLAM
| Property | Filter-based (e.g. EKF-SLAM) | Graph-based (pose graph optimization) |
|---|---|---|
| Representation | Running probabilistic estimate updated incrementally | Graph of poses and constraints, optimized globally |
| Scaling with map size | Degrades as landmark count grows | Scales much better to large environments |
| Handling loop closure | Can be awkward to retroactively correct history | Naturally incorporates corrections across the whole graph |
| Common modern usage | Simpler systems, small-scale robotics | Most modern visual SLAM and AR tracking systems |
Note
What's next
SLAM ties together motion estimation, feature matching, and 3D map representations like point clouds into one continuously running system. Continue to point clouds and 3D vision if you haven't already, to see how the maps SLAM builds are often represented and processed in practice.
I build these systems professionally.
Whether it's a RAG pipeline, analytics migration, or AI workflow — let's talk.