Advance passed advisory route joints from observed body progress
This commit is contained in:
@@ -80,9 +80,22 @@ def test_support_is_current_and_positive_but_does_not_grant_a_path_or_arrival(br
|
||||
assert 'route_support' not in navigation.plan(unrelated)
|
||||
|
||||
|
||||
def test_route_support_rejects_remote_or_wrongly_bound_target(bridge):
|
||||
def test_remote_hint_assesses_current_body_without_granting_remote_terrain(bridge):
|
||||
navigation, _, value = bridge
|
||||
for change in ({'route_transition_target': [4., 0.]}, {'execution_inputs_sha256': 'b'*64}):
|
||||
value['route_transition_target'] = [14., -8.]
|
||||
result = navigation.plan(value)
|
||||
receipt = result['route_support']
|
||||
assert receipt['admitted'] is True
|
||||
assert receipt['observation']['pose'] == value['pose']
|
||||
assert receipt['observation']['target_xy'] == [14., -8.]
|
||||
assert result['status'] == 'blocked' and 'arrival' not in result
|
||||
assert result['speed_mps'] == result['yaw_rate_rps'] == 0.
|
||||
|
||||
|
||||
def test_route_support_rejects_invalid_or_wrongly_bound_target(bridge):
|
||||
navigation, _, value = bridge
|
||||
for change in ({'route_transition_target': [float('nan'), 0.]},
|
||||
{'route_transition_target': [4.]}, {'execution_inputs_sha256': 'b'*64}):
|
||||
with pytest.raises(ValueError, match='transition observation'):
|
||||
navigation.plan({**value, **change})
|
||||
|
||||
|
||||
@@ -226,6 +226,61 @@ def test_observed_detour_can_pass_advisory_joint_without_returning_to_line(condi
|
||||
assert mission.confirm_corridor_transition(pose, 10., body) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('angle', [0., .9, -2.1])
|
||||
@pytest.mark.parametrize('offset', [-8., 8.])
|
||||
@pytest.mark.parametrize('condition', ['passed', 'early', 'unknown', 'stale',
|
||||
'forbidden', 'return', 'reverse', 'recovering'])
|
||||
def test_passed_advisory_joint_uses_progress_and_current_body_not_lateral_distance(
|
||||
angle, offset, condition):
|
||||
from k1link.simulation.ai_polygon.route_mission import RoutedMission
|
||||
*_, inputs, _ = fixture()
|
||||
inputs['routing']['blocked_edges'] = ['0', '1', '2']
|
||||
rotation = np.array([[math.cos(angle), -math.sin(angle)],
|
||||
[math.sin(angle), math.cos(angle)]])
|
||||
origin = np.array([37., -23.])
|
||||
def world(xy):
|
||||
return (rotation @ xy + origin).tolist()
|
||||
for node in inputs['routing']['map']['nodes']:
|
||||
node['xy'] = world(node['xy'])
|
||||
graph = inputs['routing']['map']
|
||||
graph['sha256'] = digest({k: v for k, v in graph.items() if k != 'sha256'})
|
||||
inputs.update(sensors={'schema_version': 'missioncore.simulation-sensor-rig/v4'},
|
||||
behavior={'max_speed_mps': 1.})
|
||||
inputs['mission']['route_xy'] = [world([12., 0.])]
|
||||
mission = RoutedMission(inputs)
|
||||
mission.route_observation([*world([0., 0.]), 0., 0., 0., 0., 1.], 0.)
|
||||
pose = [*world([offset, 4.5 if condition == 'early' else 5.5]), 0., 0., 0., 0., 1.]
|
||||
mission.route_observation(pose, 10.)
|
||||
mission.last_time, mission.last_pose = 10., tuple(pose)
|
||||
body = dict(observation=dict(pose=pose, target_xy=mission.arrival_target(),
|
||||
simulation_time_seconds=10., execution_inputs_sha256=inputs['sha256']),
|
||||
admitted=True, collision_free=True, support_known=True,
|
||||
positive_surface_required=True, support_samples=4, supported_samples=4)
|
||||
if condition == 'unknown':
|
||||
body.update(admitted=False, support_known=False, supported_samples=0)
|
||||
if condition == 'stale':
|
||||
body['observation']['simulation_time_seconds'] = 9.
|
||||
if condition == 'forbidden':
|
||||
mission.global_route['no_go'] = [dict(lower_xy=(np.array(pose[:2])-.2).tolist(),
|
||||
upper_xy=(np.array(pose[:2])+.2).tolist())]
|
||||
if condition == 'return':
|
||||
mission.leg['segments'][0]['return_to_anchor'] = True
|
||||
if condition == 'reverse':
|
||||
mission.leg['segments'][1]['end_xy'] = world([0., 0.])
|
||||
if condition == 'recovering':
|
||||
mission.recovery_goal = [*world([offset, 4.]), 0.]
|
||||
assert not mission.can_query_arrival(pose) or condition == 'return'
|
||||
result = mission.confirm_corridor_transition(pose, 10., body)
|
||||
assert (result is not None) is (condition == 'passed')
|
||||
assert mission.segment_index == (1 if condition == 'passed' else 0)
|
||||
assert mission.index == 0
|
||||
if result:
|
||||
assert mission.confirm_corridor_transition(pose, 10., body) is None
|
||||
# The new intent runs along the next edge from the actual position;
|
||||
# it neither turns back to the old hint nor completes the task goal.
|
||||
np.testing.assert_allclose(np.array(mission.route_target)-pose[:2], rotation @ [6., 0.])
|
||||
|
||||
|
||||
@pytest.mark.parametrize('direction', ['forward', 'reverse', 'at-node'])
|
||||
def test_local_blockage_keeps_original_graph_edge_and_nearby_return_node(direction):
|
||||
from k1link.simulation.ai_polygon.route_feedback import blocked_route_piece
|
||||
|
||||
Reference in New Issue
Block a user