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.
Real dataThe plan for the restYou will rebuild this history by hand. Part 1: where the points come from and how a fit is scored. Part 2: the exact formula for known matches (card 1). Part 3: ICP's trick of guessing the matches (card 4). Part 4: the three ways it fails. Part 5: real 3D scans and today's best systems.Next: drive a robot and see what a scan really is.
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.
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.
What you just sawWhen the robot moves, its picture of the room moves the opposite way. Two scans of the same room disagree by exactly the robot's own motion: one turn and one shift. Find that turn and shift from the dots alone and you know how the robot moved. This is called registration.Next: you get two scans and no steering wheel. Find the turn and the shift yourself.
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.
Colour
Depth
0.5 m, near2.5 m+, farEither 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.
As 3D pointsThe 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)\).
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.
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.
What you just sawYou searched for three numbers by eye, one turn and two shifts, steering by the gap. ICP searched for the same three with no eyes at all. Notice the two columns: the robot can compute the gap, but rotation and centre error need the true motion, which only this page knows.Next: what exactly is that gap number, and how far can it be trusted?
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.

As capturedAlignedThe 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.
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.
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.
What you just sawThe score uses only things the robot can measure: each dot's distance to the nearest dot of the other scan. Because the distances are squared, one bad reading can outweigh a hundred good ones. And nothing in the score uses the true motion: a small gap is evidence of a good fit, not proof.Next: computing the score is easy. Finding the turn and shift that make it smallest is the hard part. Start with an easier version, where you are told which dot matches which.
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.
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.
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.
What you just sawThe cost is lowest exactly where the pulls cancel, and that is where the two centres of mass (the crosses) coincide. This holds whatever the rotation, so the shift can be solved first and on its own.Next: the ties that are left all wind the same way round. Turn the scan.
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.
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\).
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.
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.
What you just sawWith known matches the cost against angle is a single cosine: one valley, nothing to get stuck in. Its bottom can be read straight off four sums, so no search is needed. Slide, then turn: that is Procrustes.Next: this two-step recipe has one trap, and it bites on real data.
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.
Left: scan as taken. Right: target with the solver’s fit on top.
What you just sawThe matrix \(UV^{\top}\) is the best orthogonal fit, and orthogonal includes mirrors. To force a rotation you give up one direction, and the cheapest to give up is the weakest: flip the entry of \(D\) that goes with the smallest singular value. That is \(D=\operatorname{diag}(1,\det(UV^{\top}))\).Next: beacons are a luxury. Most scans have no numbered points. What can stand in for the matches?
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.
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}))\).
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.
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.
What you just sawRandom wrong matches mostly cancel, so the solver shrugs off a lot of them. Nearest-point guesses are different: each points at something close by, so together they ask for a small move. From a start that is not too far off, it is a move in the right direction: too short, but useful. So move, and guess again.Next: the guess gets you part of the way. So move, guess again, and repeat. You run that loop by hand.
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.
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.
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.
What you just sawEach button solves one half of the problem exactly. Match is the best pairing for this pose; Solve is the best pose for this pairing. Neither can increase the total squared tie length, so the RMSE staircase only goes down. Individual ties can lengthen, and the final matches need not be the true ones. That loop is ICP.Next: it got there from this start. Would it from any start?
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.
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".
- Match: keep the pose, choose the best ties: \(c(i)=\) nearest teal dot. No tie gets longer.
- 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.
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:
- 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.
- 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.
What you just sawICP always stops, but only at the bottom of whichever valley it starts in. A low gap does not prove the pose is right: every arm of the star fits every other arm. So real systems hand ICP a rough first guess (odometry, an IMU, the previous frame, or feature matches with RANSAC) and let it do the fine part.Next: a second way to fail has nothing to do with the start. It comes from points that should not be 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.
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.
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.
What you just sawLeast squares lets every tie vote, and long ties shout loudest. A cutoff silences them, but it is judged at the current pose: set it too tight too early and the true pairs are silenced as well. Practical pipelines start loose and tighten as the fit improves.Next: one more choice hides inside the score itself. Distance to what?
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.
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.
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).
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.
What you just sawPoint-to-point glues each point to a sample, so along a wall every tie pulls back and the scan creeps. Point-to-plane only counts the part of the gap that is perpendicular to the surface, so the scan slides freely along walls and the corners do the steering. Same loop, different ruler, far fewer steps.Next: all of it together, on real sensor data in 3D.
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.
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.
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.
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.
ScannedAligned
CapturedAligned
What you just sawThe same loop works in three dimensions on thousands of points. The residual definition affects the result, and a smaller residual does not guarantee a smaller pose error. Reference poses also have uncertainty: the Bunny uses an ICP-based alignment, while the desk uses motion capture.Next: compare your starting estimate with ICP in the boss round.
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.
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.
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.
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 · Align
- 2 · Filter
- 3 · Diagnose
- 4 · Rescue
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.
The whole storyWith matches, alignment is a closed form: centroids, one small matrix, an SVD, a sign check. Without matches, guess them by nearest point, solve, and repeat. That loop only finds the nearest valley, so it needs a rough start, a cutoff for strays, and the right ruler. You supplied the rough start. A robot gets it from odometry, an IMU, the last frame, or feature matches.Next: what the best current systems do about each of these weak spots.
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.
Motion captureChained ICP
The math
The pipeline is two stages: a coarse pose \((R_0,t_0)\) from anywhere, then ICP started there, with a cutoff.
"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.
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).
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.
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 scoreThat is the whole arcFrom hand-clicked matches, to an exact formula, to guessing the matches and looping, to today's systems that mostly improve the guess, the cutoff and the ruler. The long read has the full derivations and the reference list.