refactor(vo): address final review — accurate docstring + update_depth_hint tests

Final review findings (Important):
- I1: e2e test docstring overclaimed — harness always uses ORBVisualOdometry.
  Rewrite docstring to describe the actual scope: smoke test + ORB regression
  guard. Wiring Mono-Depth wrapper through the harness is a sprint 2 task.
- I2: update_depth_hint had no tests. Add 2 tests: clamp at 1.0m for bogus
  values, and verify next compute_relative_pose uses the updated scale.
- I3: add TODO marker for sprint 2 deduplication with CuVSLAMVisualOdometry.

No behavior change — only docstrings, TODO markers, and test coverage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yuzviak
2026-04-18 16:29:00 +03:00
parent 44f96d6d2d
commit 759766d737
3 changed files with 59 additions and 9 deletions
+40
View File
@@ -301,3 +301,43 @@ def test_mono_depth_create_vo_backend_selects_it():
from gps_denied.core.vo import CuVSLAMMonoDepthVisualOdometry, create_vo_backend
vo = create_vo_backend(prefer_mono_depth=True, depth_hint_m=600.0)
assert isinstance(vo, CuVSLAMMonoDepthVisualOdometry)
def test_mono_depth_update_depth_hint_clamps_below_one():
"""update_depth_hint clamps bogus/negative barometer values to minimum 1.0m."""
from gps_denied.core.vo import CuVSLAMMonoDepthVisualOdometry
vo = CuVSLAMMonoDepthVisualOdometry(depth_hint_m=600.0)
vo.update_depth_hint(-5.0)
assert vo._depth_hint_m == 1.0
vo.update_depth_hint(0.0)
assert vo._depth_hint_m == 1.0
vo.update_depth_hint(0.5)
assert vo._depth_hint_m == 1.0
def test_mono_depth_update_depth_hint_affects_subsequent_scale():
"""update_depth_hint changes scale used by next compute_relative_pose call."""
from unittest.mock import patch
from gps_denied.core.vo import CuVSLAMMonoDepthVisualOdometry, ORBVisualOdometry
from gps_denied.schemas.vo import RelativePose
cam = CameraParameters(
focal_length=16.0, sensor_width=23.2, sensor_height=17.4,
resolution_width=640, resolution_height=480,
)
img = np.zeros((480, 640), dtype=np.uint8)
unit_pose = RelativePose(
translation=np.array([1.0, 0.0, 0.0]),
rotation=np.eye(3),
confidence=1.0, inlier_count=100, total_matches=100,
tracking_good=True, scale_ambiguous=True,
)
with patch.object(ORBVisualOdometry, "compute_relative_pose", return_value=unit_pose):
vo = CuVSLAMMonoDepthVisualOdometry(depth_hint_m=600.0)
pose_before = vo.compute_relative_pose(img, img, cam)
vo.update_depth_hint(1200.0)
pose_after = vo.compute_relative_pose(img, img, cam)
assert np.allclose(pose_before.translation, [1.0, 0.0, 0.0]) # 600/600 = 1.0x
assert np.allclose(pose_after.translation, [2.0, 0.0, 0.0]) # 1200/600 = 2.0x