Robots and robotics
What is SLAM in robotics?
A robot dropped into a building it's never seen needs a map to know where it is, and needs to know where it is to draw the map. SLAM is how it does both at once.
SLAM (simultaneous localization and mapping) is how a robot builds a map of an unknown place while estimating its own position on that map. It tracks its motion with wheels, an IMU or a camera, adds what its lidar or camera sees to a growing map, and keeps both estimates tied together. When it recognizes a place it's visited before, called loop closure, it corrects the drift that built up along the whole path.
What SLAM means, and why it sounds impossible
Picture yourself in a dark, unfamiliar office building with a flashlight and a notepad. You want a floor plan. To draw a wall in the right spot, you need to know where you're standing. But the only way to know where you're standing is to look at the walls you've already drawn. Each question needs the answer to the other one.
That's the problem a robot faces in any place nobody has mapped for it, and it's called SLAM: simultaneous localization and mapping. Localization means working out where the robot is. Mapping means building a model of the surroundings. Hugh Durrant-Whyte and Tim Bailey's tutorial at the University of Sydney frames it as the question of whether a robot placed at an unknown location in an unknown environment can incrementally build a consistent map of this environment while simultaneously determining its location within this map. The 2016 survey by Cesar Cadena and seven coauthors in IEEE Transactions on Robotics gives the shorter version: the concurrent construction of a model of the environment (the map), and the estimation of the state of the robot moving within it.
The robot's state is usually its pose, meaning its position plus which way it's facing. The map can be a list of landmarks (distinct things it can spot again, like a door frame or a corner), a grid of cells marked free or occupied, or a 3D cloud of points.
The idea is older than most people expect. Durrant-Whyte and Bailey trace it to the 1986 IEEE Robotics and Automation Conference in San Francisco, and say the acronym itself was first presented in a survey paper at the 1995 International Symposium on Robotics Research. For a while researchers thought the joint problem wouldn't converge, so they split it into separate mapping and localization problems. The breakthrough was realizing that solving them together, as one estimation problem, does converge.
How SLAM works, one step at a time
Every SLAM system repeats the same short loop while the robot moves:
- Predict. Use the motion sensors to guess the new pose. That's odometry: adding up wheel turns, or the rotation an IMU (inertial measurement unit, a chip with a gyroscope and an accelerometer) reports. The guess gets a little less certain with every step.
- Observe. Take a lidar scan or a camera frame and pick out features: corners, edges, distinctive patches of image.
- Associate. Decide which of those features are things already on the map and which are new. This is called data association, and it's where most failures start.
- Update. Use the matched features to correct both the pose and the positions of the landmarks, then add the new features to the map.
Cadena's survey splits a real system into two halves. The front-end turns raw sensor data into something an estimator can use: it extracts features and does the data association, both short-term (tracking the same point from one frame to the next) and long-term (recognizing an old place). The back-end does the math, taking all those matched measurements and finding the poses and map that best explain them.
Why the map gets better even when the robot is lost
Here's the part that makes SLAM work. When the robot sees two landmarks from the same spot, any error in where it thinks it's standing shifts both landmarks by the same amount. So the robot might be unsure where either landmark is in absolute terms, but it can be quite sure how far apart they are. Durrant-Whyte and Bailey put it this way: the relative location between any two landmarks may be known with high accuracy, even when the absolute location of a landmark is quite uncertain.
Those links between landmarks only get stronger with more observations. The tutorial compares the map to a network of springs connecting every landmark, which get stiffer each time the robot looks around. Correct one landmark and the correction travels through the springs to its neighbors, even ones the robot can't currently see. The authors say that in the limit, the robot's accuracy relative to the map is bounded only by the quality of the map and the sensor.
Loop closure: how SLAM cancels drift, with a worked example
Odometry alone drifts. Small errors in every step add up and nothing pulls them back. Cadena's survey notes that pose estimates from early wheel odometry quickly drifts, making the estimate unusable after few meters. Modern odometry that combines a camera and an IMU is far better, under 0.5% of the distance traveled by the survey's figure, but that's still up to a meter of error after a 200 m walk, and it never shrinks on its own.
Loop closure is what fixes it. When the robot comes back to somewhere it's been and recognizes it, it learns two things at once: where it really is, and how much error it piled up on the way around. The survey describes a robot that never closes loops as seeing the world as an “infinite corridor”, a path that keeps exploring new territory forever. One recognized loop tells it the corridor bends back on itself.
Worked example: closing a loop around a 10 m square
A robot drives a 10 m square: east, north, west, south, back to where it started. Its odometry records each leg with a little error (in meters, as east and north components):
| Leg | True motion | What odometry recorded |
|---|---|---|
| 1 | (10, 0) | (10.3, 0.1) |
| 2 | (0, 10) | (0.2, 10.4) |
| 3 | (−10, 0) | (−9.9, 0.3) |
| 4 | (0, −10) | (−0.1, −10.2) |
Add up the recorded legs and odometry thinks the robot finished at (0.5, 0.6), about 0.78 m from the start. Then the lidar scan at the end matches the scan taken at the very beginning. That's a loop closure, and it says the true offset between those two poses is (0, 0).
The back-end now has a puzzle: four odometry measurements that add up to (0.5, 0.6), and one loop closure that says they should add up to zero. If it trusts each leg equally and treats the loop closure as exact, the least-squares answer is to spread the mismatch evenly. Each leg gets corrected by (0.5, 0.6) ÷ 4 = (0.125, 0.15). Leg 1 becomes (10.175, −0.05), and so on.
| Corner | True position | Odometry only | Error | After loop closure | Error |
|---|---|---|---|---|---|
| 1 | (10, 0) | (10.3, 0.1) | 0.32 m | (10.18, −0.05) | 0.18 m |
| 2 | (10, 10) | (10.5, 10.5) | 0.71 m | (10.25, 10.2) | 0.32 m |
| 3 | (0, 10) | (0.6, 10.8) | 1.00 m | (0.23, 10.35) | 0.42 m |
| Back at start | (0, 0) | (0.5, 0.6) | 0.78 m | (0, 0) | 0 m |
One recognized place cut the worst error from 1.00 m to 0.42 m, and it fixed corners the robot passed long before it got home. That's the “correct the whole path, not just the last step” property that separates SLAM from odometry.
Real systems do the same thing with rotation included, which makes the math nonlinear, and they weight each measurement by how much they trust it instead of trusting every leg equally. A loop closure is also never treated as perfect, since it's a measurement too. The shape of the answer stays the same, though: the error gets shared out along the loop.
EKF-SLAM vs graph SLAM: how the back-end does the math
The first practical SLAM systems used an extended Kalman filter (EKF), the same predict-and-correct filter robots use for tracking their position on a known map, stretched to hold the map too. The filter's state is one long list: the robot's pose plus the position of every landmark. It also keeps a table, the covariance matrix, recording how uncertain each number is and how each one's error is linked to every other's.
That table is the problem. Durrant-Whyte and Bailey note that this approach needs a state with one entry per landmark and computation scaling as the square of the number of landmarks. Work out what that means on a flat floor. The robot's pose is 3 numbers (x, y, heading) and each landmark adds 2. With 100 landmarks the state has 203 numbers and the table has 203 × 203 = 41,209 entries. With 1,000 landmarks it's 2,003 × 2,003, just over 4 million entries, and every update touches all of them. A large building can easily have more than 1,000 corners. Clever EKF variants push this limit further, but the basic version hits a wall fast.
Most modern systems instead treat SLAM as one big fitting problem, which Cadena's survey calls the de-facto standard formulation. Every pose and landmark is a node in a graph. Every measurement, whether it's an odometry step, a landmark sighting or a loop closure, is a link that says how two nodes should sit relative to each other. The back-end then finds the arrangement that disagrees least with all the links, exactly as in the square example above. This goes by names like graph SLAM, pose graph optimization and factor graph optimization.
The trick that makes it fast is that the graph is sparse: each pose links to only a handful of others. According to the survey, open-source libraries like GTSAM, g2o and Ceres can solve problems with tens of thousands of variables in a few seconds. It also says this approach has proven more accurate and efficient than the original filtering methods.
Lidar SLAM vs visual SLAM: what changes with the sensor
The back-end math barely cares what sensor you use. The front-end cares a lot, because a feature means something different in a laser scan than in a photo.
Lidar SLAM uses a laser scanner that measures the distance to surfaces all around the robot. Matching one scan against the map works like sliding a tracing of the walls over a floor plan until it lines up. Google's Cartographer is a well-known example. Its documentation describes it as a system that provides real-time simultaneous localization and mapping in 2D and 3D. In the paper behind it, Wolfgang Hess and colleagues at Google report that their portable lidar mapping system achieves real-time mapping and loop closure at a 5 cm resolution, using it to capture floor plans of buildings.
Visual SLAM uses cameras. It tracks distinctive points across frames and works out both the camera's motion and the points' 3D positions. ORB-SLAM is one of the best-known open-source systems. Raúl Mur-Artal and colleagues describe it as a feature-based monocular SLAM system that operates in real time, using the same features for tracking, mapping and loop closing. Its successor, ORB-SLAM3, adds stereo and depth cameras and IMU data. Its authors report that the stereo-plus-IMU mode averages 3.6 cm of error on the EuRoC drone dataset and 9 mm under quick handheld motion in the room sequences of the TUM-VI dataset.
| Lidar SLAM | Visual SLAM | |
|---|---|---|
| What it measures | Distance to surfaces, directly | Brightness and color; depth has to be worked out |
| Lighting | Works in the dark | Needs light and texture to see features |
| Recognizing a place | Hard when two rooms have the same shape | Easier, since a poster or a paint color tells rooms apart |
| Scale from one sensor | Known, since it measures meters | Unknown with one camera; needs a second camera, depth or an IMU |
| Cost and size | Usually bulkier and pricier | Cameras are small and cheap |
Two rows need a word. The place-recognition row comes from Cadena's survey, which gives the example that two rooms may look identical for a 2D laser scanner while a camera can tell them apart by how they look. The scale row is plain geometry: one photo can't tell a toy car up close from a real car far away, so a single camera learns the shape of a scene but not its size until something else supplies a known distance. In practice many robots combine sensors, and SLAM systems happily take lidar, cameras, wheels and IMUs all at once.
Where SLAM is used, and when a robot doesn't need it
SLAM matters most anywhere a robot arrives with no map and no GPS. Cadena's survey ties its popularity to indoor robots, since indoor operation rules out the use of GPS to bound the localization error. It names the uses directly: mapping a 2D indoor space with wheel encoders and a laser scanner, which it calls largely solved at better than 10 cm accuracy (with the Kuka Navigation Solution as an industrial example), plus vision-based SLAM on slow robots such as Mars rovers and domestic robots. It also points to jobs where the map is the whole point: exploring a place and reporting a map back to a person, or inspecting a building or bridge, where a consistent 3D model is required. Cartographer's floor-plan mapping is the exploring-and-reporting kind.
A lot of robots don't need SLAM at all. The same survey says that when landmark positions are known in advance, like beacons on a factory floor, or when the robot has GPS, SLAM may not be required. A common pattern sits in between: run SLAM once to build a map of a warehouse, save it, and from then on just localize against the saved map.
Is SLAM solved?
Partly. The survey's answer depends on the robot, the place and the accuracy you need. A slow wheeled robot in an office with a laser scanner is in good shape. Fast motion, crowds of moving people, big seasonal changes outdoors, or murky water are still open research. Durrant-Whyte and Bailey made the same split back in their tutorial, calling SLAM solved at a theoretical and conceptual level while substantial issues remain in building practical, more general systems.
Where beginners go wrong about SLAM
- "SLAM is one algorithm." It's a problem, not a method. EKF-SLAM, particle-filter SLAM like FastSLAM, and graph SLAM are different answers to it, and Cartographer and ORB-SLAM are full systems built on those answers.
- "A wrong loop closure is just a bit of noise." It's much worse. Two corridors that look alike can fool the front-end into thinking the robot is somewhere it isn't, which Cadena's survey calls perceptual aliasing. The survey warns that wrong loop closures can severely corrupt the quality of the estimate, because the back-end bends the whole map to make the false match fit. That's why systems verify a loop closure before accepting it.
- "Once it's mapped, it's mapped." Most SLAM systems assume the world holds still while the robot moves through it. The survey calls this the static world assumption, and says it holds for a single run in a small space as long as nothing moves around much. People walk past, chairs move and shelves get restocked, so long-running robots have to notice change and update the map.
- "Better odometry means you don't need SLAM." Good visual-inertial odometry drifts slowly, but it still drifts and never recovers. The survey's own framing is that without loop closures, SLAM reduces to odometry.
- "More landmarks are always better." For accuracy, more good landmarks help. For an EKF, every landmark makes each update cost more, growing with the square of the count. That's one of the big reasons the field moved to sparse graph methods.
Common questions
What does SLAM stand for?
Simultaneous localization and mapping. The robot works out where it is (localization) and builds a model of its surroundings (mapping) at the same time, each one feeding the other.
Do robot vacuums use SLAM?
Robot vacuums that build a map of your home are doing a form of SLAM, usually with a small lidar or a camera. Cadena's 2016 survey lists vision-based SLAM on domestic robots among the areas it considers mature.
What's the difference between SLAM and odometry?
Odometry adds up the robot's own motion, so its error only grows. SLAM also builds a map and recognizes places it's seen before, which lets it correct that accumulated error. Without loop closures, SLAM reduces to odometry.
What is a loop closure in SLAM?
A loop closure is the moment a robot recognizes a place it has already mapped. The mismatch between where odometry thinks the robot is and where the map says it must be reveals the drift, which the system then spreads back along the whole path.
Learn it properly
Physical AI & Robotics Engineering has a full lesson on SLAM, right after lessons on state estimation with the Kalman filter and on sensor fusion, plus depth and 3D vision and motion planning. It's the advanced robotics path, so start with Robotics Foundations if you've never worked with a robot.
See Physical AI & Robotics Engineering in the Toorova catalog →
Sources
- Past, Present, and Future of Simultaneous Localization And Mapping: Towards the Robust-Perception Age (Cadena et al., 2016) · IEEE Transactions on Robotics (arXiv abstract)
- Past, Present, and Future of Simultaneous Localization And Mapping (Cadena et al., full text) · IEEE Transactions on Robotics (arXiv PDF)
- Simultaneous Localisation and Mapping (SLAM): Part I The Essential Algorithms (Durrant-Whyte & Bailey) · IEEE Robotics & Automation Magazine, 2006 (UC Berkeley course reading)
- Real-Time Loop Closure in 2D LIDAR SLAM (Hess, Kohler, Rapp & Andor, ICRA 2016) · Google Research
- Cartographer documentation · Cartographer project
- ORB-SLAM: a Versatile and Accurate Monocular SLAM System (Mur-Artal, Montiel & Tardós, 2015) · IEEE Transactions on Robotics (arXiv)
- ORB-SLAM3: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map SLAM (Campos et al.) · IEEE Transactions on Robotics (arXiv)
Read next
How does a robot know where it is?
Robots count wheel turns, read an IMU and check GPS or landmarks, then a filter weighs each one by how far it can be trusted. Here's how, with worked numbers.
What is a Kalman filter, in plain English?
A Kalman filter blends a prediction with a noisy measurement, weighting each by how uncertain it is. Here's how it works, with a robot example worked in numbers.
What is a PID controller? P, I and D explained simply
A PID controller sets its output from the error now, the error added up over time, and how fast the error is changing. Here's each part, with worked numbers.