Reconsider transient native planner rejections after bounded backoff
This commit is contained in:
@@ -146,3 +146,14 @@ Read-only Nav2 `/diagnostic-snapshot` сохраняет последний за
|
||||
terrain необходимо сверять observation ID: одинаковость разных транзакций
|
||||
не предполагается. Такой снимок — диагностическое свидетельство, не replay-
|
||||
или native-приёмка проезда.
|
||||
|
||||
|
||||
Временный native `ComputePathToPose` abort исключает наблюдаемую локальную
|
||||
цель на 2 секунды времени мира. После паузы между попытками она снова может
|
||||
участвовать в выборе только через обычные наблюдённые точки и новый native-путь.
|
||||
Отказ планировщика не становится постоянным пространственным запретом.
|
||||
Внутри текущей recovery-попытки исключения сохраняются, чтобы перебор вариантов
|
||||
не зацикливался; срок рассматривается после её завершения. Исключения за
|
||||
отсутствие фактического продвижения не снимаются этим механизмом. Истечение
|
||||
срока не обновляет watchdog, не пополняет бюджет recovery, не засчитывает
|
||||
продвижение и не меняет `no_go`, сенсорную опору или допуск движения.
|
||||
|
||||
@@ -25,6 +25,7 @@ def inclination(pose):
|
||||
class WaypointMission:
|
||||
turn_budget_seconds = 24
|
||||
heading_progress_radians = 0.15
|
||||
native_plan_retry_seconds = 2.0
|
||||
|
||||
def __init__(self, route):
|
||||
self.route = [list(p) for p in route]
|
||||
@@ -34,6 +35,8 @@ class WaypointMission:
|
||||
self.last_pose = None
|
||||
self.state = "following"
|
||||
self.failed_goals = []
|
||||
self.native_plan_rejections = {}
|
||||
self.last_native_plan_retry = None
|
||||
self.goal = None
|
||||
self.fault = None
|
||||
self.best_distance = None
|
||||
@@ -153,7 +156,29 @@ class WaypointMission:
|
||||
and result.get("speed_mps") == result.get("yaw_rate_rps") == 0.
|
||||
and result.get("planning_result") == dict(
|
||||
status="aborted", goal_xy=list(self.goal[:2]))):
|
||||
rejected = list(self.goal)
|
||||
self.retire_local_goal(self.arrival_target(), failed=True)
|
||||
if self.goal is None:
|
||||
self.native_plan_rejections[tuple(rejected)] = seconds + self.native_plan_retry_seconds
|
||||
|
||||
def retry_native_goals(self, seconds):
|
||||
"""A planner abort is temporary evidence, not a permanent no-go zone.
|
||||
|
||||
Back off across several observations before allowing a measured goal
|
||||
to compete again. Recovery keeps its round-robin exclusions for the
|
||||
current attempt. Expiry never supplies a goal, refreshes a progress
|
||||
deadline, replenishes retries or bypasses native/sensor admission.
|
||||
"""
|
||||
if self.recovery.active:
|
||||
return
|
||||
expired = {goal for goal, deadline in self.native_plan_rejections.items()
|
||||
if seconds >= deadline}
|
||||
if not expired:
|
||||
return
|
||||
self.failed_goals = [goal for goal in self.failed_goals if tuple(goal) not in expired]
|
||||
for goal in expired:
|
||||
del self.native_plan_rejections[goal]
|
||||
self.last_native_plan_retry = dict(seconds=seconds, goals=[list(g) for g in sorted(expired)])
|
||||
|
||||
def arrival_candidate(self, pose):
|
||||
return bool(
|
||||
@@ -223,6 +248,7 @@ class WaypointMission:
|
||||
self.fault = "unstable"
|
||||
if self.fault:
|
||||
return None, self.intent(self.fault)
|
||||
self.retry_native_goals(seconds)
|
||||
if self.recovery.active:
|
||||
selected, state = self.recovery.tick(pose, seconds, choose_maneuver)
|
||||
self.state = state
|
||||
@@ -271,6 +297,7 @@ class WaypointMission:
|
||||
self.best_distance = distance
|
||||
self.attempts = 0
|
||||
self.failed_goals.clear()
|
||||
self.native_plan_rejections.clear()
|
||||
self.turn_started = self.turn_goal = self.turn_best_error = None
|
||||
elif self.heading_progress(pose, seconds):
|
||||
self.anchor_time = seconds
|
||||
@@ -309,6 +336,8 @@ class WaypointMission:
|
||||
waypoint=self.index,
|
||||
waypoint_count=len(self.route),
|
||||
recovery_attempt=self.attempts,
|
||||
**({"last_native_plan_retry": self.last_native_plan_retry}
|
||||
if self.last_native_plan_retry is not None else {}),
|
||||
**({"recovery": self.recovery.evidence()} if self.recovery.active else {}),
|
||||
**({"last_recovery_attempt": copy.deepcopy(self.last_recovery_attempt)}
|
||||
if self.last_recovery_attempt is not None else {}),
|
||||
|
||||
@@ -297,3 +297,53 @@ def test_native_abort_keeps_task_arrival_evidence_and_requires_new_observation()
|
||||
assert mission.goal == first and mission.failed_goals == []
|
||||
assert mission.update(pose(), .1, lambda *_: None)[0] is None
|
||||
assert mission.index == 0 and mission.fault is None
|
||||
|
||||
|
||||
def test_aborted_goal_can_be_reobserved_after_backoff_without_progress_credit():
|
||||
mission = WaypointMission([[8, 0]])
|
||||
measured = [2., 0., 0.]
|
||||
visible = True
|
||||
|
||||
def choose(_target, _prior, excluded):
|
||||
return measured if visible and measured not in excluded else None
|
||||
|
||||
mission.update(pose(), 0, choose)
|
||||
mission.reject_local_plan(aborted_plan(measured, pose(), 0), pose(), 0, "run")
|
||||
assert mission.update(pose(), 1.9, choose)[0] is None
|
||||
# Expiry itself supplies neither a destination nor surface permission.
|
||||
visible = False
|
||||
assert mission.update(pose(), 2., choose)[0] is None
|
||||
assert mission.goal is None and mission.anchor_time == 0 and mission.attempts == 0
|
||||
visible = True
|
||||
assert mission.update(pose(), 2.1, choose)[0] == measured
|
||||
assert mission.anchor_time == 0 and mission.attempts == 0
|
||||
assert mission.index == 0 and mission.fault is None
|
||||
|
||||
|
||||
def test_repeated_abort_refreshes_backoff_but_not_stall_deadline():
|
||||
mission = WaypointMission([[8, 0]])
|
||||
measured = [2., 0., 0.]
|
||||
choose = lambda _target, _prior, excluded: measured if measured not in excluded else None
|
||||
for seconds in (0., 2., 4., 6.):
|
||||
assert mission.update(pose(), seconds, choose)[0] == measured
|
||||
mission.reject_local_plan(aborted_plan(measured, pose(), seconds), pose(), seconds, "run")
|
||||
assert mission.update(pose(), seconds + 1., choose)[0] is None
|
||||
assert mission.anchor_time == 0
|
||||
mission.update(pose(), 8., choose)
|
||||
assert mission.attempts == 1
|
||||
|
||||
|
||||
def test_native_backoff_does_not_clear_current_recovery_round_or_motion_failures():
|
||||
mission = WaypointMission([[8, 0]])
|
||||
first, _ = mission.update(pose(), 0, goal)
|
||||
mission.reject_local_plan(aborted_plan(first, pose(), 0), pose(), 0, "run")
|
||||
other = [3., 1., 0.]
|
||||
mission.failed_goals.append(other) # A progress failure, not a planner abort.
|
||||
mission.recovery.begin(pose(), 1., mission.failed_goals)
|
||||
mission.retry_native_goals(3.)
|
||||
assert mission.failed_goals == [first, other]
|
||||
assert mission.recovery.excluded == [first, other]
|
||||
mission.recovery.phase = "idle"
|
||||
mission.retry_native_goals(3.)
|
||||
assert mission.failed_goals == [other]
|
||||
assert mission.attempts == 0 and mission.anchor_time == 0
|
||||
|
||||
Reference in New Issue
Block a user