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
+7 -1
View File
@@ -92,12 +92,15 @@ class ContinuousPipeline:
"simulation_time_ns": simulation_time_ns})
self.condition.notify_all()
def observe_pose(self, pose, speed, captured_at, *, measured_twist=None):
def observe_pose(self, pose, speed, captured_at, *, measured_twist=None, simulation_time_ns=None):
# Called from the physics callback: only an in-memory bounded publish.
if measured_twist is not None and (len(measured_twist) != 3 or
not all(math.isfinite(value) for value in measured_twist)):
raise ValueError('Invalid measured planar twist')
if simulation_time_ns is not None and (type(simulation_time_ns) is not int or simulation_time_ns < 0):
raise ValueError('Invalid measured simulation time')
with self.condition:
self.pose_simulation_time = (simulation_time_ns, captured_at)
self.pose = (list(pose), float(speed), captured_at)
self.pose_twist = None if measured_twist is None else (tuple(measured_twist), captured_at)
@@ -275,6 +278,7 @@ class ContinuousPipeline:
guard = self.route_guard
sensor = self.sensor
measured_twist = getattr(self, 'pose_twist', None)
pose_simulation_time = getattr(self, 'pose_simulation_time', None)
enabled = self.enabled and self.ready
intent_revision = self.intent_revision
if connection_epoch != epoch:
@@ -288,6 +292,8 @@ class ContinuousPipeline:
perception_age_seconds=max(0, started-perception[1]["observation"]["captured_at"]),
observation_id=result["observation_id"],
enabled=result["decision"]["reason"] in {"road", "replanning"})
if pose_simulation_time is not None and pose_simulation_time[1] == pose[2]:
payload['pose_simulation_time_ns'] = pose_simulation_time[0]
if measured_twist is not None and measured_twist[1] == pose[2]:
payload['measured_twist'] = list(measured_twist[0])
range_identity = sensor[:2] if sensor is not None else None