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
+70
View File
@@ -295,3 +295,73 @@ def test_only_bound_native_abort_retires_the_local_option(reverse, mismatch):
if mismatch is None:
assert r.tick(position, now+.1, choose)[0] is None
assert r.excluded == [selected['goal']]
@pytest.mark.parametrize("reverse", [False, True])
def test_native_action_finishes_its_own_distance_before_returning_to_route(reverse):
r = ObservedRecovery()
r.begin(pose(), 0, [])
sign = -1 if reverse else 1
selected = dict(goal=[sign*.7, 0., 0.], reverse=reverse)
choose = lambda *_: selected
now = survey(r, pose(), choose)
receipt = completed_path(pose(), now, selected['goal'])
receipt.update(status='path', speed_mps=sign*.1,
controller_goal=['backup' if reverse else 'path', selected['goal'][:2], .1])
receipt.pop('action_result')
r.observe_navigation(receipt, pose(), now, (r.sequence, r.option), 'run')
position = pose(sign*.45)
r.observe_view(r.view_request(position, now+1), position, now+1)
assert r.tick(position, now+1, choose) == (
selected['goal'], 'reversing' if reverse else 'manoeuvring')
assert r.active and r.completion is None
# A completed native action stops intent even slightly past its goal.
position = pose(sign*.71)
receipt = completed_path(position, now+2, selected['goal'])
receipt['action_result']['kind'] = 'backup' if reverse else 'path'
r.observe_navigation(receipt, position, now+2, (r.sequence, r.option), 'run')
assert r.tick(position, now+2, choose) == (None, 'replanning')
assert not r.active
@pytest.mark.parametrize('mismatch', ['run', 'time', 'pose', 'option', 'goal', 'kind'])
def test_unbound_owner_cannot_suppress_legacy_completion(mismatch):
r = ObservedRecovery()
r.begin(pose(), 0, [])
selected = dict(goal=[-.7, 0., 0.], reverse=True)
choose = lambda *_: selected
now = survey(r, pose(), choose)
receipt = completed_path(pose(), now, selected['goal'])
receipt.update(status='path', speed_mps=-.1,
controller_goal=['backup', [-.7, 0.], .1])
receipt.pop('action_result')
position, key, run = pose(), (r.sequence, r.option), 'run'
if mismatch == 'run': run = 'other'
elif mismatch == 'time': now += .1
elif mismatch == 'pose': position = pose(.1)
elif mismatch == 'option': key = (r.sequence, r.option+1)
elif mismatch == 'goal': receipt['controller_goal'][1] = [-1., 0.]
elif mismatch == 'kind': receipt['controller_goal'][0] = 'spin'
r.observe_navigation(receipt, position, now, key, run)
assert r.native_action is None
assert r.tick(pose(-.45), now+1, choose) == (None, 'replanning')
def test_native_owner_does_not_bypass_unknown_view_or_progress_budget():
r = ObservedRecovery()
r.begin(pose(), 0, [])
selected = dict(goal=[-.7, 0., 0.], reverse=True)
choose = lambda *_: selected
now = survey(r, pose(), choose)
receipt = completed_path(pose(), now, selected['goal'])
receipt.update(status='path', speed_mps=-.1,
controller_goal=['backup', [-.7, 0.], .1])
receipt.pop('action_result')
r.observe_navigation(receipt, pose(), now, (r.sequence, r.option), 'run')
# Close enough for the former distance threshold, but no current rear view.
assert r.tick(pose(-.45), now+3, choose) == (None, 'surveying')
assert r.active
assert r.tick(pose(-.45), now+12, choose) == (None, 'surveying')
assert r.excluded == [selected['goal']]
r.tick(pose(-.45), now+12.1, choose)
assert r.native_action is None