Advance observed passage intent without repeated lateral retargeting
This commit is contained in:
@@ -605,3 +605,52 @@ def test_explicit_route_direction_is_separate_from_remote_goal(selector):
|
||||
for target in ([8.,-5.],[8.,0.],[8.,5.],[675.,-9.])]
|
||||
assert goals[0] is not None
|
||||
assert all(np.array_equal(goal,goals[0]) for goal in goals)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('angle,shift', [(0,(0,0)),(73,(42,-17)),(-138,(-250,52))])
|
||||
def test_observed_through_passage_advances_without_chasing_a_new_lateral_centre(selector,angle,shift):
|
||||
_,pose,_,_,rotation=road(angle,shift)
|
||||
xy=np.array([[x,y] for x in np.arange(-1.,9.01,.08)
|
||||
for y in np.arange(-2.5,4.01,.08)])
|
||||
points=np.c_[xy@rotation.T+shift,np.zeros(len(xy))]
|
||||
geometry={**GEOMETRY,'length_m':1.3636,'max_step_m':.1}
|
||||
selector.observe(np.c_[points,np.ones(len(points))],1.,pose)
|
||||
goal=[*(np.asarray(shift)+rotation@[3.,0.]),0.]
|
||||
original=dict(selector.surface.cells)
|
||||
# A widened/partially observed section changes its instantaneous midpoint.
|
||||
# The already selected, clear through-passage must keep its lateral line
|
||||
# while advancing the local horizon as the chassis makes forward progress.
|
||||
for forward in [1.,1.7,2.4,3.1]:
|
||||
position=np.asarray(shift)+rotation@[forward,.25]
|
||||
moved=[*position,.37,0,0,math.sin(math.radians(angle-10)/2),math.cos(math.radians(angle-10)/2)]
|
||||
goal=selector.choose(points,moved,position+rotation@[6.,0.],goal,(),geometry,2.,
|
||||
travel_direction=rotation@[1.,0.])
|
||||
assert goal is not None
|
||||
local=(np.asarray(goal[:2])-shift)@rotation
|
||||
assert local[0]-forward>2.7
|
||||
assert abs(local[1])<.15
|
||||
assert np.min(np.linalg.norm(points-goal,axis=1))<1e-9
|
||||
assert dict(selector.surface.cells)==original
|
||||
|
||||
|
||||
def test_through_passage_requires_measured_permission_and_current_clearance(selector):
|
||||
points,pose,target,_,_=road()
|
||||
# The first continuation is observed; its farther extrapolation is not.
|
||||
selector.observe(np.c_[points,np.ones(len(points))],1.,pose)
|
||||
prior=[1.5,0.,0.]
|
||||
chosen=selector.choose(points,pose,target,prior,(),GEOMETRY,1.1,travel_direction=[1.,0.])
|
||||
assert chosen is not None and chosen[0]>2.7 and abs(chosen[1])<.15
|
||||
assert np.min(np.linalg.norm(points-chosen,axis=1))<1e-9
|
||||
# A pole on the continued line defeats retention before physical contact.
|
||||
selector.observe_navigation(clearance_receipt(pose,[[2.3,0.]]),pose,1,'run',1.1)
|
||||
blocked=selector.choose(points,pose,target,prior,(),GEOMETRY,1.2,travel_direction=[1.,0.])
|
||||
assert blocked is None or abs(blocked[1])>.3
|
||||
# An explicit mission exclusion still owns the candidate region.
|
||||
limited=selector.choose(points,pose,target,prior,(),GEOMETRY,1.2,
|
||||
lambda p:p[:,0]<2.,travel_direction=[1.,0.])
|
||||
assert limited is None or limited[0]<2.
|
||||
# No remembered label can create unmeasured geometry beyond this cloud.
|
||||
selector.clearance_observation=None
|
||||
moved=[2.7,0.,.37,0.,0.,0.,1.]
|
||||
end=selector.choose(points,moved,[8.,0.],chosen,(),GEOMETRY,1.3,travel_direction=[1.,0.])
|
||||
assert end is None or end[0]<=points[:,0].max()
|
||||
|
||||
@@ -262,51 +262,3 @@ def test_view_spin_is_not_restarted_by_translated_direction_endpoint(moving_brid
|
||||
result = navigation.plan(value)
|
||||
assert len(calls) == int(changed)
|
||||
assert result['controller_generation'] == (8 if changed else 7)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('world_yaw', [0., .73, -2.1])
|
||||
def test_lateral_passage_goal_keeps_continuation_heading_while_body_approaches(moving_bridge, world_yaw):
|
||||
navigation, value, _, _ = moving_bridge
|
||||
axes = np.array([[math.cos(world_yaw), -math.sin(world_yaw)],
|
||||
[math.sin(world_yaw), math.cos(world_yaw)]])
|
||||
origin = np.array([42., -17.])
|
||||
goal = origin + axes @ [3., -1.2]
|
||||
direction = axes @ [1., 0.]
|
||||
value.update(goal=[*goal, 0.], route_transition_target=None,
|
||||
orientation_target=dict(key='route-0-1', xy=[*goal],
|
||||
direction_xy=direction.tolist()))
|
||||
native_plan = navigation.node.plan
|
||||
headings = []
|
||||
def capture(pose, selected, heading):
|
||||
headings.append(heading)
|
||||
np.testing.assert_allclose(selected[:2], goal)
|
||||
return native_plan(pose, selected, heading)
|
||||
navigation.node.plan = capture
|
||||
for along, lateral, body_yaw in [(0., 0., 0.), (1., -.1, -.2), (2., -.5, -.6)]:
|
||||
xy = origin + axes @ [along, lateral]
|
||||
a = world_yaw + body_yaw
|
||||
value['pose'] = [*xy, .37, 0., 0., math.sin(a/2), math.cos(a/2)]
|
||||
navigation.path_planned_at = float('-inf')
|
||||
assert navigation.plan(value)['status'] == 'path'
|
||||
# The observed endpoint still selects the lateral passage. Approaching it
|
||||
# must not turn its shrinking diagonal into a progressively sharper final
|
||||
# body heading: this is through travel along one continuation, not parking.
|
||||
np.testing.assert_allclose(headings, world_yaw, atol=1e-12)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mode', ['unrouted', 'recovery', 'arrival', 'discrete'])
|
||||
def test_continuation_heading_does_not_override_a_placement_or_recovery(moving_bridge, mode):
|
||||
navigation, value, _, _ = moving_bridge
|
||||
value['orientation_target']['direction_xy'] = [1., 0.]
|
||||
if mode == 'unrouted':value['orientation_target'].pop('direction_xy')
|
||||
elif mode == 'recovery':value['recovery_orientation'] = True
|
||||
elif mode == 'arrival':value.update(arrival_target=[20., 0.], visual_goal_available=True)
|
||||
else:value['continuous'] = False
|
||||
native_plan = navigation.node.plan
|
||||
headings = []
|
||||
def capture(pose, selected, heading):
|
||||
headings.append(heading)
|
||||
return native_plan(pose, selected, heading)
|
||||
navigation.node.plan = capture
|
||||
assert navigation.plan(value)['status'] == 'path'
|
||||
assert headings == [math.atan2(.2, 4.)]
|
||||
|
||||
Reference in New Issue
Block a user