The problem, and what came before ICP

The idea

A robot, a 3D scanner or a self-driving car sees the world as clouds of points, one cloud per moment. To build a map, or just to know how it moved, it has to fit each new cloud onto the last one. That fitting is called registration. Read the four cards in order: three earlier approaches, their limitations, and the idea behind ICP.

As stored: two scans of one room, each drawn around the robot that took it.
Registered: orange turned and shifted onto teal. That turn and shift is how the robot moved (arrow).
A 3D map of office desks built from Kinect depth frames, seen from above and behind, with the camera's path drawn as an orange line.Real data
What registration builds: 149 Kinect depth frames from 19.7 s of the TUM desk sequence, each fitted onto the one before by ICP (25 of them drawn). Orange: the camera's path, worked out from the fits alone.
1980s1. Markers and hand-picked matches
112233
The numbered markers appear in both scans, so the pairs (dashed) are known in advance. The exact formula then gives the turn and shift.
How: put targets in the scene, or have a person click the same spots in both scans. With matches known, an exact formula gives the turn and shift (Faugeras & Hebert 1986; Arun, Huang & Blostein 1987; Horn 1987).Drawback: somebody has to place the markers or do the clicking. Useful in controlled settings, but manual pairing cannot keep up with a robot scanning many times a second.
1980s2. Match distinctive features
Corners: found in bothSmooth: nothing to find?pairs come from the cornersno corners, no pairs
Corners can be found in both scans and paired, like markers. A smooth curve has no corners, so there is nothing to pair.
How: let a program find corners, edges or flat patches in each scan, pair them up, then use the same exact formula.Drawback: it needs scenes that have such features and a detector that finds the same ones twice. On smooth or cluttered shapes the pairs are wrong or missing.
1980s3. Line up the overall shape
whole scanpartial viewcentrelongest direction
A whole outline (teal) and a partial view of it (orange), drawn where it truly belongs. The partial view's centre and longest direction have moved, so lining those up would put the scan in the wrong place.
How: skip matches altogether. Move each cloud's centre of mass to the same place and turn its longest directions (principal axes) to agree.Drawback: it works best when both scans cover the same shape. Partial views can shift the centres and principal axes away from their corresponding positions.
1991–924. Iterative Closest Point (ICP)
Round 1: guess pairsRound 2: better guessesRound 12: settled
A real ICP run on two scans of one shape. Each grey line pairs an orange dot with its nearest teal dot. Solving moves orange, the pairs improve, and after 12 rounds the scans agree.
How: do not look for true matches first. Guess that each point matches the nearest point of the other scan, apply the exact formula from card 1, and repeat. For point-to-point ICP, the total squared nearest-point error cannot increase; the matches may improve (Besl & McKay 1992; Chen & Medioni 1992).What it fixed: uses raw points without markers or a feature detector. Partial overlap generally needs correspondence filtering. What it costs: it needs a roughly right starting position. You will find out why.

Where the points come from

The idea

A robot's laser scanner fires a ray in every direction and measures how far each one travels before it hits something. That ring of distances is all the robot gets. It draws them as dots around itself. It has no map, and it does not know where it is or how it has moved.

