Align Nav2 with physics time and preserve complete simulation scenes

This commit is contained in:
DCCONSTRUCTIONS
2026-10-09 22:15:20 +03:00
parent 3376b1a9e6
commit 16865574d0
15 changed files with 262 additions and 65 deletions
+35
View File
@@ -118,3 +118,38 @@ def test_recovery_acknowledges_the_side_capture_pose_and_time(modules):
assert submitted[0]["source.pose"] == live["pose"]
assert submitted[0]["source.camera.lens-depths"] == front["lens_depths"]
assert [v["lens_depths"] for v in submitted[0]["source.detection-views"]] == [[1.], [2.]]
def test_controller_uses_physics_stamp_but_wall_time_freshness(modules, monkeypatch, tmp_path):
_, module = modules
import numpy as np
pipeline = module.ContinuousPipeline(None, tmp_path, clock=lambda: 100.)
pipeline.enable(True)
pipeline.ready = True
pipeline.model = SimpleNamespace(inputs={"sha256": "inputs"})
pipeline.await_model = lambda: True
pipeline.observe_pose([1, 0, 0, 0, 0, 0, 1], .4, 99.95,
measured_twist=(.4, 0, 0), simulation_time_ns=25_000_000_000)
pipeline.perception = (pipeline.epoch, {"observation": {"captured_at": 99.6}})
pipeline.sensor = (pipeline.epoch, 1, {"captured_at": 99.9, "points": np.zeros((0, 3))})
pipeline.result = {"observation_id": "live", "captured_at": 99.8,
"decision": {"reason": "road"}}
sent = []
class Connection:
def close(self): pass
def request(self, path, payload):
sent.append((path, payload))
pipeline.closed = True
return dict(reason="none", observation_id="live", speed_mps=.4, yaw_rate_rps=0)
monkeypatch.setattr(module, "NavigationClient", Connection)
pipeline.control_loop()
path, payload = sent[0]
assert path == "/control"
assert payload["pose_simulation_time_ns"] == 25_000_000_000
assert payload["pose_age_seconds"] == pytest.approx(.05)
assert payload["perception_age_seconds"] == pytest.approx(.4)
assert payload["measured_twist"] == [.4, 0, 0]
import json
record = json.loads((tmp_path / "controller.jsonl").read_text())
assert record["expires_at"] == pytest.approx(100.25)
assert record["freshness_deadlines"]["range"] == pytest.approx(100.7)