Prevent accumulated range sampling drift in observed passages
This commit is contained in:
@@ -654,3 +654,33 @@ def test_through_passage_requires_measured_permission_and_current_clearance(sele
|
||||
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()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('angle,side,shift', [(0,1,(0,0)), (73,-1,(42,-17)), (-138,1,(-250,52))])
|
||||
def test_range_sampling_error_does_not_accumulate_into_lateral_drift(selector, angle, side, shift):
|
||||
_, pose, _, _, rotation = road(angle, shift)
|
||||
# Diagonally phased scan rows: successive nearest samples are offset by
|
||||
# 11 mm. Recursively extending each snapped point drifts >1 m in 19 m.
|
||||
xy = np.array([[x, side*(y+.055*x)] for x in np.arange(-1.,25.01,.2)
|
||||
for y in np.arange(-4.,4.01,.13)])
|
||||
points = np.c_[xy@rotation.T+shift, np.zeros(len(xy))]
|
||||
geometry = {**GEOMETRY, 'length_m':1.36, 'max_step_m':.1}
|
||||
selector.observe(np.c_[points, np.ones(len(points))], 1., pose)
|
||||
goal = [*(np.asarray(shift)+rotation@[3.,0.]),0.]
|
||||
lateral = []
|
||||
for along in np.arange(1.,20.01,.2):
|
||||
position = np.asarray(shift)+rotation@[along,0.]
|
||||
moved = [*position, *pose[2:]]
|
||||
goal = selector.choose(points, moved, position+rotation@[6.,0.], goal,
|
||||
(), geometry, 2., travel_direction=rotation@[1.,0.])
|
||||
assert goal is not None
|
||||
assert selector.evidence['source'] in {'continuing-observed-passage', 'retained-observed-passage'}
|
||||
assert np.min(np.linalg.norm(points-goal,axis=1)) < 1e-9
|
||||
lateral.append(((np.asarray(goal[:2])-shift)@rotation)[1])
|
||||
assert max(np.abs(lateral)) < .13
|
||||
# A new measured obstacle revokes the axis before a physical encounter.
|
||||
obstacle = position+rotation@[1.5,0.]
|
||||
selector.observe_navigation(clearance_receipt(moved,[obstacle]),moved,1,'run',2.)
|
||||
replacement = selector.choose(points, moved, position+rotation@[6.,0.],goal,
|
||||
(), geometry,2.1,travel_direction=rotation@[1.,0.])
|
||||
assert replacement is None or abs(((np.asarray(replacement[:2])-shift)@rotation)[1])>.3
|
||||
|
||||
Reference in New Issue
Block a user