Align Nav2 with physics time and preserve complete simulation scenes
This commit is contained in:
@@ -72,3 +72,12 @@ def test_clearance_potential_spans_the_local_intent_horizon(configured):
|
||||
cost = lambda d: 252*math.exp(-layer['cost_scaling_factor']*d)
|
||||
assert cost(1.) > cost(2.) > cost(3.) > 1.
|
||||
assert grid['footprint_padding'] == .05 and grid['track_unknown_space']
|
||||
|
||||
|
||||
def test_simulation_clock_reaches_every_native_node_and_costmap(configured):
|
||||
configure, inputs, robot = configured
|
||||
config = configure(inputs, robot, use_sim_time=True)
|
||||
for name in ('planner_server', 'controller_server', 'behavior_server'):
|
||||
assert config[name]['ros__parameters']['use_sim_time'] is True
|
||||
for name in ('global_costmap', 'local_costmap'):
|
||||
assert config[name][name]['ros__parameters']['use_sim_time'] is True
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user