Guide local goals around observed obstacles and finish native recovery

This commit is contained in:
DCCONSTRUCTIONS
2026-10-09 13:06:04 +03:00
parent 51406fc90c
commit ade3c19d2a
10 changed files with 281 additions and 12 deletions
@@ -36,6 +36,7 @@ class ObservedRecovery:
self.blocked_option = False
self.failure = None
self.completion = None
self.native_action = None
@property
def active(self):
@@ -56,6 +57,7 @@ class ObservedRecovery:
self.blocked_option = False
self.failure = None
self.completion = None
self.native_action = None
def observe_navigation(self, result, pose, seconds, option_key, execution_inputs_sha256):
"""Consume bound completion or retire a consistently vetoed intention.
@@ -70,6 +72,16 @@ class ObservedRecovery:
execution_inputs_sha256=execution_inputs_sha256)
if observation != expected:
return
owner = result.get("controller_goal") or []
if (self.selected is not None and self.selected.get("kind") != "orient"
and result.get("status") == "path" and len(owner) == 3
and owner[0] == ("backup" if self.selected["reverse"] else "path")
and list(owner[1]) == list(self.selected["goal"][:2])):
# The bound native action owns its stopping tolerance. A second
# 30 cm arrival test used to cancel short retreats halfway through.
# Ownership never grants motion: current views, ground, obstacles
# and measured progress still govern every subsequent command.
self.native_action = dict(kind=owner[0], goal_xy=list(owner[1]))
completion = result.get("action_result")
if (self.selected is not None and self.selected.get("kind") != "orient"
and result.get("status") == "waiting-for-plan"
@@ -216,6 +228,7 @@ class ObservedRecovery:
self.best_heading = math.inf
self.blockage = None
self.blocked_option = False
self.native_action = None
if self.phase == "executing":
distance = math.dist(pose[:2], self.selected["goal"][:2])
observed = choose(self.selected, self.excluded)
@@ -223,7 +236,7 @@ class ObservedRecovery:
desired = math.atan2(dy, dx) + (math.pi if self.selected["reverse"] else 0)
error = abs(angle(desired-heading(pose)))
orienting = self.selected.get("kind") == "orient"
if (error <= .1 if orienting else distance <= .3):
if (error <= .1 if orienting else self.native_action is None and distance <= .3):
self.phase = "idle"
return None, "replanning"
if self.best_distance-distance >= .1 or self.best_heading-error >= .05:
@@ -258,4 +271,5 @@ class ObservedRecovery:
def evidence(self):
return dict(phase=self.phase, option=self.option, selected=self.selected,
surveyed_sectors=sorted(self.views), request=self.request,
rejected_goals=self.excluded, failure=self.failure)
rejected_goals=self.excluded, failure=self.failure,
native_action=self.native_action)