Keep advisory route joints directional and preserve observed clearance
This commit is contained in:
@@ -510,3 +510,18 @@ def test_symmetric_obstacle_does_not_average_two_passages_through_its_centre(sel
|
||||
goal=selector.choose(points,pose,target,None,(),GEOMETRY,1.1)
|
||||
assert goal is not None and abs(goal[1])>.35
|
||||
assert selector.approach_clearance(np.array([goal]),pose,GEOMETRY,1.1)[0]>.2
|
||||
|
||||
|
||||
@pytest.mark.parametrize("angle,shift", [(0,(0,0)), (73,(42,-17)), (-138,(-250,52))])
|
||||
def test_wide_passage_does_not_erase_obstacle_clearance_for_route_direction(selector,angle,shift):
|
||||
_,pose,_,_,rotation=road(angle,shift)
|
||||
xy=np.array([[x,y] for x in np.arange(.4,6.,.07)
|
||||
for y in np.arange(-4.,4.01,.07)])
|
||||
points=np.c_[xy@rotation.T+shift,np.zeros(len(xy))]
|
||||
selector.observe(np.c_[points,np.ones(len(points))],1.,pose)
|
||||
hazard=(np.array([[2.,-1.3]])@rotation.T+shift).tolist()
|
||||
selector.observe_navigation(clearance_receipt(pose,hazard),pose,1,'run',1.)
|
||||
goal=selector.choose(points,pose,np.array(shift)+rotation@[8,-5],None,(),GEOMETRY,1.1)
|
||||
assert goal is not None
|
||||
assert selector.approach_clearance(np.array([goal]),pose,GEOMETRY,1.1)[0] > 1.5
|
||||
assert ((np.array(goal[:2])-shift)@rotation)[1] > 0
|
||||
|
||||
@@ -321,3 +321,32 @@ def test_advisory_joint_is_never_an_exact_arrival_destination():
|
||||
mission.segment_index=len(mission.leg['segments'])-1
|
||||
mission.route_observation(pose,0.)
|
||||
assert mission.can_query_arrival(pose)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("offset", [-3.,0.,3.])
|
||||
def test_advisory_joint_is_a_direction_not_lateral_attraction(offset):
|
||||
from k1link.simulation.ai_polygon.route_mission import RoutedMission
|
||||
*_,inputs,_=fixture()
|
||||
inputs['routing']['blocked_edges']=['0','1','2']
|
||||
inputs.update(sensors={'schema_version':'missioncore.simulation-sensor-rig/v4'},
|
||||
behavior={'max_speed_mps':1.})
|
||||
mission=RoutedMission(inputs)
|
||||
mission.route_observation([0.,0.,0.,0.,0.,0.,1.],0.)
|
||||
# The actual open passage can pass a map joint on either side. Neither
|
||||
# the goal selector nor the stopped view acquisition should face the joint.
|
||||
for t,y in enumerate([2.,4.,5.,6.],start=10):
|
||||
pose=[offset,y,0.,0.,0.,0.,1.]
|
||||
mission.route_observation(pose,float(t*4))
|
||||
direction=np.array(mission.route_target)-pose[:2]
|
||||
assert direction[0] == pytest.approx(0.) and direction[1] > 3.5
|
||||
assert mission.orientation_target()['xy'] == mission.route_target
|
||||
assert mission.arrival_target() == [0.,5.]
|
||||
assert mission.segment_index == 0 # direction is not a transition receipt
|
||||
assert not mission.can_query_arrival(pose)
|
||||
# A required return anchor and final mission destination retain exact XY.
|
||||
mission.leg['segments'][0]['return_to_anchor']=True
|
||||
mission.route_observation(pose,60.)
|
||||
assert mission.route_target == [0.,5.]
|
||||
mission.segment_index=len(mission.leg['segments'])-1
|
||||
mission.route_observation(pose,61.)
|
||||
assert mission.route_target == mission.leg['goal_xy']
|
||||
|
||||
Reference in New Issue
Block a user