measure: drop the stale metric map when VIO tracking is lost
- Commit
af038c9b996afba9b3f01592b4c2c0c61a2a98ae- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 20:13 UTC (29 days ago)
- Parents
4167dd5
Symptom: after a tracking loss and recovery, measurements could snap to the pre-loss floor plane and the next alignment attempt mixed keyframes from two different metric scales. Root cause: the Lost transition in push_frame only changed the quality flag. Keyframes (already rescaled into metres), landmarks and the fitted plane survived, so try_align resumed over a hybrid keyframe set and ray_to_world could still intersect the old plane once quality recovered. Fix: on entering Lost, clear keyframes, landmarks and the plane, reset scale/confidence/pose and drop queued IMU samples, so recovery re-initialises from a clean, single-scale state. This matches the documented contract that anchors from before a loss are no longer trustworthy. Verification: cargo test -p measure_vio --lib: 44 passed.
Diff
measure/src/main/rust/src/vio.rs
diff --git a/measure/src/main/rust/src/vio.rs b/measure/src/main/rust/src/vio.rsindex b2d766aac9..968b09f113 100644--- a/measure/src/main/rust/src/vio.rs+++ b/measure/src/main/rust/src/vio.rs@@ -203,6 +203,18 @@ impl VioSession { // still "initialising". if matches!(self.quality, Quality::Good | Quality::Limited) { self.quality = Quality::Lost;+ // The metric map belonged to the lost track: keyframes were+ // scaled by the old alignment and landmarks/plane refer to a+ // world frame that can no longer be re-observed. Keeping them+ // would let a later re-initialisation mix two scales in one+ // solve and keep snapping taps to a stale plane.+ self.keyframes.clear();+ self.landmarks.clear();+ self.plane = None;+ self.scale = 1.0;+ self.scale_confidence = 0.0;+ self.pose = CameraPose::identity();+ self.pending_imu.clear(); } self.prev_points = detect_points(gray); self.prev_ids = self.fresh_ids(self.prev_points.len());