Reconstruction (pi/reconstruction/)

The M3 reconstruction: it turns a batch of 2D detection records — the same LED seen from many camera poses — into a per-LED 3D position. DLT triangulation seeds each point, a sparse Huber bundle adjustment refines all positions jointly, outliers are rejected, and the result is quality-scored and emitted as an OutputMap. It is the Python reference the Rust The solver (solver/) is a port of.

Key files

  • reconstruction/api.py — reconstruct(detections, ...) -> OutputMap, the public entry point.

  • reconstruction/triangulate.py — DLT triangulation and parallax.

  • reconstruction/bundle.py — the sparse bundle adjustment.

  • reconstruction/camera.py — the pinhole camera model (shared with the simulator).

  • reconstruction/vio.py, vio_api.py, vio_replay.py — the joint visual-inertial solve and offline replay (see Design notes).

Run

# Reconstruct a map from a detection log:
bazel run //pi/reconstruction:reconstruct -- session.json -o map.json

bazel test //pi/reconstruction:reconstruct_test
bazel test //pi/reconstruction:rust_parity_test   # parity with solver/

How well it recovers a shape

The The simulator (shared/simulator/) generates detection logs for known fixtures, so the recovery error can be measured exactly. This figure — regenerated by //docs:build from the real simulator → reconstruction path — overlays the recovered positions on ground truth:

Ground truth vs reconstructed LED positions

Ground truth (hollow) vs reconstruction (filled, colored by per-LED error) for a helix fixture.

The reconstruction quality metrics and the outlier-rejection rationale are in the design spec (§7.5, §8.3, §12). For fixtures behind a diffuser, where only a sparse subset of LEDs is lit at a time, see Strided (diffuse) capture: mapping LEDs behind a diffuser: what ties the phases into one rigid map, and why the solve never drops observations across the decode gaps.