Skip to the lesson
FixTheRobot Explore Robotics / Localization & SLAM / M3 Mapping and State Estimation / M3-T5

Localization & SLAM · Theory · M3

M3-T5 — ICP Fundamentals

Alternate between guessing which points correspond and solving exactly for the best motion given the guess.

  • Lesson 5 of 8
  • Module 3: Mapping and State Estimation
  • Theory
  • About 8 minutes to read

ICP, the Iterative Closest Point algorithm, is the workhorse of LiDAR odometry. It is short enough to write in twenty lines, and it hides two important lessons: how a hard problem (unknown correspondences) is solved by alternating with an easy one (known correspondences), and why that alternation only finds the nearest answer.

Learning objectives

After this lesson, you should be able to:

  • Write the point-to-point ICP loop and state its stopping criteria.
  • Derive the closed-form rigid transform for known correspondences (centroids and an SVD or atan2 step).
  • Explain why ICP converges to a local minimum and what determines its basin of convergence.
  • Name common variants (point-to-line, trimmed, robust, generalised) and what each fixes.

The problem and the intuition

Imagine two tracings of the same floor plan on transparent sheets, one a little shifted and rotated. You cannot tell which dot matches which. A sensible strategy: pretend that every dot on your sheet corresponds to the nearest dot on the other, find the single slide-and-turn that best fits those pairs, apply it, and repeat. After the move, the nearest dots are better pairs than before. ICP does exactly this: guess matches, fix motion, repeat.

If the correspondences were known, the problem would be easy and exact. ICP replaces the unknown matches by the nearest neighbours and improves both together.

ICP has a basin of convergenceA plot of the fraction of runs that converge to the correct alignment against the initial rotation error. It is near one up to 30 degrees and falls to near zero beyond 70 degrees.015304560759000.250.50.751initial rotation error (degrees)converged (fraction) Typical shape (indoor scans, point-to-point ICP). Good start: converges.Large error: the nearest points belongto the wrong structures, and ICP locks onto them. Exact numbers depend on the scene.
ICP only converges from starting guesses close enough to the truth. The “basin of convergence” depends on the geometry of the scene.

The algorithm: point-to-point ICP

Problem. Given a source point set P = {pi} and a target set Q = {qj}, find the rotation R and translation t that minimise the sum of squared distances between each transformed source point and its corresponding target point.

Assumptions. The two sets sample the same surfaces; they overlap substantially; the initial alignment is within the basin of convergence; noise is small and there are few outliers.

The closed-form step for known correspondences

For pairs (pi, qi), minimise Σ |R pi + t − qi|². The translation follows from the centroids and the rotation from the centred points. In 2D, with p̃i = pi − p̄ and q̃i = qi − q̄:

2D closed-form rigid alignment
θ=atan2(∑(p~x q~y−p~y q~x), ∑(p~x q~x+p~y q~y))\theta =\mathrm{atan}2(\sum (\tilde{p}_{x}\,\tilde{q}_{y}-\tilde{p}_{y}\,\tilde{q}_{x}),\,\sum (\tilde{p}_{x}\,\tilde{q}_{x}+\tilde{p}_{y}\,\tilde{q}_{y}))
t=qˉ−R(θ) pˉt=\bar{q}-R(\theta )\,\bar{p}

In 3D the same result comes from the SVD of the covariance H = Σ p̃i q̃iᵀ = U Σ Vᵀ: R = V diag(1, 1, det(V Uᵀ)) Uᵀ and t = q̄ − R p̄. The determinant factor prevents a reflection (Arun, Huang and Blostein, 1987; Umeyama, 1991).

p̄, q̄
centroids (means) of the paired source and target points.
p̃, q̃
points with their centroid subtracted.
H
the 3×3 (or 2×2) cross-covariance of the centred pairs.
det
determinant; +1 for a rotation, −1 for a reflection.

Pipeline

  1. Initialise the transform T with the best available guess (odometry), or the identity.
  2. Transform the source points: p′i = T pi.
  3. Match: for each p′i find its nearest neighbour qi in the target (use a k-d tree). Optionally discard pairs with distance above a threshold.
  4. Solve: compute the closed-form R, t for these pairs and compose it with the current T.
  5. Check convergence: stop when the change in transform is below a tolerance (for example 1e-4 m and 1e-4 rad), the mean error stops decreasing, or a maximum number of iterations (20–50) is reached.

Properties

  • Monotonic. Each iteration cannot increase the mean squared distance, so ICP always converges to some local minimum.
  • Local. The nearest-neighbour correspondences are only right when the scans already almost overlap. With a large initial error, the correspondences are wrong and the minimum reached may be a different alignment (a wall matched to another wall).
  • Slow near the end for point-to-point matching on flat walls (the points can slide along the surface). Point-to-line and point-to-plane distances converge much faster.
  • Cost. Nearest-neighbour search dominates: O(N log M) per iteration with a k-d tree.

Variants and what they fix

ICP variants
VariantChangeFixes
Point-to-line / point-to-plane (Chen and Medioni, 1992)Minimise distance along the surface normalSlow sliding along walls; faster, more accurate
Trimmed ICP (Chetverikov et al., 2002)Use only the best fraction (for example 80%) of the pairsPartial overlap and outliers
Robust loss (Huber, Cauchy)Down-weight large residualsDynamic objects, outliers
Generalised ICP (Segal et al., 2009)Plane-to-plane with local covariancesNoisy normals; unifies point-to-point and point-to-plane
Multi-resolution / coarse-to-fineMatch downsampled data firstLarger basin, speed

