Localisation & SLAM, step 6
Closing the loop
Turn every scan match into an edge of a graph, add one edge that closes the loop, and solve for all the poses at once: the lap closes and the map lines up.
Builds on Least squares: fitting noisy data and Optimisation: gradient descent, from the free Foundations.
Write and run this step in the simulator with ProWhy the loop doesn't close
Your ICP track from step 5 still drifts: every match is a little off and the errors add up. When the rover gets back to its start its track doesn't quite, and the map shows a seam.
A graph of poses
Pose-graph SLAM keeps every keyframe pose as a node and every measurement as an edge : "seen from pose , pose is at ". ICP links consecutive keyframes. One more match, of the last scan against the first, adds a loop closure. , the edge's information matrix (its inverse covariance), says how much to trust it.
The error of an edge
With the position of pose and the rotation by ,
Its Jacobians, with , and , are
Gauss–Newton
The best poses minimise over every edge. Linearise each edge at the current poses and add its blocks into one system: into block of , into , into , into , and and into blocks and of . Solve , add to the poses, and repeat. Foundations: Least squares covers the idea.
Edges only fix relative poses, so the whole graph could slide and spin for free and is singular. Hold pose 0 still: drop its three rows and columns and solve for the rest.
The program
The rover drives step 5's loop, matching a scan every half second, then closes the loop and calls your optimiser. The Images tab shows the map before and after; the 3D view shows the ICP chain in orange and your optimised track in green.
Your task
Write edge_error(xi, xj, z), edge_jacobians(xi, xj) → (A, B), build_system(poses, edges) → (H, b) and optimize(poses, edges, iters). The grader checks each on fixed graphs, then your track and your map against the real maze.