fix(simulation): consume Nav2 local action completion
This commit is contained in:
@@ -194,3 +194,73 @@ def test_repeated_fresh_body_veto_retires_option_without_waiting_progress_timeou
|
||||
assert r.excluded == [selected['goal']]
|
||||
r.tick(p,now+2,choose)
|
||||
assert not r.blocked_option and r.blockage is None
|
||||
|
||||
|
||||
def completed_path(position, seconds, goal):
|
||||
return dict(status='waiting-for-plan', speed_mps=0., yaw_rate_rps=0.,
|
||||
diagnostic=dict(failure='native-action-complete'),
|
||||
action_result=dict(status='succeeded', kind='path', goal_xy=goal[:2]),
|
||||
route_observation=dict(observation=dict(pose=position,
|
||||
simulation_time_seconds=seconds, execution_inputs_sha256='run')))
|
||||
|
||||
|
||||
def test_native_local_completion_returns_to_mission_without_rejecting_goal():
|
||||
mission = WaypointMission([[10, 0]])
|
||||
def choose(*_):
|
||||
return [3., 0., 0.]
|
||||
selected = dict(goal=[2., 0., 0.], reverse=False)
|
||||
def maneuver(*_):
|
||||
return selected
|
||||
mission.update(pose(), 0, choose, choose_maneuver=maneuver)
|
||||
mission.update(pose(), 8, choose, choose_maneuver=maneuver)
|
||||
survey(mission.recovery, pose(), maneuver, 8)
|
||||
# A native local action can succeed outside the legacy 30 cm test. It is
|
||||
# completion of that action only, never the mission arrival receipt.
|
||||
position, now = pose(1.61), 12.
|
||||
receipt = completed_path(position, now, selected['goal'])
|
||||
r = mission.recovery
|
||||
r.observe_navigation(receipt, position, now, (r.sequence, r.option), 'run')
|
||||
goal, intent = mission.update(position, now, choose, choose_maneuver=maneuver)
|
||||
assert (goal, intent['state']) == (None, 'replanning')
|
||||
assert not r.active and r.excluded == [[3., 0., 0.]] and mission.index == 0
|
||||
assert intent['last_recovery_attempt']['completion'] == receipt['action_result']
|
||||
goal, intent = mission.update(position, now+.1, choose, choose_maneuver=maneuver)
|
||||
assert goal == [3., 0., 0.] and intent['state'] == 'following'
|
||||
assert mission.fault is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mismatch', ['run', 'time', 'pose', 'option', 'goal', 'kind',
|
||||
'failed', 'missing', 'nonzero', 'status'])
|
||||
def test_unbound_or_unsuccessful_result_cannot_complete_local_recovery(mismatch):
|
||||
r = ObservedRecovery()
|
||||
r.begin(pose(), 0, [])
|
||||
selected = dict(goal=[2., 0., 0.], reverse=False)
|
||||
def choose(*_):
|
||||
return selected
|
||||
survey(r, pose(), choose)
|
||||
position, now = pose(1.61), 2.
|
||||
receipt = completed_path(position, now, selected['goal'])
|
||||
key, run = (r.sequence, r.option), 'run'
|
||||
if mismatch == 'run':
|
||||
run = 'another-run'
|
||||
elif mismatch == 'time':
|
||||
now += .1
|
||||
elif mismatch == 'pose':
|
||||
position = pose(1.6)
|
||||
elif mismatch == 'option':
|
||||
key = (r.sequence, r.option+1)
|
||||
elif mismatch == 'goal':
|
||||
receipt['action_result']['goal_xy'] = [3., 0.]
|
||||
elif mismatch == 'kind':
|
||||
receipt['action_result']['kind'] = 'spin'
|
||||
elif mismatch == 'failed':
|
||||
receipt['action_result']['status'] = 'aborted'
|
||||
elif mismatch == 'missing':
|
||||
receipt.pop('action_result')
|
||||
elif mismatch == 'nonzero':
|
||||
receipt['speed_mps'] = .1
|
||||
elif mismatch == 'status':
|
||||
receipt['status'] = 'blocked'
|
||||
r.observe_navigation(receipt, position, now, key, run)
|
||||
r.tick(position, now+.1, choose)
|
||||
assert r.active and r.selected == selected
|
||||
|
||||
Reference in New Issue
Block a user