JOVANA
Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Drift, Wrong Matches, and Loop Closure

Small errors pile up into a bent map; recognizing a place you have been before snaps it back into shape.

Why a straight hallway comes out crooked

Imagine walking through a building with your eyes closed, counting your steps and trusting your sense of turning. Each step you are off by a hair; each turn you misjudge by a degree or two. None of those mistakes feels big. But they never cancel out — they add up. After a hundred meters your guess about where you are can be off by several meters, and worse, twisted at the wrong angle. A robot building a map of an unknown place faces exactly this. In SLAM, the robot estimates its own path and draws the world at the same time, using only its motion and its sensors.

The step-counting estimate of motion has a name: odometry. It is wonderfully smooth from one instant to the next, but it has no memory of absolute truth, so its small errors quietly accumulate. We call this slow buildup drift. Drift is not a bug you can fix with a better wheel or a cleaner sensor — it is the unavoidable price of estimating motion one piece at a time.

Loop closure: "wait, I have been here before"

Here is the beautiful idea that rescues the map. When the robot comes back to a spot it visited earlier and *recognizes* it, that recognition is a piece of hard information drift cannot argue with: these two moments, far apart in the journey, happened at the same physical place. Acting on that recognition is called loop closure.

To use it, the robot adds a constraint — a tie that says "the pose I have now and the pose I had back then must line up." If you picture the whole trajectory as a chain of poses connected by springs, odometry gives you the springs between neighbors. A loop closure adds one long spring that reaches across the chain and pulls the loose end back to where it truly belongs. This is the heart of pose-graph optimization: treat every pose as a node, every measurement as a spring, and let the springs settle into the shape that disagrees with everything as little as possible.

How does the robot confirm it is truly the same place and not just somewhere similar? It tries to align its current sensor view against the earlier one — overlaying two LiDAR scans with ICP-based scan matching, or matching the same visual landmarks across two camera frames. A good geometric fit turns a hopeful guess into a trustworthy constraint.

The danger of a confident wrong match

Before the robot can add a loop closure, it has to find the candidate: out of everywhere it has been, which old view looks like the one in front of it now? That search is place recognition — boiling each scene down to a compact signature and asking the map "have I seen anything like this?" When it works, it spots a returned-to corridor in milliseconds.

But the world is full of look-alikes. Two different offices on two different floors can have the identical desk, the identical door, the identical blank wall. This is perceptual aliasing: distinct places that sensors cannot tell apart. If place recognition takes the bait and declares a match that is false, the robot welds together two parts of the map that were never the same place.

Deciding which observation belongs to which place — and refusing the wrong pairings — is the data-association problem, and loop closure is where it bites hardest. A single false closure is far more destructive than drift. Drift bends the map gently; a wrong constraint yanks a whole wing of the building on top of another, and the optimizer, trusting the bad spring, happily ruins a map that was nearly correct.

One good closure heals the whole path

Now the payoff. Suppose the robot has drifted two meters over a long loop, then correctly recognizes its starting point. The loop closure says the two ends must coincide — but the drift was not all earned at the finish. It seeped in evenly across the whole journey. So the optimizer does not just snap the endpoint home; it spreads the correction backward across every pose in the loop, nudging each one a little. The error gets shared out, and the spiral relaxes into a clean ring.

Because the poses and the map are tied together, fixing the path fixes the world too. Every wall, doorway, and landmark the robot placed along that loop slides into a more consistent position. A corridor that had been drawn as two slightly offset copies merges into one. The single constraint paid for itself many times over — this is the global correction that makes large-scale mapping possible at all.

Before closure (open loop, drift accumulating):

  start *--*--*--*--*--*--*  end   <- should be back at start,
         (poses drift outward)         but ends 2 m away

Add one loop-closure spring  ( end  ===  start ):

  start *--*--*--*--*--*--* end
    ^___________________________|   correction pulled across ALL poses

After optimization (error shared out, ring closes):

      *--*--*
     /        \
    *          *      one clean loop; map de-duplicated
     \        /
      *--*--*
A loop-closure constraint distributes its correction backward over every pose, not just the endpoint.