Bound retries for unreachable path recovery

This commit is contained in:
Tanner committed 2026-11-19 15:57:32 +00:00
1 parent d4eae5ee5f
commit 7ab354800b
4 files changed
+71 -6

No files matched your search

+27 -5
View File
@@ -123,6 +123,7 @@ def missing_movement_chunks(g):
PATH_VALIDATION_INTERVAL = 0.25
PATH_RECOVERY_RETRY_INTERVAL = 1.0
PATH_RECOVERY_MAX_ATTEMPTS = 3
def _recover_invalid_path(g, now=None):
@@ -135,6 +136,8 @@ def _recover_invalid_path(g, now=None):
if g.get('navigation_recovery_target') is not None:
g.navigation_recovery_target = None
g.navigation_retry_at = 0.0
g.navigation_recovery_attempts = 0
g.navigation_failed_target = None
if now >= g.get('path_validation_at', 0.0):
g.path_validation_at = now + PATH_VALIDATION_INTERVAL
try:
@@ -149,6 +152,8 @@ def _recover_invalid_path(g, now=None):
g.path = []
g.navigation_recovery_target = target
g.navigation_retry_at = 0.0
g.navigation_recovery_attempts = 0
g.navigation_failed_target = None
target = g.get('navigation_recovery_target')
if target is None or now < g.get('navigation_retry_at', 0.0):
@@ -158,6 +163,7 @@ def _recover_invalid_path(g, now=None):
if position == tuple(target):
g.navigation_recovery_target = None
g.navigation_retry_at = 0.0
g.navigation_recovery_attempts = 0
return
try:
@@ -168,14 +174,24 @@ def _recover_invalid_path(g, now=None):
g.path = navpath
g.navigation_recovery_target = None
g.navigation_retry_at = 0.0
g.navigation_recovery_attempts = 0
g.navigation_failed_target = None
print('[movement] rerouted to {}'.format(target), flush=True)
else:
g.path = []
g.navigation_retry_at = now + PATH_RECOVERY_RETRY_INTERVAL
if now >= g.get('navigation_retry_log_at', 0.0):
print('[movement] no route to {}; will retry'.format(target),
flush=True)
g.navigation_retry_log_at = now + 5.0
attempts = g.get('navigation_recovery_attempts', 0) + 1
g.navigation_recovery_attempts = attempts
if attempts >= PATH_RECOVERY_MAX_ATTEMPTS:
print('[movement] giving up on unreachable path target {} '
'after {} attempts'.format(target, attempts), flush=True)
g.navigation_recovery_target = None
g.navigation_retry_at = 0.0
g.navigation_recovery_attempts = 0
g.navigation_failed_target = tuple(target)
else:
g.navigation_retry_at = now + PATH_RECOVERY_RETRY_INTERVAL
print('[movement] no route to {}; retry {}/{}'.format(
target, attempts, PATH_RECOVERY_MAX_ATTEMPTS), flush=True)
def tick(global_state):
@@ -505,6 +521,8 @@ def start_automation(global_state, initialize=True):
g.path = []
g.navigation_recovery_target = None
g.navigation_retry_at = 0.0
g.navigation_recovery_attempts = 0
g.navigation_failed_target = None
g.path_validation_at = 0.0
g.look_at = None
g.y_v = 0.0
@@ -571,6 +589,10 @@ def start_automation(global_state, initialize=True):
g.setdefault('holding_slot', 0)
g.setdefault('holding_hand', 0)
g.setdefault('time', 0.0)
g.setdefault('navigation_recovery_target', None)
g.setdefault('navigation_retry_at', 0.0)
g.setdefault('navigation_recovery_attempts', 0)
g.setdefault('navigation_failed_target', None)
old_stop = g.get('movement_stop_event')
old_worker = g.get('movement_thread')