A worked example: three points, one exact step

Source points P = (0, 0), (1, 0), (0, 1). The target is P rotated by 30° and translated by (0.5, 0.2): Q = (0.5, 0.2), (1.366, 0.7), (0.0, 1.066). Assume the correspondences are known.

  1. Centroids. p̄ = (0.333, 0.333). q̄ = (0.622, 0.655).
  2. Centred points. p̃ = (−0.333, −0.333), (0.667, −0.333), (−0.333, 0.667). q̃ = (−0.122, −0.455), (0.744, 0.045), (−0.622, 0.411).
  3. Sums. Σ dot = Σ(p̃ₓq̃ₓ + p̃yq̃y) = 1.155 and Σ cross = Σ(p̃ₓq̃y − p̃yq̃ₓ) = 0.667. θ = atan2(0.667, 1.155) = 30.0°.
  4. Translation. t = q̄ − R(30°) p̄ = (0.622, 0.655) − (0.333 cos30° − 0.333 sin30°, 0.333 sin30° + 0.333 cos30°) = (0.622, 0.655) − (0.122, 0.455) = (0.5, 0.2). The exact transform is recovered in one step because the correspondences were right.
  5. With unknown correspondences, ICP would pair each source point with its nearest target point. If the true motion is small (a few centimetres, a few degrees), most pairs are right and a few iterations converge. If the rotation were 90°, the nearest neighbour of (1, 0) rotated might be (0, 1)’s image: a wrong pair, and the first step moves the wrong way. The next iteration pairs again, but now from a worse position.

This is why the lab asks you to first run ICP on a good start and then to find how far you can push it before it fails.

Engineering implications and limitations

Engineering implications

  • Provide a good initial guess from wheel odometry or an IMU. Even a rough guess within a few degrees and tens of centimetres is usually enough for a room-scale scan.
  • Downsample large clouds with a voxel or random filter: nearest-neighbour search is the cost.
  • Reject outliers by distance (a gate that shrinks over the iterations), trimming, or a robust loss.
  • Monitor the result: final mean error, inlier ratio and the movement from the guess. Refuse results with a poor score and fall back to odometry.
  • Check degeneracy (M3-T4): ICP in a corridor converges happily to a pose that is wrong along the corridor.
  • Use point-to-plane in 3D when normals are available; it is the default in most LiDAR odometry pipelines (LOAM, LIO-SAM and others in Module 5).

Limits

ICP is a local method: no number of iterations will rescue a bad initial guess. It is sensitive to the sampling pattern (points on a wall seen from different distances have different densities), to outliers and to partial overlap. It gives a point estimate with no uncertainty: covariance has to be estimated separately, for example from the Hessian of the final objective. For global alignment use features, correlative matching or learned descriptors (Modules 5 and 8).

Common misconceptions

“ICP finds the best alignment.”

It finds the best local alignment reachable from the starting guess by following the nearest neighbours.

“More iterations always help.”

ICP converges monotonically to a local minimum. After that, more iterations change nothing.

“ICP needs known correspondences.”

It estimates correspondences by nearest neighbour; the closed-form step uses them, then the next iteration refines them.

“The rotation can be averaged from point angles.”

The rotation comes from the cross-covariance of the centred points. Averaging angles misbehaves at the wrap and ignores point weighting.

Engineering takeaways

  1. ICP alternates between nearest-neighbour correspondences and the closed-form rigid transform for those pairs.
  2. The closed form uses centroids for translation and atan2 (2D) or SVD (3D) of the centred cross-covariance for rotation.
  3. It converges monotonically to a local minimum, so the starting guess decides the outcome.
  4. Point-to-line or point-to-plane, trimming and robust losses fix slow convergence and outliers.
  5. Always check the quality of the final match and the geometry (degeneracy) before using it.

References and further reading

Established fundamentals. Learned registration (Module 8) is an active research area.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

Why can the closed-form step recover the exact transform in one iteration in the worked example, but ICP needs several iterations on real scans?

Explanation

In the example the correspondences are known and exact, so the closed form is the global optimum for those pairs. On real scans the correspondences are the nearest neighbours, which are only approximately right; each iteration improves the pairing a little, and the pairing and the transform are refined together.

Question 2

An ICP run starts 70° off and ends with a low mean error but a visibly wrong map. How can a low error be “wrong”?

Explanation

The final alignment matched the scan to the wrong structures (for example one wall to another similar wall) and fits them well. The mean distance only measures how well the paired points line up, not whether the pairing is the true one. A check against the odometry guess or the overlap with other evidence is needed.

Question 3

What does trimming (keeping only the closest 80% of pairs) protect against, and what is the risk if the overlap really is smaller than 80%?

Explanation

It protects against outliers and partial overlap: points with no counterpart are excluded from the fit. If the true overlap is smaller than the kept fraction, the trimmed set still contains wrong pairs, and the estimate is biased, so the fraction should adapt to the overlap or be estimated.

What’s next

ICP gives a registration; the next lessons use it inside filters. First, the problem of estimating the robot and the map together with a Bayes filter.

Practice this lesson

Diagnose Scan-Matching Failure

ICP converges to the wrong alignment: diagnose initial guess, outliers and geometry degeneracy and repair them.

Next lesson

M3-T6 — Filtering-Based SLAM

State SLAM as recursive filtering over a joint pose-and-map state and explain why it scales poorly.

Nothing below is required to finish this lesson.