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
+10 -8
View File
@@ -19,20 +19,21 @@ def _positive(value, name):
def build_scheduling_policy(*, continuous, physics_dt, capture_hz, main_loop_hz,
catch_up_mode="render-period-catchup"):
"""Derive a native integer clamp from the declared main-loop cadence.
catch_up_mode="sensor-period-catchup"):
"""Bound native catch-up by one sensor acquisition period, not display FPS.
For fractional main-loop rates, round only the native setting upward;
For fractional acquisition/display rates, round only the native setting upward;
the requested loop and sensor cadences are unchanged. The ceil step bound is a
conservative runtime guard, not a promise that every update executes that
many steps. 60Hz physics/30Hz main loop gives an exact two-step cap.
many steps. 60Hz physics/10Hz sensing gives a six-step cap. Display-rate catch-up
remains available for qualification against the previous two-step clamp.
Explicit legacy-wall-catchup permits a same-build continuous A/B comparison;
noncontinuous execution always retains the legacy one-Hz clamp.
Existing execution-input validation owns the supported capture-rate range.
"""
if type(continuous) is not bool:
raise ValueError("Invalid scheduling continuous mode")
if catch_up_mode not in ("render-period-catchup", "legacy-wall-catchup"):
if catch_up_mode not in ("sensor-period-catchup", "render-period-catchup", "legacy-wall-catchup"):
raise ValueError("Invalid scheduling catch-up mode")
physics_dt = _positive(physics_dt, "physics dt")
capture_hz = _positive(capture_hz, "capture rate")
@@ -40,7 +41,8 @@ def build_scheduling_policy(*, continuous, physics_dt, capture_hz, main_loop_hz,
physics_hz = _positive(1 / physics_dt, "physics rate")
effective_mode = catch_up_mode if continuous else "legacy-wall-catchup"
render_period = effective_mode == "render-period-catchup"
minimum = math.ceil(main_loop_hz) if render_period else 1
sensor_period = effective_mode == "sensor-period-catchup"
minimum = math.ceil(capture_hz) if sensor_period else math.ceil(main_loop_hz) if render_period else 1
maximum_steps = math.ceil(physics_hz / minimum)
return dict(
schema_version=SCHEMA,
@@ -58,8 +60,8 @@ def build_scheduling_policy(*, continuous, physics_dt, capture_hz, main_loop_hz,
max_physics_steps_per_update=maximum_steps,
max_requested_physics_interval_seconds=1 / minimum,
max_integrated_seconds_per_update=maximum_steps * physics_dt,
derivation=("ceil-main-loop-rate" if render_period else "legacy-one-hz-clamp"),
native_rate_rounding=("up-to-integer" if render_period else "none"),
derivation=("ceil-sensor-rate" if sensor_period else "ceil-main-loop-rate" if render_period else "legacy-one-hz-clamp"),
native_rate_rounding=("up-to-integer" if sensor_period or render_period else "none"),
step_bound_rounding="ceil-conservative-verify-native-counts",
overload_policy="discard-excess-wall-time-demand-and-report-lower-rtf",
simulation_clock="sum-completed-physics-dt",