Pose Graph Optimization (PGO) relies on iterative, non-linear least squares optimization to correct accumulated drift in a robot's trajectory. However, the success of this optimization hinges entirely on the quality of the constraints (edges).
1. Loop Closure
1.1 Scan Context
Instead of doing heavy statistical math, Scan Context compresses the 3D point cloud into a lightweight 2.5D image matrix based on a bird's-eye view (BEV) projection.
The Algorithm:
3. The Matrix: This results in an N_r \times N_s matrix. We have successfully turned a massive 3D point cloud into a tiny grayscale image, where the pixel intensity represents the maximum height of the environment at that specific distance and angle.

1.2 Fast Nearest Neighbor Search (KD-Trees \& Ring Keys)
This vector is completely rotation-invariant by default. The algorithm uses a fast KD-Tree to search the historical database for Ring Keys that are close to the current one. Once the KD-Tree returns a few likely candidates, the algorithm performs the full matrix comparison to verify the match. If the Scan Context distance score d falls below a strict threshold, we have found a loop!
2. Robust Kernels
Here is a breakdown of the two common robust kernels used to handle loop closure outliers, along with their mathematical properties. Let δ be a tunable threshold parameter.
2.1 Huber Kernel
The Huber kernel behaves exactly like a standard least-squares function when the error is small. Once the error exceeds the threshold δ, it switches to a linear penalty.

It is a good default choice but might not be aggressive enough for highly corrupted loop closures.
2.2 Cauchy Kernel
The Cauchy kernel is even more aggressive. While Huber switches to a linear penalty, Cauchy forces the penalty to completely flatten out (asymptote) for large errors. This means a wildly incorrect LiDAR match will exert almost no pull on the optimization graph, effectively ignoring the false positive.

Summary
Because perceptual aliasing can introduce false positive constraints that would otherwise destroy a standard least-squares graph, Robust Kernels serve as a critical mathematical fail-safe. By applying non-linear loss functions like Huber (which scales linearly) or Cauchy (which asymptotes), the optimizer suppresses the quadratic penalty of extreme outliers. This ensures the system trusts the small variations of natural sensor noise while safely ignoring the massive errors of incorrect loop closures, preserving the structural integrity of the final map.