Loop Closure for Drift Correction
Every step drifts a little until you recognize a place you saw before. Loop closure snaps the whole path back into agreement at that reunion.
Why Does This Exist?
Visual odometry integrates motion, so error grows without bound: a percent drift becomes m after an m loop. Loop closure exists to stop that growth by detecting a revisit, measuring the accumulated error at the reunion, and distributing the correction backward along the path. Without it long SLAM maps bend and double walls.
This page covers detection plus verification. The correction math that follows is pose graph optimization; the systems that call both are ORB-SLAM and visual SLAM.
Think of It Like This
Realizing a hiking loop closed
You hike for hours counting steps, fairly sure the camp sits ahead. Then you spot your own boot print and a familiar bent tree: you walked a loop. You now know exactly how far your step count drifted and can rescale the whole morning.
Boot prints are bag-of-words matches and the rescale is the pose correction. The analogy stops at lookalikes: forests rarely duplicate while office corridors do, so visual similarity alone is not proof.
How It Actually Works
Each keyframe becomes a compact place descriptor such as a bag-of-words vector or a learned global embedding. Retrieval proposes candidates with high similarity outside the recent window, excluding the last s to avoid trivial matches. Verification then demands geometric proof: match descriptors across the pair, estimate a fundamental or perspective transform with RANSAC, and require at least inliers with mean reprojection under px. Only verified loops add a constraint edge between distant poses; the backend then optimizes the graph.
Worked numbers
An m office loop drifts m ( percent) before closing. Retrieval returns three candidates with similarities , , against threshold , keeping two. Geometric checks give inliers on the first and on the second, so only the first becomes an edge. After optimization the end error falls to m ( percent).
Code
def accept_loop(similarity: float, inliers: int) -> bool: return similarity >= 0.35 and inliers >= 40 # appearance plus geometry
print(accept_loop(0.46, 92)) # -> Trueprint(accept_loop(0.38, 7)) # -> FalseWatch Out For
Closing on lookalike corridors
Identical doors and repeated facades score high on appearance while geometry barely passes on a few coincidental matches. The symptom is a snapped map with folded floors. Require strong inlier counts plus temporal consistency across neighboring keyframes before adding the edge.
The Quick Version
- Loop closure detects revisits to bound otherwise endless drift.
- Place descriptors propose candidates; geometry with RANSAC disposes.
- Only verified loops become constraint edges in the pose graph.
- One good loop can cut meters of drift to decimeters.
- Recency exclusion avoids matching the current hallway to itself.
- Lookalike places are the main false-positive source to gate.