LiDAR SLAM: how scan matching works internally
Atlasbot · 17/8/2026 · 11 min read
What is the article SLAM? calls the front-end "scan matching" — to match the current scan to the existing map. For the particular LiDAR, what does "matching" mean? This one opens up that mechanism at the algorithm level.
Key concepts
Each LiDAR scan yields a point cloud set of — coordinates of objects reflecting the return laser beam. Scan matching solves the problem: find rotation + translation (the correct Transform concept has been learned) such that when applying that transformation to the new scan, it fits as tightly as possible to the existing reference map/scan.
The two most common approaches: ICP (Iterative Closest Point) — point-coupling followed by fine-tuning; and Correlative Scan Matching — scan a hypothesis grid, selecting the best match hypothesis.
How it works
Find (R, t) such that: R × new scan + t ≈ reference map
The transformation (R, t) found is the estimation of the robot's position change between two scans — which is a scan matching "count" of position, without relying on odometry wheel (although odometry is often used as the initialization point for the algorithm to converge faster).
ICP is a classical, iterative scanning matching algorithm:
1. For each point in the new scan, find its NEAREST corresponding point in the reference scan
2. Compute the transform (R, t) minimizing the total distance between those point pairs
3. Apply (R, t) and repeat step 1 with the updated point positions
4. Stop when (R, t) converges (changes between iterations are small enough)
Finally: ICP assumes an initial approximation point pairing, then fine - tunes — like rotating two puzzle pieces until they fit together, without knowing exactly which piece fits which piece from the start. Cons: easy wrong convergence (fading into a true non-optimal position) if the initial point is too far from the correct solution — this is the reason it is always necessary to have a good initial guess (usually from odometry) before running the ICP.
Instead of point pairing followed by fine-tuning (often prone to local extreme jamming such as ICP), Correlative Scan Matching scans for a grid of possible(R, t) hypotheses over a range of searches, scoring each hypothesis by map-matching, selecting the highest-point hypothesis. Cartographer uses an optimization variant of this method — that trades higher computational costs (testing multiple hypotheses) for better avoidance of local extreme jamming than pure ICP.
Technical details
Formulas
The number of operations to perform each ICP loop with the number of points in the scan — directly affects the available front - end frequency:
Cost_per_ICP_iteration ≈ O(N × M)
(N = points in the new scan, M = points in the reference scan/map;
finding the nearest neighbor for each of N points requires checking M points, unless
an accelerating data structure such as a k-d tree is used, approaching O(N log M))
Correlative Scan Matching has a drastically different — cost ratio than the search space size (trial range (R,t)), without directly depending on the number of scan points in the same ICP - dependent manner:
Correlative_cost ≈ O(Hypotheses_tested) = O(search_range / grid_spacing)
Parameters
| Method | The Approach | Major risks |
|---|---|---|
| ICP | Match closest points, refine iterations | Local extreme jamming if initialized far from the correct solution |
| Correlative Scan Matching | Try the hypothetical grid, pick the highest point. | The computational cost is higher if the search is wide |
Practical applications
The article Select LiDAR stated that angle resolution affects small obstacle detection — it also directly affects the quality of scan matching: the thicker the spot density (the finer the angle resolution), the more data the algorithm has to find the correct joint transform, which is particularly important in environments with little apparent geometric specificity (long hallways, flat walls) — where scan matching is most easily disoriented because many locations along the hallways look geometrically "identical".
Practical example
import numpy as np
def icp_step(scan_new, scan_ref):
# Step 1: match nearest points (simplified; use a k-d tree in practice)
pairs = []
for p in scan_new:
dists = np.linalg.norm(scan_ref - p, axis=1)
nearest = scan_ref[np.argmin(dists)]
pairs.append((p, nearest))
# Step 2: compute centroids and find R,t minimizing error (simplified)
src = np.array([p[0] for p in pairs])
dst = np.array([p[1] for p in pairs])
src_mean, dst_mean = src.mean(axis=0), dst.mean(axis=0)
translation = dst_mean - src_mean
return translation # (omit rotation R to keep the example short)
scan_new = np.array([[1.0, 0.0], [1.0, 0.5], [1.2, 1.0]])
scan_ref = np.array([[1.1, 0.05], [1.05, 0.55], [1.25, 1.05]])
t = icp_step(scan_new, scan_ref)
print(f"Dich chuyen uoc luong: dx={t[0]:.3f}, dy={t[1]:.3f}")
Output:
Dich chuyen uoc luong: dx=0.083, dy=0.033
This is a simplified ICP loop (ignoring the R rotation for a neat example) — ICP real-world repeats several rounds, each updating the point position and then pairing, until the estimated shift is small enough (convergence).
Common mistakes
- Failing to provide a good initialization point for ICP— as stated in the Abstract section, ICP is prone to false convergence if starting too far from the correct solution; odometry should always be used as the initialization point, not running ICP "from zero".
- Using pure ICP in less geometrically characterized environments (long corridors)— is prone to false convergence due to the fact that many locations along corridors have similar scan shapes; Correlative Scan Matching (as used by Cartographer) is more tolerant of this situation.
- Using no k-d tree-accelerated data structure— as in the Formula section, the linear search O(N×M) is significantly slower than O(N log M) when the number of scan points is large.
- Setting the Correlative Scan Matching search range too wide — increases the linear computational cost by the size of the search space without commensurate improvement of the result quality if the robot moves slowly enough.
Conclusion
Scan matching — whether by ICP or Correlative Scan Matching — is the problem of finding the two point cloud LiDAR joint rotation and displacement, which is the specific mechanism behind the front-end of every SLAM system. The LiDAR angle resolution and the geometric characteristic density of the environment directly affect the result quality. The last article in the SLAM column, Mapping real-world , moves from algorithm theory to a practical map scanning workflow and common errors.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.