Allow bounded physics catch-up beyond sensor acquisition overhead
This commit is contained in:
@@ -42,3 +42,24 @@ def test_invalid_clocks_and_rates_are_rejected(cadence):
|
||||
cadence(10, float("nan"))
|
||||
with pytest.raises(ValueError):
|
||||
cadence(10, 0.).due(float("nan"))
|
||||
|
||||
|
||||
def test_physics_catchup_has_headroom_for_acquisition_without_changing_clocks(monkeypatch):
|
||||
monkeypatch.syspath_prepend(str(Path(__file__).parents[1] / "simulation/ai-polygon"))
|
||||
build = importlib.import_module("scheduling_policy").build_scheduling_policy
|
||||
settings = dict(continuous=True, physics_dt=1/60, capture_hz=10, main_loop_hz=30)
|
||||
candidate = build(**settings)
|
||||
prior = build(**settings, catch_up_mode="sensor-period-catchup")
|
||||
assert candidate["physics_dt_seconds"] == prior["physics_dt_seconds"] == 1/60
|
||||
assert candidate["capture_hz"] == prior["capture_hz"] == 10
|
||||
assert candidate["freshness_clock"] == prior["freshness_clock"]
|
||||
assert candidate["min_simulation_frame_rate_hz"] == 5
|
||||
assert candidate["max_physics_steps_per_update"] == 12
|
||||
assert candidate["max_integrated_seconds_per_update"] == pytest.approx(.2)
|
||||
# A measured ~125ms loop needs 7 or 8 steps. The former six-step
|
||||
# clamp discarded time even though there was room to integrate it.
|
||||
demanded = [7, 8, 7, 8]
|
||||
assert sum(min(n, prior["max_physics_steps_per_update"]) for n in demanded) == 24
|
||||
assert sum(min(n, candidate["max_physics_steps_per_update"]) for n in demanded) == 30
|
||||
legacy = build(**{**settings, "continuous":False})
|
||||
assert legacy["min_simulation_frame_rate_hz"] == 1
|
||||
|
||||
Reference in New Issue
Block a user