fix(simulation): consume Nav2 local action completion

This commit is contained in:
DCCONSTRUCTIONS
2026-10-08 14:00:54 +03:00
parent 6a89f809a4
commit bc915c01e1
5 changed files with 149 additions and 3 deletions
+21
View File
@@ -83,6 +83,18 @@ class Navigation:
return dict(speed_mps=0., yaw_rate_rps=0., status=status, path=[],
diagnostic=dict(failure=reason), **extra)
def completed_action(self, key, route):
terminal = self.node.terminal
if (key == self.action_key and key[0] in {'path', 'backup'}
and terminal is not None and terminal.done()
and terminal.result().status == GoalStatus.STATUS_SUCCEEDED):
# Preserve the native terminal result before a sensor refresh can
# submit the same FollowPath again. This is local-action completion,
# not whole-body arrival admission and never a motion proposal.
return self.reply('native-action-complete', route_observation=route,
action_result=dict(status='succeeded', kind=key[0], goal_xy=list(key[1])))
return None
def plan(self, value):
entered = time.monotonic()
if self.failure:
@@ -170,6 +182,9 @@ class Navigation:
self.node.stop()
return self.reply('reverse-goal-is-not-behind', status='blocked')
key = ('backup', tuple(goal[:2]), limit)
completed = self.completed_action(key, route)
if completed is not None:
return completed
if key != self.action_key:
with self.owner_lock:
self.action_key = None
@@ -180,6 +195,9 @@ class Navigation:
# a path update; the existing capture leases and raw range gates
# still validate every command against the caller's observation.
key = ('path', tuple(goal[:2]), limit)
completed = self.completed_action(key, route)
if completed is not None:
return completed
continuing = key == self.action_key
# Match the pinned Nav2 BT's 1 Hz ComputePathToPose cadence.
# The path is an intent, not a sensor sample: terrain, costmaps,
@@ -202,6 +220,9 @@ class Navigation:
for p in path.poses]
with self.owner_lock:
self.action_key = key
completed = self.completed_action(key, route)
if completed is not None:
return completed
native = self.node.native_command()
if native is None:
terminal = self.node.terminal.result() if self.node.terminal and self.node.terminal.done() else None