one ray,one distanceboxrobotno hits:hidden
The scanner sends rays all around, here one every 10° (the game's scanner uses 180, one every 2°). Each ray returns one distance, drawn as a dot where it hit. The wall behind the box gets no hits.

The room from above. Only you can see this. Faint lines are the laser rays.

What the robot gets. The same dots, drawn around the robot, which always sits in the middle facing up.

On a real robot

A 2D lidar spins a laser and times each pulse. A typical unit returns a few hundred to a few thousand distances per turn, ten or more turns a second, each good to a centimetre or two. A depth camera (Kinect, RealSense) gives a distance for every pixel instead.

A colour photo of an office desk with books, a phone, a monitor and a keyboard.Colour
The matching Kinect depth image: near surfaces red and orange, far ones green and blue, missing readings black.Depth0.5 m, near2.5 m+, far
One Kinect frame from the TUM RGB-D desk sequence. The depth image holds one distance per pixel (640 × 480 = 307,200 per frame); black pixels have no reading (26% here), such as the dark monitor screen and object edges.

Either way the result is the same kind of thing: a cloud of points measured from the sensor, with holes wherever something blocked the view. Lining up consecutive clouds is how a robot tracks its own motion without GPS.

The same frame as coloured 3D points seen from a viewpoint turned to the side, with black gaps behind the objects.As 3D points
The same depth frame as about 17,600 coloured 3D points (one per 1.25 cm cube), seen from a virtual camera turned 28° to the side. The black gaps behind objects are where the camera measured nothing: a scan is points seen from one viewpoint.

The math

Ray number \(k\) leaves at angle \(\phi_k\) and comes back with a distance \(r_k\). The dot it makes, measured from the robot, is \(p_k=(r_k\cos\phi_k,\; r_k\sin\phi_k)\).

x (forward)y (left)φkrkpkrk cos φkrk sin φk
Ray \(k\) leaves at angle \(\phi_k\) from the forward axis and returns \(r_k\). The dashed lengths are the dot's two coordinates. Range noise (about 1 cm) moves the dot along its own ray.

A dot \(p^{B}\) from scan B and the same spot \(p^{A}\) in scan A are related by

\[ p^{A}=R\,p^{B}+t,\qquad R=\begin{pmatrix}\cos\theta&-\sin\theta\\ \sin\theta&\cos\theta\end{pmatrix}. \]

\(\theta\) is how much the robot turned between the scans and \(t=(t_x,t_y)\) is how far it moved. Three unknown numbers in a flat world; six in 3D.

More detail

With the robot at position \(x_A\), heading \(\theta_A\) for scan A and \(x_B,\theta_B\) for scan B, the relation above is \(\theta=\theta_B-\theta_A\) and \(t=R(-\theta_A)\,(x_B-x_A)\): the robot's second pose written in the first pose's frame.

A depth camera adds one step: a pixel \((u,v)\) with depth \(z\) becomes the 3D point \(p=z\,K^{-1}(u,v,1)^{\top}\), where \(K\) holds the camera's focal lengths and image centre. That is how the Kinect frames in the real-scans level were turned into points.

optical axisimageplaneucxpxcamerafxz (depth)u − cxx / z = (u − cx) / fx
One image axis of a depth camera. The pixel sits \(u-c_x\) from the image centre on a plane \(f_x\) in front of the camera, so similar triangles give \(x=z\,(u-c_x)/f_x\); \(v\) gives \(y\) the same way.

Line up two scans by hand

The idea

These are scan A (teal) and scan B (orange) from one drive. Each is drawn the way the robot stores it: around the robot at the moment it was taken. They show the same walls, but the robot turned and moved in between, so orange looks turned and shifted. Put orange back on teal, and the turn and shift you used are how the robot moved.

walltxtyθtbaABb = R(θ) a + tone turn θ,two shifts tx, ty
One wall point, measured from both robot poses: \(a\) from pose B (orange), \(b\) from pose A (teal). Turning \(a\) by \(\theta\) and adding the shift \(t=(t_x,t_y)\) gives \(b\): one turn and two shifts.

On a real robot

Nobody drags scans on a robot. This search runs automatically for every new scan, and the answers are chained: where I am now = where I was, plus this turn and shift. That running total is called lidar odometry.

Scans arrive many times a second, so the motion between two of them is small. That is the easy case, and it is why the method works so well in practice.

Two Kinect point clouds of a desk with books, a red phone, a monitor and a keyboard, with the second cloud left where it was captured, so edges appear twice.The same two clouds after moving the second one by the camera motion, so the edges merge into one.As capturedAligned
Two Kinect point clouds of a desk, taken 0.2 s apart and drawn through the first camera. As captured, every edge appears twice; aligned by the camera's motion between them (9.2° and 8.6 cm, from motion capture), the copies merge.

The math

Call the orange dots \(a_1,\dots,a_N\) and the teal dots \(b_1,\dots,b_M\). Moving the orange scan by a turn \(R\) and a shift \(t\) sends each dot to \(R\,a_i+t\). The gap you were shrinking is

\[ \text{gap}(R,t)=\sqrt{\frac1N\sum_{i=1}^{N}\ \min_j\ \lVert R\,a_i+t-b_j\rVert^{2}} \]

Read it inside out: move dot \(i\); find the nearest teal dot (\(\min_j\)); take that distance, squared; average over all orange dots; square root. Registration means: find the \(R\) and \(t\) that make this as small as possible.

R ai + tnearest bjdigap = √( mean of di² )one di for each orange dot
Each orange dot, moved to \(R\,a_i+t\), is tied to its nearest teal dot \(b_j\). The tie's length is \(d_i\), and the gap is the square root of the mean of all the \(d_i^2\).
More detail

The gap never reaches zero, even at the true motion. The laser hits each wall at different spots in the two scans, every range carries about 1 cm of noise, and some walls are seen in only one scan because something blocked the view from the other pose.

ABpillarhidden from A: no teal dots nearby
Both scans at the true pose. Most orange dots land between teal dots, so their ties are short but not zero. Where the pillar blocks A's view (shaded) there are no teal dots, so the orange dots there (ringed) are tied to dots far away.

That last point matters: with parts of the scans missing, the pose with the smallest gap is not exactly the true pose. ICP seeks a local minimum of the gap, so it can end a degree or so away from the truth, as it does here.

How the robot keeps score

The idea

In the last level you steered by one number, the gap. A robot cannot see walls, only dots, so this score is one way to judge a fit. Build it in five small steps: tie every orange dot to its nearest teal dot, measure each tie, square the lengths, average them, and take the square root. Here the fit is nearly right, and every tie is drawn.

1 cm12 cm42 cm44 cm161 tie · 2 measure · 3 square4 average · 5 root(1 + 4 + 4 + 16) ÷ 4= 6.25 cm²6.252.5RMSE = √6.25 = 2.5 cm
Ties of 1, 2, 2 and 4 cm, each with its square drawn on it. The RMSE is the side of the average square, 2.5 cm, and the longest tie alone supplies 16 of the 25 cm².

On a real robot

There is no answer key. The robot uses this number twice: as the thing to make small, and afterwards as a health check on the result.

Open3D returns inlier_rmse, computed only from pairs inside its correspondence cutoff, and fitness, the fraction of source points with such a partner. This activity instead shows RMSE over all points, including long ties. Keep those definitions separate when comparing results. Low residuals and high fitness support an overlap estimate; they do not prove the pose is correct. Pose error requires a separate reference, such as motion capture.

true poseashort ties, low RMSEslid 3 dot spacingsaerrorsame ties, same RMSE
Slid along a straight corridor, every orange dot still has a teal partner about as close as before, so RMSE and fitness barely change. Nothing the robot measures shows the error; an outside reference such as motion capture can.

The math

For orange dot \(i\), the tie length is the distance to its nearest teal dot: \(d_i=\min_j\lVert R\,a_i+t-b_j\rVert\).

\[ \text{RMSE}=\sqrt{\frac{d_1^{2}+d_2^{2}+\dots+d_N^{2}}{N}},\qquad \text{fitness}=\frac{\#\{\,i: d_i\le 5\text{ cm}\,\}}{N} \]

Each bar under the picture is one \(d_i^{2}\). The dashed line is their average, and the RMSE is the square root of that. Squaring is what makes one long tie count so much: a tie ten times longer adds a hundred times more.

5 cm cutoff13 cmbad reading10 cmno overlapfitness = 4 of 6 = 67%inlier RMSE (grey ties) = 2.5 cmRMSE over all six ties = 7 cm
Each dashed circle has the 5 cm cutoff as its radius. Four orange dots find a teal partner inside it; a bad reading and a dot past the end of the teal scan do not, so they lower the fitness and raise the all-point RMSE.
More detail

Why square at all? With known matches, squared distances give a quadratic cost in translation and a closed-form rotation solution. The next three levels build that formula. The price is sensitivity to bad points, which a later level deals with.

The median tie is shown for contrast: it is the middle value when the ties are sorted, so one extreme reading cannot dominate it. Methods built on medians or capped losses are called robust estimators.

If you knew the matches: slide

The idea

Start with the easier problem from the first card. Same drives as before, but now the room has numbered beacons. The robot sees each beacon in both scans and knows which is which, so every orange dot comes with its true teal partner. Each grey tie pulls its orange dot towards its partner. The thick arrow is the average of all those pulls. Here you may only slide the scan, not turn it.

11223344μAμB1234the pulls, from one pointtheir averageaverage = μB − μA
Each grey arrow pulls one orange beacon towards its partner. Drawn from one point (right), the four pulls average to the thick arrow, which is exactly the arrow from the orange centre \(\mu_A\) to the teal centre \(\mu_B\).

On a real robot

Known matches exist whenever points carry an identity: corners of a calibration board, reflective markers tracked by a motion-capture system, a feature followed from one camera image to the next, or the numbered landmarks of a face tracker.

112233445566view 1view 2
Software can find the inner corners of a calibration board and number them in the same order in every view. Corner 3 in one view is corner 3 in the other, so each corner comes with its partner, like the beacons here.

Tracking marked objects uses this point-alignment problem directly. Hand-eye calibration uses a related rotation-alignment subproblem, followed by a separate translation solve in the relation AX = XB.

The math

With matches \(a_i\leftrightarrow b_i\), the cost is the average squared tie length. Sliding by \(t\):

\[ E(t)=\frac1n\sum_{i=1}^{n}\lVert a_i+t-b_i\rVert^{2} \]

The thick arrow is the average pull, \(\bar r=\frac1n\sum_i (b_i-a_i-t)\). The slope of \(E\) is \(-2\bar r\), so \(E\) stops falling exactly where \(\bar r=0\). That happens when the orange centre of mass \(\mu_A\) sits on the teal one \(\mu_B\): \(t=\mu_B-\mu_A\). With a turn \(R\) as well, the same argument gives \(t=\mu_B-R\,\mu_A\).

slide xslide yt = 0as scannedt = μB − μAlowest costaverage pullcontours of E: circles
Contours of the cost over every slide \(t\), at equal steps: circles round \(t=\mu_B-\mu_A\), the bottom of a round bowl. From any slide the average pull points straight at the bottom, and its length is the distance still to go.
More detail

With matches \(a_i \leftrightarrow b_i\) the cost is \(E(R,t)=\frac1n\sum_i\lVert R a_i+t-b_i\rVert^2\). Its slope in \(t\) is minus twice the average pull:

\[ \frac{\partial E}{\partial t}=-\frac{2}{n}\sum_i\bigl(b_i-R a_i-t\bigr)=0 \;\Longrightarrow\; t=\mu_B-R\,\mu_A . \]

\(E\) is a bowl in \(t\) (a paraboloid), so there is one lowest point and no way to get stuck. Subtracting the centroids from both scans removes \(t\) from the problem.

as scannedμAμBcentres subtractedonly a turn is left
Subtracting each scan’s centre moves both crosses onto one point, so there is no slide left to find. The ties that remain all wind the same way round: what is left is a turn, which the next level finds.

If you knew the matches: turn

The idea

You slid the beacons until their centres met. What is left is a turn about that centre. Drag anywhere (or use the buttons) to turn the orange beacons. The curved arrow is the net twist of all the ties. As you turn, the strip underneath draws the cost against the angle. Find the lowest point.

net twistcentrearound the centre:turns the scanalong the radius: no turn
With the centres together, each tie pulls its orange beacon partly along the radius, which cannot turn the scan, and partly around the centre. Those sideways parts add up to the net twist.

On a real robot

Slide, then turn, is the Kabsch (or Umeyama) solution of the Procrustes problem. It runs inside point-to-point ICP and molecular alignment. A related rotation solve appears in hand-eye calibration.

It is very cheap: one pass over the points to fill a 2×2 or 3×3 matrix, then one small matrix factorisation. The angle it gives here is the robot's actual turn from the earlier levels, found without any guessing.

The math

Subtract the centres: \(\tilde a_i=a_i-\mu_A\), \(\tilde b_i=b_i-\mu_B\). Collect all the matches into one small matrix:

\[ M=\sum_i \tilde b_i\,\tilde a_i^{\top}=\begin{pmatrix}M_{11}&M_{12}\\M_{21}&M_{22}\end{pmatrix} \]

Turning by \(\theta\) changes the cost as \(\text{const}-\frac{2}{n}\,[(M_{11}+M_{22})\cos\theta+(M_{21}-M_{12})\sin\theta]\): a single cosine wave, which is the curve you drew. Its lowest point is at \(\theta^{\ast}=\operatorname{atan2}(M_{21}-M_{12},\;M_{11}+M_{22})\). In 3D there is no single angle, so the SVD does the job: \(M=U\Sigma V^{\top}\), \(R=UV^{\top}\).

More detail

Centre both scans (\(\tilde a_i=a_i-\mu_A\), \(\tilde b_i=b_i-\mu_B\)) and collect the matches into one small matrix \(M=\sum_i \tilde b_i\,\tilde a_i^{\top}\). Then

\[ \sum_i\lVert R\tilde a_i-\tilde b_i\rVert^2=\text{const}-2\,\operatorname{tr}(R^{\top}M), \]

so the best rotation maximises \(\operatorname{tr}(R^{\top}M)\). In 2D that is \((M_{11}+M_{22})\cos\theta+(M_{21}-M_{12})\sin\theta\), a cosine, with its peak at \(\theta^\ast=\operatorname{atan2}(M_{21}-M_{12},\,M_{11}+M_{22})\).

In 3D there is no single angle, and the SVD does the same job: \(M=U\Sigma V^{\top}\), \(R=UV^{\top}\) (the orthogonal Procrustes problem from the hand-eye calibration slides, W4). Then \(t=\mu_B-R\mu_A\).

The trap in the recipe: mirrors

The idea

The recipe from the last two levels, written for any number of dimensions, is \(R=UDV^{\top}\), where \(D\) is a diagonal of \(+1\)s. Sometimes that "best fit" is not a turn at all but a mirror image, which no real object can do. Then one entry of \(D\) has to become \(-1\). Which one? Flip the entries and compare.

TurnMirror30°det R = +1a real motiondet = −1no turn makes this
A turn moves the F and it still reads as an F. A mirror reverses it, and no turn can undo that. Both keep every length; only the turn has \(\det R=+1\).

Left: scan as taken. Right: target with the solver’s fit on top.

On a real robot

Thin, noisy data is common: a single wall, a floor, a table top seen by a depth camera. Standard solvers (Eigen's umeyama, for example) apply this sign check on every call.

Skip it and the answer is occasionally not a rotation. Code that later turns it into a quaternion, or chains it with other poses, then fails in ways that are hard to trace.

Right-handedas in ROSxyz toward youLeft-handedas in Unityxyz away
ROS uses right-handed axes and Unity left-handed ones, so any conversion between the two has \(\det=-1\). Apply it to one scan but not the other, and that scan arrives back to front like the flipped F.

The math

The SVD splits the match matrix as \(M=U\Sigma V^{\top}\). \(\Sigma\) holds the singular values \(\sigma_1\ge\sigma_2\): how strongly the data speak along each of two directions (the dashed axes).

For \(R=UDV^{\top}\) with \(D=\operatorname{diag}(d_1,d_2)\), the fit quality is the score \(d_1\sigma_1+d_2\sigma_2\). All \(+1\) is the highest score, but \(\det R=\det(UV^{\top})\,d_1d_2\) must be \(+1\) for a true turn. If \(\det(UV^{\top})=-1\), one \(d\) must flip, and flipping the one with the smallest \(\sigma\) loses least: \(D=\operatorname{diag}(1,\det(UV^{\top}))\).

flip d₁: give up 2σ₁flip d₂: give up 2σ₂0−1, −1mirror−26.37−1, +1turn−16.94+1, −1best turn16.94+1, +1mirror26.37
The four sign choices for the flipped scan (\(\sigma_1=21.7,\ \sigma_2=4.7\)), placed by score: flipping \(d_2\) gives up \(2\sigma_2\), flipping \(d_1\) gives up \(2\sigma_1\). On the thin noisy wall \(\sigma_2=0.005\), so the same fix is almost free.
More detail

With \(M=U\Sigma V^{\top}\) and \(R=UDV^{\top}\), the quantity to maximise is \(\operatorname{tr}(R^{\top}M)=\operatorname{tr}(D\Sigma)=\sum_i d_i\sigma_i\). All \(d_i=+1\) is the unconstrained best, which is where the lecture derivation stops (W4, slide 25).

A rotation also needs \(\det R=\det(UV^{\top})\prod_i d_i=+1\). When \(\det(UV^{\top})=-1\), an odd number of \(d_i\) must be \(-1\), and since \(\sigma_1\ge\sigma_2\ge\dots\) the smallest loss is to flip the last one (Kabsch 1976, Umeyama 1991):

\[ R = U\,\operatorname{diag}\bigl(1,\dots,1,\det(UV^{\top})\bigr)\,V^{\top}. \]

It happens without any bug when the points are nearly flat (a wall in 2D, a plane in 3D) and noisy: the last singular value is close to zero, so the data barely vote on that direction.

Thin wall in 2Dσ₁σ₂ ≈ 0two numbers, one near zeroTable top in 3Dσ₁σ₂σ₃ ≈ 0three numbers, one near zero
Flat data leave one direction with almost no spread. Its singular value is close to zero, so noise alone can set the sign of \(\det(UV^{\top})\).

No beacons: what can stand in for matches?

The idea

Take the beacons away. The solver you built still needs matches, so try handing it three kinds. The teal shape is the orange one, turned and shifted by a known amount. Feed the solver the true matches, then scrambled ones, then a guess: each dot's nearest neighbour. Watch what angle it reports each time.

True: every tie right
Scrambled: half the ties wrong
Nearest point: short ties, mostly wrong
right matchwrong matchTeal is orange turned 40° and shifted.

On a real robot

Cameras get approximate matches from feature descriptors (SIFT, ORB). Some are wrong, and RANSAC, from the robust-estimation week, removes those before a solver like this runs.

You can compute geometric descriptors, such as FPFH, from a lidar or depth scan. Basic ICP uses a simpler rule: choose the nearest target point at the current pose. Compare that rule with known and scrambled matches here.

endcornerendright matchwrong: RANSAC drops it
A descriptor such as FPFH summarises the shape around a point (circles), so a corner finds the corner wherever the other scan lies. Up close the two line ends look alike, so one match is wrong; RANSAC removes such matches before the solver runs.

The math

Every match adds one term \(\tilde b\,\tilde a^{\top}\) to the matrix \(M\) from the turn level.

  • True matches all add terms that agree on the same turn.
  • Random wrong matches may partly cancel in this bounded shuffle experiment. Ordinary least squares has no majority guarantee: even one distant wrong match can dominate the fit.
  • Nearest-point matches are wrong in a biased way: each \(b\) is close to where \(a\) already is, so its term says "hardly any turn needed". In this example, the estimated turn is too small. With other geometry or a poorer start, it can also point in the wrong direction.
40°atrue partnernearestcentre
Each tie votes for the angle from \(\tilde a\) to \(\tilde b\), seen from the centre. For dot \(a\) the true partner says 40°, its nearest teal dot only a few degrees, so together the nearest-point ties ask for too small a turn.
More detail

Every match adds one term \(\tilde b\,\tilde a^{\top}\) to \(M\). A correct match adds a term that agrees with all the other correct ones. A random match adds a term with no preferred direction, so many of them sum to roughly zero and \(M\) still points the right way until they dominate.

A nearest-point match is biased. Its \(b\) is close to where \(a\) already is, so its term looks like "no motion needed". When the scans start reasonably close, the fit from such matches under-shoots the true rotation; when they start far apart it can be useless, which the next-but-one level maps out. Repeating the guess after each small move is Iterative Closest Point (Besl & McKay 1992).

Face landmarks come with fixed indices, so they are true matches for free. MediaPipe's own face-geometry module solves head pose with a file named procrustes_solver.cc.

Be the algorithm: Match, Solve, repeat

The idea

Now put the pieces together on the same two scans from the drive, with no beacons. Match ties every orange dot to its nearest teal dot: the guess from the last level. Solve is slide-then-turn on those ties: the exact formula. Red ties differ from the nearest-neighbour matches at the true pose. Select Match, then Solve when it appears. The staircase underneath shows the root-mean-square tie length after each action.

Matchpose fixed: pick tiesSolveties fixed: pick posetiesnew pose, so match againStop when no tie changes.
Match keeps the pose and picks the ties; Solve keeps the ties and picks the pose. After one Solve the scan is closer but not there yet, so Match runs again.
RMSE after each actionDrop from MatchDrop from Solve

On a real robot

This loop is registration_icp in Open3D and IterativeClosestPoint in PCL. Match is a nearest-neighbour search per point, sped up with a k-d tree; on scans with tens of thousands of points it takes most of the time.

Real code stops when the error changes by less than a small tolerance, or after a fixed number of rounds.

querydistancecomputednever looked atskipped regionfirst split
A k-d tree splits the teal points at the median, alternating vertical and horizontal lines. For this query the search computes only 5 of the 15 distances: it skips the far side of any split line that is farther away than its best match so far (the dashed circle shows the final one).

The math

ICP lowers one cost, \(E=\frac1N\sum_i\lVert R\,a_i+t-b_{c(i)}\rVert^{2}\), by changing two things in turn. \(c(i)\) is "which teal dot orange dot \(i\) is tied to".

  1. Match: keep the pose, choose the best ties: \(c(i)=\) nearest teal dot. No tie gets longer.
  2. Solve: keep the ties, choose the best pose: centroids, \(M\), SVD, sign check.

Each step is the best possible for its half, so \(E\) can never rise, and it cannot go below zero, so it must settle. That is the staircase, and why pressing a button twice does nothing.

0Epose (a shift) →startstops here:no tie changeslower bowl, never reached
Solve: slide to the bottom of this bowlMatch: drop to the lowest bowl
0EMatch: no changeeach press →
Each grey bowl is the cost for one fixed set of ties (the pose drawn as a single shift); the thick curve is the lowest bowl at each pose. Neither move goes up, which gives the staircase, and the loop can stop above a lower bowl it never reaches.
More detail

ICP minimises \(E(R,t,c)=\frac1N\sum_i\lVert R a_i+t-b_{c(i)}\rVert^2\) over the pose and the matching \(c\) together, one at a time:

  1. Match: \(c(i)=\arg\min_j\lVert R a_i+t-b_j\rVert\). No tie can get longer than the one it replaces. A k-d tree makes each lookup fast.
  2. Solve: \((R,t)=\arg\min\sum_i\lVert R a_i+t-b_{c(i)}\rVert^2\), the closed form: centroids, \(M\), SVD, \(D\).

\(E\) never rises and cannot go below zero, so it settles (Besl & McKay 1992). Pressing a button twice changes nothing because each step is already optimal for its half. The proof says the loop stops; it does not say it stops at the right pose. That is the next level.

Failure 1: starting too far away

The idea

ICP got home in the last level because the scans started close. Here is the gap for every starting angle. In the turn level, with true matches, this curve was one smooth valley. With guessed matches it has several, and ICP can only roll downhill from where it starts. Five starts: say whether ICP will reach the true pose, then watch.

The gap for every starting angle of the star, with two real ICP runs. From inside the green basin ICP rolls to the true pose; from just past the ridge it rolls into the next valley and stops there.

On a real robot

A robot rarely starts ICP blind. Wheel encoders or an inertial sensor say roughly how it moved, and at ten or more scans a second, "the same motion as last time" is already close.

The hard cases are cold starts: a robot switched on inside a known map, or returning to a place it has seen before. There a global method based on feature matches and RANSAC finds the right valley, and ICP finishes the job.

Tracking earliernow guess: last motion again ICP Cold start mapnew scan 3 matches agree1 does not
Tracking: repeating the last motion (or reading wheel odometry or an IMU) puts the new scan near its true pose, and ICP corrects the rest. Cold start: matched features vote on the pose, RANSAC keeps the matches that agree, and ICP finishes from there.

The math

For one fixed set of ties, the cost against angle is a single cosine (the turn level). The gap uses, for each dot, whichever tie is shortest, so the curve here is the lowest of many cosines glued together. Glued curves have several dips.

ICP only ever lowers the cost, so it ends at the bottom of the dip it starts in: a local minimum. The set of starts that lead to the true pose is the basin of convergence. A symmetric shape has several equally deep dips, and nothing in the gap can tell them apart.

The star again. Each thin curve keeps the ties chosen at one angle, so it is one cosine (green: the ties at the true pose); the real cost (bold, the gap squared) is never above any of them and touches each where its ties were chosen.
More detail

The cost \(E(R,t)=\frac1N\sum_i\min_j\lVert Ra_i+t-b_j\rVert^2\) has a \(\min\) inside it. With fixed matches (the turn level) the cost was a single cosine in the angle. Each time a point switches partner the cosine changes, and the pieces glue together into a curve with several valleys.

ICP is a descent method: both of its steps lower \(E\), so it ends at a local minimum, the one whose basin of convergence contains the start (Besl & McKay 1992 prove convergence, to a local minimum only).

The curve drawn here fixes \(t\) at the truth and varies only the angle. The real landscape has three dimensions in 2D and six in 3D, so a slice can hide valleys, as the last round shows. A symmetric shape has several equally deep valleys, and no amount of iterating can choose between them.

Failure 2: points that should not be there

The idea

Same room and robot as before. But between scan A and scan B, people walked in. Almost a third of the orange dots are on them, and ICP ties those dots to walls anyway. The bars underneath count the ties by length. Drag the orange handle to set a cutoff: any tie longer than that gets no vote.

Scan B moved by the robot's true motion: dots on walls land on teal dots, but dots on people have no partner, so their ties (red) run to the nearest wall. The few long grey ties come from walls scan A could not see.

On a real robot

Between two scans people walk through, doors open, and the robot sees round a corner it could not see before. Points with no true partner are the normal case.

In Open3D this cutoff is the max_correspondence_distance argument of registration_icp, and it is usually the first thing to tune. Systems such as KISS-ICP adjust it automatically as the robot speeds up and slows down.

A sketch from above: an open door shows the room behind it, and a new pose sees into a side passage. Those dots have nothing to match in scan A, yet ICP still ties each one to its nearest teal dot.

The math

Solve minimises a sum of squared tie lengths, so a tie five times longer counts twenty-five times as much. A point on a moving person may have a long tie, but a point near a wall can have a short, incorrect tie. The cutoff tests distance, not whether a point belongs to a moving object.

With a cutoff \(d_{\max}\), only the ties in \(K=\{\,i:\ d_i\le d_{\max}\}\) are used. Too large and the stray ties still vote. Too small and, at the starting pose, most of the true ties are longer than \(d_{\max}\) too, so they are thrown out before the scan has had a chance to move. In this scene, plotting the final error against \(d_{\max}\) reveals a range between these two failures. Other scenes need not produce the same curve.

Tie lengths in this level's room. At the start, wall and person ties overlap and a 15 cm cutoff throws out most wall ties too; at the true pose they separate, which is why a cutoff should start loose and tighten.
More detail

The Solve step minimises a sum of squared lengths, so a tie five times longer counts twenty-five times as much. Outliers with long ties can outweigh many good pairs. Short incorrect ties can remain inside the cutoff.

Rejection keeps \(K=\{\,i:\lVert Ra_i+t-b_{c(i)}\rVert\le d_{\max}\}\) and solves on \(K\) only. It is the bluntest robust estimator: weight 1 inside the cutoff, 0 outside (a truncated loss). Smoother choices such as Huber weights, or RANSAC on the matches, follow the same idea from the robust-estimation week (W5).

cost of one tie dmax2 ddmax5d tie length 25× the cost least squares Huber with a cutoff
Least squares grows with the square, so a tie 5 times longer adds 25 times as much. A cutoff caps each tie at \(d_{\max}^2\) and gives it no pull; Huber keeps a pull of fixed size.

With a cutoff the plotted error can tick up between iterations, because the set \(K\) changes. What still never rises is the sum in which each rejected tie counts as \(d_{\max}^2\).

Failure 3: measuring to the wrong thing

The idea

Every level so far measured each orange dot to its nearest teal dot. But the laser hits a wall at different spots each time, so there is no exact twin to find. Should the score measure to the nearest dot, or to the wall the dots lie on? Slide the scan along the corridor and compare the two.

To the nearest sampleslants along the wall To the wallonly the gap across
The same orange dots, two rulers. To the nearest teal sample each tie also runs along the wall, by an amount that depends on where the samples fell; to the wall, only the gap across counts.

Point-to-pointPoint-to-plane

On a real robot

The robot is not told where the walls are. At each point it estimates the surface direction from the neighbouring points with a small PCA (estimate_normals in Open3D), so point-to-plane needs scans dense enough to have neighbours on the same surface.

It is the usual choice for indoor depth cameras; KinectFusion tracks the camera with it on every frame.

q n: least spread most spread: along the wall
The robot finds the wall's direction from q's neighbours. Their spread is largest along the wall and smallest across it, so the normal n is the direction of least spread: the eigenvector of their covariance with the smallest eigenvalue.

The math

Point-to-point: \(\sum_i\lVert R\,a_i+t-b_i\rVert^{2}\). The whole gap counts, including the part that runs along the wall.

Point-to-plane: \(\sum_i\bigl((R\,a_i+t-b_i)\cdot n_i\bigr)^{2}\), where \(n_i\) is a unit arrow sticking straight out of the surface at \(b_i\). The dot product keeps only the part of the gap that is perpendicular to the wall, so sliding along the wall costs nothing.

This version has no exact formula. Each round assumes the remaining turn is small and solves a small set of linear equations instead.

pqn p − q (p − q)·n along the wall point-to-point counts all of p − q point-to-plane counts only (p − q)·n
Split the gap \(p-q\) into a part along the wall and a part along the normal \(n\). Point-to-point squares the whole gap; point-to-plane keeps only \((p-q)\cdot n\), so sliding along the wall is free.
More detail

Point-to-point (Besl & McKay 1992): \(\sum_i\lVert Ra_i+t-b_{c(i)}\rVert^2\), solved in closed form by Procrustes.

Point-to-plane (Chen & Medioni 1992): \(\sum_i\bigl((Ra_i+t-b_{c(i)})\cdot n_{c(i)}\bigr)^2\), with \(n\) the surface normal at the matched point, estimated here by PCA over a few neighbours. There is no closed form, so each step linearises \(R\approx I+[\omega]_\times\) for a small rotation and solves a small least-squares system (Low 2004): 3 unknowns in 2D, 6 in 3D.

In a bare corridor neither measure can say where along it you are. Point-to-plane reports that honestly as a flat direction; point-to-point reports ripples that come from the sampling, not the scene.

Bare corridorslide: freeΣ n nᵀ =000None eigenvalue 0
Cornerslide: resistedΣ n nᵀ =m00Nboth above 0

With the matches held fixed, a small shift \(\delta\) away from the best fit raises the point-to-plane cost by \(\delta^\top\bigl(\sum_i n_i n_i^\top\bigr)\delta\). N counts the normals across the corridor and m those along it; a bare corridor has m = 0, so the slide along it is free.

Real robots meet the same blind direction in long corridors and tunnels. Zhang, Kaess and Singh (ICRA 2016) detect such directions in LiDAR odometry from the eigenvalues of this kind of matrix and keep the solver from updating along them.

Compare real scans with a reference pose

The idea

Apply the same loop to real 3D scans: a rabbit figurine measured by a laser scanner, and a desk seen by a Kinect depth camera 0.2 seconds apart. Compare the Bunny with Stanford's reference registration and the desk with an independent motion-capture pose. Predict which method will have the smaller rotation error, then inspect the iterations. Compare translation error separately.

Two laser scans of the Stanford Bunny as captured: the orange scan bun045 is turned 34.3 degrees away from the teal scan bun000. The same two Bunny scans after Stanford's reference alignment: orange and teal interleave on one surface. ScannedAligned
Bunny, laser scanner. Scan bun045 (orange) as captured, 34.3° from bun000 (teal), then moved by Stanford's reference alignment.
Close-up of the left of the desk with the second Kinect cloud left where it was captured: the books, the red phone and the box have doubled edges. The same close-up with the second cloud moved by the motion-capture pose: the two clouds merge into one scene. CapturedAligned
Desk, Kinect (close-up). This level's desk pair, 0.2 s apart. Moving the second cloud by the motion-capture pose, which does not use the depth images, merges the doubled edges.
Point-to-pointPoint-to-plane

On a real robot

Check how a benchmark obtains its reference poses. Stanford aligned the Bunny scans with modified ICP, so its alignment is not an independent measurement. TUM uses motion capture to track the Kinect.

Bunny: laser scanner figurine, from above 34.3° bun000 bun045 Reference: ICP alignment not independent of ICP
The Bunny was scanned from directions 34.3° apart, and each scan saw only the side facing the scanner (coloured arcs). Its reference pose comes from aligning the scans with modified ICP.
Desk: motion capture desk Kinect Reference: tracked markers independent of ICP
TUM tracks reflective markers on the Kinect with cameras around the room. That pose does not use the depth images, so it is independent of ICP.

In normal operation, an independent reference pose is usually unavailable. Use residuals and fitness as diagnostic signals, while remembering that neither proves the pose is correct.

The math

In 3D a rigid pose has six degrees of freedom: three for rotation and three for translation. Match uses a 3D k-d tree. Point-to-point Solve uses the same recipe with a 3×3 matrix: \(M=U\Sigma V^{\top}\), \(R=U\,\mathrm{diag}(1,1,\det(UV^{\top}))\,V^{\top}\), \(t=\mu_B-R\,\mu_A\). Point-to-plane uses the linearised solve from the previous lesson.

Compare an estimate with the reference \((R^{\ast},t^{\ast})\) using the angle of \(R^{\ast\top}R\) and the distance \(\lVert t-t^{\ast}\rVert\). The prediction here is scored by rotation error only.

θ ‖t − t*‖ reference (R*, t*) estimate (R, t) θ = angle of R*ᵀR rotation error ‖t − t*‖ translation error
Grey: the reference pose. Orange: an estimate. Any leftover rotation \(R^{\ast\top}R\) is one turn about one axis; its angle θ is the rotation error, and the distance between the origins is the translation error.
More detail

In 3D the pose has six degrees of freedom, represented by \(R\in SO(3)\) and \(t\in\mathbb{R}^3\). Point-to-point Solve uses the same recipe with a \(3\times3\) matrix \(M=U\Sigma V^{\top}\) and \(R=U\,\mathrm{diag}(1,1,\det(UV^{\top}))\,V^{\top}\). Match uses a 3D k-d tree.

x y θ 2D, the game so far 1 turn + 2 shifts = 3
The scans in the earlier levels lie in a plane: one turn and two shifts.
x y z 3D, real scans 3 turns + 3 shifts = 6
Real scans are 3D: a turn about each axis and a shift along each.

Bunny: scans bun045 and bun000 from the Stanford 3D Scanning Repository, down-sampled to 1811 and 1919 points, reference rotation 34.3° from Stanford's ICP-based alignment file, 1 cm cutoff. Desk: TUM RGB-D fr1/desk (Sturm et al. 2012, CC BY 4.0), two frames 0.2 s apart back-projected through the Kinect intrinsics, 4291 and 4718 points, motion-capture ground truth 9.19° and 8.61 cm, 6 cm cutoff.

These results were checked against Open3D 0.20 (bunny, point-to-point: 2.19° and 0.81 mm there, 2.18° and 0.81 mm here). KinectFusion (Newcombe et al. 2011) runs point-to-plane ICP like this on every frame, starting from the previous frame's pose.

Boss rounds: rescue the alignment

The idea

Help a robot align two scans: improve the start, filter stray readings, and decide when the scan needs another positioning cue. Try each decision, read the result, then continue. A small matching gap alone does not prove the pose is correct.

  1. 1 · Align
  2. 2 · Filter
  3. 3 · Diagnose
  4. 4 · Rescue
Orange: moving scanTeal: fixed scan

Practice and daily challenge
Open the original daily challenge

Optional practice. Compare a hand fit, ICP alone and ICP from your fit. This does not change your four-round completion.

gap -

On a real robot

Your part is played by odometry, an inertial sensor, or a feature-based global match. ICP's part is unchanged: it turns a rough guess into a precise one.

Chained over thousands of scans, the small leftovers add up, and the map slowly bends. Fixing that drift is what loop closure and pose-graph optimisation in SLAM are for.

Map of the TUM desk stitched from 25 Kinect frames with motion-capture camera poses, seen from above and behind; the camera path is drawn in white. The same map stitched with camera poses from chained frame-to-frame point-to-plane ICP; the camera path, drawn in orange, drifts away from the motion-capture path. Motion captureChained ICP
The TUM desk sequence stitched into one map, with camera poses from motion capture (white path) and from chaining point-to-plane ICP frame to frame with no loop closure (orange path). After 19.7 s and 8.45 m of camera path, the chained poses end 26.6 cm and 3.64° from motion capture.

The math

The pipeline is two stages: a coarse pose \((R_0,t_0)\) from anywhere, then ICP started there, with a cutoff.

1 Rough start (R₀, t₀) odometry, IMU, global match or you 2 ICP from there, with a cutoff point-to-point or point-to-plane 3 Can you trust the result? enough matches kept a small gap between them every direction pinned down yes Use the pose no better start, other cutoff, or another cue
Rounds 1 to 3 each test one box, and round 4 runs the whole chart. A small gap alone does not pass box 3.

"Points off by" is the combined score used here: move every clean orange dot once with your pose and once with the true pose, and take the RMS distance between the two results, \(\sqrt{\tfrac1N\sum_i\lVert (R\,a_i+t)-(R^{\ast}a_i+t^{\ast})\rVert^{2}}\). It mixes turn and shift errors into one length.

reference pose (R*, t*) your pose (R, t) points off by = RMS length of the grey lines turn and shift errors in one length
Each clean point is moved once with your pose and once with the reference pose. The RMS length of the grey lines is the reference pose error in the rounds and “points off by” in the daily challenge.
Where this goes next

Chain ICP frame to frame and small errors add up, so maps drift. Fusing every aligned frame into one model and aligning against the model slows the drift (KinectFusion, with a TSDF, in the RGB-D week, W6). Global consistency comes later: bundle adjustment (W8) and pose graphs with loop closure in SLAM (W9 and W10).

Chained ICP drifts start loop closure: ICP of the last scan against the first
Each scan is aligned to the one before, so small errors add up and the loop does not close.
After optimising the graph the error is spread around the loop
The loop-closure edge and pose-graph optimisation spread the error around the loop. Dashed: the true path.

Variants worth knowing by name: Generalized-ICP (plane-to-plane; Segal, Haehnel & Thrun 2009), the survey of ICP design choices by Rusinkiewicz & Levoy (2001), and Umeyama's (1991) version of the closed form with scale. The long read has the derivations and all references.

Where this is today

The idea

Thirty years on, the loop you ran by hand remains a common part of systems that line up 3D data. Current work attacks the same weak spots you met: the starting guess, the cutoff, the choice of ruler, and the matches. Each card names a recent system, what it changes, and the level where you met that problem.

Starting guess Cutoff Ruler Matches Points from photos ICP 1992 Besl & McKay 2020 2021 2022 2023 2024 2025 TEASER++ FAST-LIO2 Kinematic-ICP KISS-ICP GenZ-ICP GeoTransformer DUSt3R VGGT
Hollow dots: the four weak spots of the 1992 loop. Filled dots: the systems on the cards, in the lane they work on; TEASER++ works on two, and the bottom lane gets 3D points from photos.
ICP, done carefullyKISS-ICP (2023)Point-to-point ICP for lidar odometry, with robust optimization and a cutoff adapted from deviations from predicted motion. The authors evaluate one parameter set on cars, drones and handheld scanners.You met this in: the cutoff level.
Prediction vs. ICP predicted after ICP δ δ: deviation from the prediction Cutoff τ from past δ τ kept dropped
δ is how far ICP moved the pose away from the predicted motion. The cutoff τ is set from past values of δ, and longer matches are dropped.
Choosing the rulerGenZ-ICP (2024)Blends point-to-point and point-to-plane, weighting them by the surroundings, to reduce failures in corridors and other places where one ruler alone poorly constrains motion.You met this in: the walls level, in the corridor.
n point-to-point point-to-plane fixed scan, a flat wall GenZ-ICP adds both: w · point-to-plane + (1 − w) · point-to-point w is set from the surroundings
Point-to-point measures the whole gap to the matched point; point-to-plane measures only the part across the surface.
A better starting guessFAST-LIO2 (2022) · Kinematic-ICP (2024)FAST-LIO2 fuses the lidar with an inertial sensor, which predicts the motion before each scan is fitted. Kinematic-ICP builds the way a wheeled robot can and cannot move into the fit itself.You met this in: the valleys level, where the start decided everything.
IMU predicts the start no prediction predicted wrong right Wheels cannot slide forward turn sideways
Left: a predicted start lands in the right valley. Right: a wheeled robot can drive forward and turn but cannot slide sideways, and Kinematic-ICP uses this in the fit.
No starting guess at allTEASER++ (2020)Global registration: it takes feature matches of which most may be wrong, finds the consistent ones, and can certify optimality for its rotation-estimation subproblem when the certificate succeeds. Often used to find the right valley, with ICP to finish.You met this in: the valleys and cutoff levels.
d d
Green: correct matches; a rigid motion keeps distances, so the distance d between two of them is the same in both scans. Red, dashed: wrong matches, which do not agree.
Learning the matchesGeoTransformer (2022)A neural network proposes matches between two clouds that barely overlap, accurately enough that the closed-form solver can be applied directly.You met this in: the matches level, where true matches made one shot enough.
Little overlap grey: matches from the network One closed-form solve joined where they overlap
Two scans that overlap only on a short piece of wall. With good matches, the closed-form solve from the Turn and Mirror trap levels can be applied directly.
Points straight from photosDUSt3R (2024) · VGGT (2025)Networks that infer 3D structure from photos. DUSt3R expresses an image pair in a common frame; combining many pairs generally requires global alignment. VGGT predicts multiple views in a shared frame.Still true: the underlying question has not changed: which single motion makes two views of a scene agree.
photo 1 photo 2 network one shared frame
Each pixel becomes a 3D point, and the points from both photos come out in one shared frame.
Use it yourselfOpen3D · small_gicpOpen3D's registration_icp is the loop from this game in a few lines of Python. small_gicp is a fast, parallel implementation of ICP and its Generalized-ICP variant for real-time use.You met this in: every level.
import open3d as o3d
reg = o3d.pipelines.registration
target.estimate_normals()                 # normals, for point-to-plane
ruler = reg.TransformationEstimationPointToPlane()
result = reg.registration_icp(source, target,
    0.05,                                 # cutoff (5 cm)
    T0,                                   # starting guess, a 4×4 pose
    ruler)                                # the ruler
print(result.fitness, result.inlier_rmse) # the score
The game in Open3D: each argument is a choice you made in one of the levels.