Problems · Problem 18 · Perception & mapping · Hard
Graph SLAM
Turn a drifting lap of odometry into a consistent trajectory by optimising every pose at once against all the measurements.
Builds on Least squares: fitting noisy data, from the free Foundations.
Write and run this problem in the simulator with ProWhat it computes
Odometry drifts: a turn measured 3 % too big bends the whole rest of the path. Graph SLAM corrects a trajectory all at once. Each keyframe pose is a node. Each measurement is an edge, "seen from pose , pose is at ", weighted by an information matrix (an inverse covariance). Odometry links consecutive poses, and a loop closure says the lap ended where it began. The best trajectory minimises
The error and its Jacobians
With the rotation by , and the difference in position:
where and , with and .
Gauss–Newton
repeat iters times:
H = zeros(3n, 3n); b = zeros(3n)
for each edge (i, j, z, Ω):
e, A, B = the error and Jacobians at the current poses
H[i, i] += Aᵀ Ω A H[i, j] += Aᵀ Ω B
H[j, i] += Bᵀ Ω A H[j, j] += Bᵀ Ω B
b[i] += Aᵀ Ω e b[j] += Bᵀ Ω e
solve H Δx = -b for poses 1 … n-1 only # pose 0 stays put
x += Δx, then wrap every θ
Edges only fix relative poses, so the whole graph could slide and spin for free: is singular until you hold one pose still.
Tools
H[3*i:3*i+3, 3*j:3*j+3] is block . rover.wrap(a) wraps angles to . np.linalg.solve(M, v) solves .
Your task
Implement optimize(poses, edges, iters). poses is and each edge is (i, j, z, info); return the optimised poses. The program drives the rover once round the loop, keeps a keyframe every half second, and draws raw odometry in red and your trajectory in green. The grader compares optimize with the reference on three test graphs, then checks your lap against the rover's true path.