Bound corridor ranking work and retire aborted local actions
This commit is contained in:
@@ -347,3 +347,43 @@ def test_native_backoff_does_not_clear_current_recovery_round_or_motion_failures
|
||||
mission.retry_native_goals(3.)
|
||||
assert mission.failed_goals == [other]
|
||||
assert mission.attempts == 0 and mission.anchor_time == 0
|
||||
|
||||
|
||||
def aborted_follow(goal, p, seconds):
|
||||
result = aborted_plan(goal, p, seconds)
|
||||
result['action_result'] = {**result.pop('planning_result'), 'kind': 'path'}
|
||||
return result
|
||||
|
||||
|
||||
def test_followpath_abort_does_not_wait_for_stall_or_force_recovery():
|
||||
mission = WaypointMission([[8, 0]])
|
||||
first, _ = mission.update(pose(), 0, goal)
|
||||
mission.reject_local_plan(aborted_follow(first, pose(), 0), pose(), 0, 'run')
|
||||
assert mission.goal is None and mission.failed_goals == [first]
|
||||
second, intent = mission.update(pose(), .1, goal)
|
||||
assert second != first and not mission.recovery.active
|
||||
assert mission.anchor_time == 0 and mission.attempts == 0
|
||||
# Native aborts and replacement goals still earn no task progress.
|
||||
for t in range(1, 34):
|
||||
current, _ = mission.update(pose(), t, goal)
|
||||
if current is not None:
|
||||
mission.reject_local_plan(aborted_follow(current, pose(), t), pose(), t, 'run')
|
||||
assert mission.fault == 'stuck'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mismatch', ['kind', 'goal', 'status', 'run', 'pose', 'time', 'moving'])
|
||||
def test_followpath_abort_must_belong_to_current_goal_and_observation(mismatch):
|
||||
mission = WaypointMission([[8, 0]])
|
||||
first, _ = mission.update(pose(), 1, goal)
|
||||
result = aborted_follow(first, pose(), 1)
|
||||
receipt = result['action_result']
|
||||
observation = result['route_observation']['observation']
|
||||
if mismatch == 'kind': receipt['kind'] = 'backup'
|
||||
elif mismatch == 'goal': receipt['goal_xy'] = [100., 100.]
|
||||
elif mismatch == 'status': receipt['status'] = 'canceled'
|
||||
elif mismatch == 'run': observation['execution_inputs_sha256'] = 'other'
|
||||
elif mismatch == 'pose': observation['pose'] = pose(.1)
|
||||
elif mismatch == 'time': observation['simulation_time_seconds'] = .9
|
||||
elif mismatch == 'moving': result['speed_mps'] = .1
|
||||
mission.reject_local_plan(result, pose(), 1, 'run')
|
||||
assert mission.goal == first and mission.failed_goals == []
|
||||
|
||||
@@ -410,3 +410,48 @@ def test_alternating_cached_views_do_not_multiply_semantic_votes(selector):
|
||||
assert dict(selector.surface.cells) == before
|
||||
selector.observe(negative, 4., position, frame_id='d:front', capture_id='d')
|
||||
assert selector.choose(points, position, target, None, (), GEOMETRY, 4.) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('seed', [19, 37, 44])
|
||||
def test_indexed_boundary_cost_preserves_exact_height_filtered_distance(selector, seed):
|
||||
rng = np.random.default_rng(seed)
|
||||
barriers = np.c_[rng.uniform(-3, 3, (415, 2)), rng.uniform(-2, 2, 415)]
|
||||
candidates = np.c_[rng.uniform(-2, 2, (261, 2)), rng.uniform(-.3, .3, 261)]
|
||||
geometry = {**GEOMETRY, 'height_m': .734, 'max_step_m': .1}
|
||||
selector.observe(np.c_[barriers, np.zeros(len(barriers))], 1., [0, 0, .37, 0, 0, 0, 1])
|
||||
# Use the same actual retained return in each semantic voxel; no invented
|
||||
# cell centres or relaxed height intervals enter either calculation.
|
||||
measured = np.array(list(selector.measured.values()))
|
||||
distance = np.linalg.norm(candidates[:, None, :2]-measured[None, :, :2], axis=2)
|
||||
dz = measured[None, :, 2]-candidates[:, None, 2]
|
||||
expected = 2*geometry['width_m']*np.exp(-np.min(np.where(
|
||||
(dz>=-.1)&(dz<=.734), distance, np.inf),axis=1)/geometry['width_m'])
|
||||
np.testing.assert_allclose(selector.boundary_cost(candidates, geometry, 1.), expected,
|
||||
rtol=1e-12, atol=1e-12)
|
||||
|
||||
|
||||
def test_boundary_index_skips_closer_returns_above_the_body(selector):
|
||||
candidates = np.array([[1., 0., 0.], [1., 0., 8.]])
|
||||
barriers = np.array([[1., 0., 3.], [1.1, 0., 3.], [1.2, 0., 3.], [2., 0., 0.]])
|
||||
selector.observe(np.c_[barriers, np.zeros(len(barriers))], 1., [0, 0, .37, 0, 0, 0, 1])
|
||||
cost = selector.boundary_cost(candidates, GEOMETRY, 1.)
|
||||
np.testing.assert_allclose(cost, [2*.905*np.exp(-1/.905), 0.])
|
||||
|
||||
|
||||
def test_shared_bearing_queries_conservatively_bound_common_horizon(selector):
|
||||
rng = np.random.default_rng(126)
|
||||
position = [17., -31., .37, 0., 0., 0., 1.]
|
||||
candidates = np.c_[rng.uniform(-3., 3., (1259, 2))+position[:2], np.zeros(1259)]
|
||||
obstacles = rng.uniform(-4., 4., (237, 2))+position[:2]
|
||||
selector.observe_navigation(clearance_receipt(position, obstacles.tolist()), position, 1, 'run', 1.)
|
||||
actual = selector.approach_clearance(candidates, position, GEOMETRY, 1.1, lookahead_m=3.5)
|
||||
expected = []
|
||||
for goal in candidates:
|
||||
delta = goal[:2]-position[:2]
|
||||
direction = delta/np.linalg.norm(delta)
|
||||
a = np.asarray(position[:2])+GEOMETRY['width_m']/2*direction
|
||||
b = np.asarray(position[:2])+3.5*direction
|
||||
projection = np.clip((obstacles-a) @ (b-a)/np.sum((b-a)**2), 0, 1)
|
||||
expected.append(np.min(np.linalg.norm(obstacles-(a+projection[:, None]*(b-a)), axis=1)))
|
||||
assert np.all(actual <= np.asarray(expected)+1e-10)
|
||||
assert np.max(np.asarray(expected)-actual) < .041
|
||||
|
||||
Reference in New Issue
Block a user