Skip to content

ICP covariance matrix and Monte Carlo ICP uncertainty - #667

Merged
JanuszBedkowski merged 1 commit into
mainfrom
mp/icp_covariance_montecarlo
Nov 27, 2026
Merged

JanuszBedkowski merged 1 commit into
mainfrom
mp/icp_covariance_montecarlo

Conversation

@michalpelka

Copy link
Copy Markdown
Contributor

I've implemented naive, way to find uncertainty using random perturbation of solution.
We challenge optimized ICP solution with random perturbation, and we rerun ICP.
If solution is true sharp global minimum, it will converge again, if not it will stay for this dimension.
To find covariance, we can compute covariance of resulting samples.

unc_time unc

I've tested it against https://huggingface.co/datasets/MichalPelka/UndegroundParkingDataset

/home/janusz/mandeye/HDMapping/cmake-build-relwithdebinfo/bin/session_uncertainty_calculation /home/janusz/mandeye/UndegroundParkingDataset/ground-truth/skierniewice_ground_truth_ZFIMAGER5010.laz /home/janusz/mandeye/UndegroundParkingDataset/mandeye/lio_result_0/session.mjs /home/janusz/mandeye/UndegroundParkingDataset/unc --method monte_carlo --node-step 100 --decimation 0.1 --tls-decimation 0.05

Agentic summary:

  • PairWiseICP / PoseGraphLoopClosure::compute_icp_uncertainty return the sigmas together with IcpResidualStatistics, which now carries the pose covariance sigma0^2 * (J^T J)^-1.
  • PairWiseICP::compute_icp_montecarlo runs ICP from randomly perturbed start poses (fixed seed) and returns the spread of the results (IcpSpread); PoseGraphLoopClosure::compute_icp_montecarlo runs it on an edge.
  • PairWiseICP::verbose (default true) silences the per-iteration log.
  • Step 2 loop closure GUI: an "uncertainty method" dropdown (point-to-point, point-to-plane, ICP Monte Carlo) with one Calculate button; shows the result tables and the 6x6 covariance in mm and degrees. The active edge's translation ellipsoid is drawn for the shown result (yellow: point-to-point/ plane at the current pose; magenta: Monte Carlo at the mean result).
  • session_uncertainty_calculation: new options --method, --search-radius, --runs, --start-offset-m, --start-offset-deg, --node-step, --decimation, --tls-decimation; the TLS is cropped to each chunk; one progress line per node with ETA. Defaults keep the previous results. The CSV gains the upper triangle of the pose covariance (cov_px_px ... cov_ka_ka) as extra columns.
  • scripts/plot_session_uncertainty.py plots that CSV: trajectory top view coloured by position sigma with x-y covariance ellipses, and the pose sigmas over time.

- PairWiseICP / PoseGraphLoopClosure::compute_icp_uncertainty return the sigmas
  together with IcpResidualStatistics, which now carries the pose covariance
  sigma0^2 * (J^T J)^-1.
- PairWiseICP::compute_icp_montecarlo runs ICP from randomly perturbed start
  poses (fixed seed) and returns the spread of the results (IcpSpread);
  PoseGraphLoopClosure::compute_icp_montecarlo runs it on an edge.
- PairWiseICP::verbose (default true) silences the per-iteration log.
- Step 2 loop closure GUI: an "uncertainty method" dropdown (point-to-point,
  point-to-plane, ICP Monte Carlo) with one Calculate button; shows the result
  tables and the 6x6 covariance in mm and degrees. The active edge's
  translation ellipsoid is drawn for the shown result (yellow: point-to-point/
  plane at the current pose; magenta: Monte Carlo at the mean result).
- session_uncertainty_calculation: new options --method, --search-radius,
  --runs, --start-offset-m, --start-offset-deg, --node-step, --decimation,
  --tls-decimation; the TLS is cropped to each chunk; one progress line per
  node with ETA. Defaults keep the previous results. The CSV gains the upper
  triangle of the pose covariance (cov_px_px ... cov_ka_ka) as extra columns.
- scripts/plot_session_uncertainty.py plots that CSV: trajectory top view
  coloured by position sigma with x-y covariance ellipses, and the pose
  sigmas over time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: MichalPelka <michalpelka@gmail.com>
@JanuszBedkowski
JanuszBedkowski merged commit 3fdd449 into main Nov 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants