Skip to content
AI360Xpert
Beta

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.

A recognized revisit pulls the drifted path back onto the mapped start
A recognized revisit pulls the drifted path back onto the mapped start

Why Does This Exist?

Visual odometry integrates motion, so error grows without bound: a 11 percent drift becomes 88 m after an 800800 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 3030 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 4040 inliers with mean reprojection under 22 px. Only verified loops add a constraint edge between distant poses; the backend then optimizes the graph.

Worked numbers

An 800800 m office loop drifts 88 m (11 percent) before closing. Retrieval returns three candidates with similarities 0.460.46, 0.380.38, 0.310.31 against threshold 0.350.35, keeping two. Geometric checks give 9292 inliers on the first and 77 on the second, so only the first becomes an edge. After optimization the end error falls to 0.50.5 m (0.060.06 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))  # -> False

Watch 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.