Pose-graph optimization is how a SLAM robot fixes its map after the fact: every place the robot has been becomes a node, every measured motion between two places becomes an edge, and a least-squares solver moves all the nodes at once until the edges agree as well as possible. It is what lets a single loop closure correct the drift in an entire trajectory.
Imagine pinning every spot the robot visited to a corkboard and tying neighbouring pins together with rubber bands, each band cut to the distance the robot thinks it travelled. When the robot recognises a place it saw long ago, you add one more band between the new pin and the old one. That band is too short or too long for the pins as they stand, so you let go: every pin shifts a little until all the bands are as relaxed as they can be. The pins where they settle are the corrected path, and the map is redrawn from them.
🎯 Quick challenge
A robot drives a long loop and then recognises its starting point. What does pose-graph optimization do with that recognition?
Pose-graph optimization is the step in SLAM (building a map while working out where the robot is in it) that turns a drifting, slightly wrong path into a consistent one. The robot's past positions become nodes in a graph, each measured movement between two positions becomes an edge, and a solver adjusts every position at once so the measurements agree as closely as possible. When the robot recognises a place it has seen before (a loop closure), one new edge is enough for the solver to correct the whole path.
It is the part of a SLAM system that does the correcting (often called the back-end), inside widely used systems such as slam_toolbox in ROS 2, Cartographer and ORB-SLAM2.
Start here: why a robot's path needs fixing
A robot that tracks its own motion with wheel odometry (estimating movement from how far the wheels turned) or scan matching makes a small error on every step. Each error is tiny, but they add up: after a long corridor and a few turns, the robot's idea of where it is can be a metre or more out, and a map drawn from that path bends and doubles back on itself.
Two facts make the fix possible:
The robot can remember every pose, not just the current one. Keep the whole path, and you can still correct the past.
Some measurements link poses that are far apart in time. When the robot returns to its start and recognises it, it learns "pose 400 is in the same place as pose 1". That single fact contradicts all the small errors accumulated in between.
Pose-graph optimization is the arithmetic that uses the second fact to repair the first: it finds the path that disagrees least with all the measurements together.
What it is: nodes, edges and confidence
Grisetti, Kümmerle, Stachniss and Burgard's widely cited tutorial puts the whole idea in one sentence: graph-based SLAM uses "a graph whose nodes correspond to the poses of the robot at different points in time and whose edges represent constraints between the poses" (Grisetti et al., 2010).
Nodes (poses). Each node is where the robot was at one moment: x, y and heading for a ground robot (a pose in SE(2)), or a full 3D position and orientation for a drone or handheld camera (SE(3)).
Edges (constraints). Each edge is a measured relative transformation between two poses: "from pose 4, pose 5 is 1.2 m ahead and turned 3° left". Edges come either from odometry between consecutive poses or "by aligning the observations acquired at the two robot locations" (Grisetti et al.), such as matching two laser scans.
Confidence (information matrix). Every edge carries a matrix Ω that says how much to trust it. A precise scan match gets a large Ω and pulls hard; noisy wheel odometry gets a small one and gives way easily.
Cartographer's documentation uses the same rubber-band picture: constraints "can intuitively be thought of as little ropes tying all nodes together", the optimizer "fastens those ropes altogether", and "the resulting net is called the 'pose graph'" (Cartographer ROS).
From sensor data to a corrected trajectory
The front-end depends on the sensor; the back-end only sees an abstract graph. A loop closure is one more edge, but solving the graph moves every pose in the loop.
How it works
1. Front-end and back-end
Graph-based SLAM splits into two jobs. Building the graph from raw measurements "is usually called front-end and it is heavily sensor dependent", while finding the best poses for that graph "is called back-end and relies on an abstract representation of the data which is sensor agnostic" (Grisetti et al.). Pose-graph optimization is the back-end. That is why the same solver libraries serve laser, camera and multi-sensor systems.
2. Write down how wrong each edge is
For an edge between poses i and j, the current guess of the poses predicts a relative transformation ẑ_ij. The measurement says z_ij. The difference is the error (for rotations, the difference is taken on the manifold, see step 5):
e_ij = z_ij − ẑ_ij(x_i, x_j)
The total cost adds up every edge's error, weighted by its confidence:
Minimising F is a maximum-likelihood estimate when the measurement noise is Gaussian: the most probable trajectory given everything the robot measured.
3. Linearise, solve, repeat
The relationship between poses involves rotations, so F is not a simple quadratic. Solvers start from an initial guess (usually the raw odometry path) and iterate:
Linearise each error around the current guess using its Jacobian (how the error changes when a pose moves slightly).
Build one linear system H·Δx = −b by adding a few small blocks per edge.
Solve for the correction Δx.
Update the poses and repeat until the corrections are tiny.
This is the Gauss–Newton method; Levenberg–Marquardt is a damped variant of the same loop, and Grisetti et al. name both as the standard solvers (Grisetti et al.). GTSAM's tutorial shows the loop in action: three poses start from a "deliberately inaccurate initial estimate" of (0.5, 0, 0.2), (2.3, 0.1, −0.2) and (4.1, 0.1, 0.1), and Levenberg–Marquardt returns them to (0, 0, 0), (2, 0, 0) and (4, 0, 0) within a tiny tolerance (GTSAM tutorial).
4. Why it is fast: sparsity
Each pose is linked to only a few others, so H is almost all zeros. Grisetti et al. note that H "is sparse by construction, having non-zeros between poses connected by a constraint", with a number of non-zero blocks equal to twice the number of constraints plus the number of nodes, which allows the system to be solved "by sparse Cholesky factorization" (a fast method for solving linear systems that are mostly zeros) (Grisetti et al.). The number of non-zero entries in H grows with the number of edges, not with the square of the number of poses.
5. Two details that trip people up
Fix one pose. Every error depends only on relative positions, so sliding or rotating the whole graph changes nothing and the system has no unique answer (this is called gauge freedom). The standard fix is to hold one pose (usually the first) still (Grisetti et al.). In GTSAM a prior factor on the first pose anchors it in the same way.
Treat rotations properly. Rotations are not ordinary vectors. Euler angles have singularities, and rotation matrices or quaternions have extra numbers that a naive update breaks. Grisetti et al. solve this by optimising "on a manifold": compute small corrections in a local flat space and apply them to the pose with a special ⊞ operator. In their 3D test on a simulated robot travelling over a sphere, Gauss–Newton with Euler angles diverged while the manifold version "converges to the right solution" (Grisetti et al.).
A worked example you can check by hand
Take a robot in a straight corridor, with positions along one axis. Pose x₀ is fixed at 0 m.
Edge
Measurement
Confidence
Odometry x₀ → x₁
moved 1.0 m
1
Odometry x₁ → x₂
moved 1.0 m
1
Scan match / loop closure x₀ → x₂
x₂ is 1.8 m from x₀
1
Odometry alone says x₂ = 2.0 m; the direct measurement says 1.8 m. Minimise (x₁ − 1)² + (x₂ − x₁ − 1)² + (x₂ − 1.8)². Setting both derivatives to zero gives x₁ = 0.933 m and x₂ = 1.867 m. The 0.2 m disagreement has been shared out: every edge is now off by 0.067 m, rather than one edge carrying all of it.
Now trust the direct measurement four times as much (confidence 4 instead of 1). The answer moves to x₁ = 0.911 m and x₂ = 1.822 m: the confident edge is off by only 0.022 m, and the two odometry edges each absorb 0.089 m. That is all Ω does: it decides who gives way.
A real pose graph does the same thing with thousands of 2D or 3D poses and rotations, which is why it needs the iterative solver above. GTSAM's PoseSLAM example is the next step up: five 2D poses driving round a square, with 2 m odometry edges (most with a 90° turn) plus one loop-closure edge from pose 5 back to pose 2 (GTSAM tutorial).
Where you'll see it
System
Sensors
How it uses a pose graph
Source
slam_toolbox (ROS 2)
2D lidar
Builds a pose graph from scan-matched laser scans; "If a loop closure is found, the pose graph is optimized"; solver plugins include Ceres; saved pose graphs can be reloaded to keep mapping
Local SLAM builds submaps; global SLAM finds loop-closure constraints and runs "a pose graph optimization" (which it also calls sparse pose adjustment) in background threads
If you have run lidar SLAM in ROS 2 and watched the map suddenly straighten after the robot returned to its start, you have watched a pose graph being re-solved.
Limits and common problems
One wrong loop closure can ruin the map. The solver trusts every edge it is given. If the front-end decides two different corridors are the same place, the optimizer will bend the map to make them meet. Data association, deciding which measurements belong together, is the front-end's job, and Grisetti et al. state that their back-end simply assumes "the given front-end provides consistent estimates" (Grisetti et al.). Real systems add checks before accepting a loop closure: Cartographer uses a branch-and-bound scan matcher with a minimum match score, and then handles remaining outliers with a Huber loss, so a bad edge pulls less hard than its squared error would suggest (Cartographer ROS).
It needs a reasonable starting guess. Gauss–Newton and Levenberg–Marquardt refine a guess by repeated local linearisation, which is why Grisetti et al. present the method for the case where "a good initial guess … of the robot's poses is known" (Grisetti et al.). In practice the starting guess is the odometry path, so very poor odometry makes the optimizer's job harder.
It forgets the landmarks. A pure pose graph keeps poses only; the raw measurements are replaced by edges that Grisetti et al. call "virtual measurements" (Grisetti et al.). That keeps it small, but it is an approximation; systems that need the most accurate result re-optimise poses and points together with bundle adjustment, as ORB-SLAM2 does after a loop closure.
It grows forever unless you prune it. Every new pose adds a node. slam_toolbox's experimental "true lifelong" mode removes nodes over time so that computation stays bounded (slam_toolbox).
Highest-accuracy visual reconstruction; costlier than a pose graph
Grisetti et al. draw the same line between filtering methods, which estimate the current state online, and smoothing methods, which "estimate the full trajectory of the robot from the full set of measurements" (Grisetti et al.). Pose-graph optimization is smoothing.
Going deeper
Incremental solvers. Re-solving the whole graph after every new pose is wasteful. iSAM, cited by Grisetti et al. as "an on-line version that exploits partial reorderings to compute the sparse factorization" (Grisetti et al.), updates the solution as poses arrive; GTSAM includes it (GTSAM tutorial).
Where it came from. Grisetti et al. credit Lu and Milios (1997) with the graph-based formulation and note that it took years to catch on because of "the comparably high complexity of solving the error minimization problem", until advances in sparse linear algebra made it fast (Grisetti et al.).
Uncertainty comes for free. At the solution, H approximates the information matrix of the whole trajectory, so its inverse gives the uncertainty of each pose. GTSAM's examples draw these as covariance ellipses after optimizing (GTSAM tutorial).
Multiple robots and sessions. The same graph can join trajectories from different runs or robots. Cartographer notes that global constraints "can also align different trajectories recorded by multiple robots" (Cartographer ROS), and slam_toolbox can merge serialized pose graphs from separate sessions (slam_toolbox).
Why it matters
Any robot that maps a building, a warehouse or a city has to cope with drift. Pose-graph optimization is the standard answer because it keeps the whole history, weighs every measurement by how much it deserves to be trusted, and fixes the past when new evidence arrives. Understanding it explains why a SLAM map jumps into place after a loop closure, why one bad loop closure is so damaging, and what the solvers inside slam_toolbox, Cartographer, g2o and GTSAM are actually doing.
Common questions
What is pose-graph optimization in simple terms?
The robot keeps a list of every place it has been and the measured movement between them. Because each movement measurement is slightly wrong, the places do not quite fit together. Pose-graph optimization moves all the places at once, by small amounts, until the measurements agree as well as possible. When the robot recognises somewhere it has been before, that extra measurement lets it correct the whole path.
What is the difference between a pose graph and a factor graph?
A pose graph only contains robot poses and the relative measurements between them. A factor graph is the general version: its variables can be poses, landmarks, velocities or sensor biases, and its factors can link any number of them. A GPS reading, for example, is a factor on a single pose. GTSAM's tutorial calls the pose-only case "the simplest instantiation of a SLAM problem", PoseSLAM (GTSAM tutorial).
Why does my SLAM map suddenly jump or bend after a loop closure?
That jump is pose-graph optimization working. Before the loop closure, drift had accumulated unnoticed; the loop-closure edge exposes it, and re-solving the graph spreads the correction over every pose in the loop, so the map redraws in a new shape. If the map bends into something clearly wrong instead, the usual cause is a false loop closure: two similar-looking places matched as one. Tighten the front-end's match threshold before tuning the optimizer.