Once the frontend gives us a set of poses and constraints, we have a probability problem.
We have a graph where nodes are poses
The Probability Formulation
We want to find the trajectory
Assuming Gaussian noise, this is equivalent to minimizing the negative log-likelihood, which turns into a NLS problem.
The Error Function
An edge
The expected measurement based on our current nodes is
The error (residual) vector
Crucial Note: We are on a manifold. We cannot just subtract matrices. We calculate the error in the tangent space
This gives us a 6x1 error vector for each edge.
The Cost Function
We minimize the Mahalanobis distance (weighted sum of squares):
Where
Solving the Optimization
This is solved using Gauss-Newton or Levenberg-Marquardt
We linearize the error term around the current guess
We solve the normal equation:
- Build H and b: Iterate over all edges, compute Jacobians, add to the sparse matrix H.
- Solve: Use a sparse Cholesky solver (standard) or Preconditioned Conjugate Gradient (for massive maps).
- Update:
.
Why is this efficient?
The H matrix is sparse.
Node
We exploit this sparsity to solve systems with 100,000+ variables in real-time.