Carry captured sensor range envelopes into navigation observations
This commit is contained in:
@@ -90,3 +90,32 @@ def test_one_visible_corner_cannot_clear_a_voxel_with_hidden_corners(range_image
|
||||
images = range_images([[0, 0, 0]], changed)
|
||||
np.testing.assert_array_equal(images.cleared(points, 0.06, 0.12),
|
||||
full_footprint_oracle(images, points))
|
||||
|
||||
|
||||
def test_organized_ranges_use_separate_limits_from_run_configuration(range_images):
|
||||
packet = dict(view_models=[0, 1], view_sizes=[[2, 2], [2, 2]],
|
||||
view_axes=[np.eye(3), np.eye(3)],
|
||||
view_parameters=[[-180, 180, -7, 10], [1, 1, 1, 1]],
|
||||
view_ranges=[20., 14., 0., 20., 6., 0., 8., 0.])
|
||||
origins = np.zeros((2, 3))
|
||||
with pytest.raises(ValueError, match='Invalid organized range samples'):
|
||||
range_images(origins, packet)
|
||||
actual = range_images(origins, packet, range_limits_m=[20., 8.])
|
||||
np.testing.assert_array_equal(actual.ranges, packet['view_ranges'])
|
||||
packet['view_ranges'][6] = 9. # A longer lidar must not extend the D455.
|
||||
with pytest.raises(ValueError, match='Invalid organized range samples'):
|
||||
range_images(origins, packet, range_limits_m=[20., 8.])
|
||||
packet['view_ranges'][6] = 8.
|
||||
packet['view_ranges'][0] = 20.1
|
||||
with pytest.raises(ValueError, match='Invalid organized range samples'):
|
||||
range_images(origins, packet, range_limits_m=[20., 8.])
|
||||
|
||||
|
||||
@pytest.mark.parametrize('limits', [[20.], [20., float('nan')], [20., 41.], [20., -1.]])
|
||||
def test_invalid_sensor_range_limit_configuration_is_rejected(range_images, limits):
|
||||
packet = dict(view_models=[0, 1], view_sizes=[[2, 2], [2, 2]],
|
||||
view_axes=[np.eye(3), np.eye(3)],
|
||||
view_parameters=[[-180, 180, -7, 10], [1, 1, 1, 1]],
|
||||
view_ranges=np.zeros(8))
|
||||
with pytest.raises(ValueError, match='Invalid sensor range limits'):
|
||||
range_images(np.zeros((2, 3)), packet, range_limits_m=limits)
|
||||
|
||||
@@ -105,3 +105,41 @@ def test_lidar_observation_horizon_comes_from_versioned_sensor_spec(maximum):
|
||||
assert ends[-1].tolist() == [0., maximum, 0.]
|
||||
# A missing return only contributes a clearing ray, never supporting ground.
|
||||
assert not any(np.array_equal(p, ends[-1]) for p in observed)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('maximum', [8., 20.])
|
||||
def test_published_long_range_packet_reaches_observed_memory(maximum):
|
||||
from navigation.observed_space import ObservedSpace
|
||||
class Query:
|
||||
def __init__(self): self.calls = 0
|
||||
def raycast_closest(self, origin, direction, distance, bothSides):
|
||||
self.calls += 1
|
||||
if self.calls == 1 and distance >= 14.:
|
||||
return dict(hit=True, position=[14., 0., 0.], collision='/World/Exit')
|
||||
if self.calls == 2:
|
||||
return dict(hit=True, position=[.5, 0, 0], rigidBody='/World/Rover/chassis')
|
||||
return dict(hit=False)
|
||||
directions = np.array([[1.,0,0], [0.,1.,0], [-1.,0,0], [0.,-1.,0]])
|
||||
ranges = []
|
||||
points, ends, _, _ = mounted_range_returns(Query(), np.zeros(3), directions,
|
||||
'k1', dict(range_m=[.3, maximum]), np.ones(4), organized_ranges=ranges)
|
||||
packet = dict(view_models=[0, 1], view_sizes=[[2, 2], [2, 2]],
|
||||
view_axes=[np.eye(3), np.eye(3)],
|
||||
view_parameters=[[-180, 180, -7, 10], [1, 1, 1, 1]],
|
||||
view_ranges=np.concatenate([ranges[0], np.zeros(4)]))
|
||||
pose = np.array([0., 0., .37, 0, 0, 0, 1.])
|
||||
memory = ObservedSpace(range_limits_m=[maximum, 8.])
|
||||
actual = memory.observe(points, pose, 1., np.zeros((2,3)), ends,
|
||||
np.zeros(len(ends), dtype=int), range_views=packet)
|
||||
np.testing.assert_array_equal(actual, points)
|
||||
# Legacy ray packets share the same per-origin contract. Clearing rays
|
||||
# remove stale surfaces, but cannot create supporting ground by themselves.
|
||||
ray_only = ObservedSpace(range_limits_m=[maximum, 8.])
|
||||
assert not len(ray_only.observe(np.empty((0,3)), pose, 1., np.zeros((2,3)),
|
||||
ends, np.zeros(len(ends), dtype=int)))
|
||||
if maximum > 8.:
|
||||
with pytest.raises(ValueError, match='declared sensor envelope'):
|
||||
ObservedSpace().free_keys(np.zeros((2,3)), ends,
|
||||
np.zeros(len(ends), dtype=int))
|
||||
with pytest.raises(ValueError, match='declared sensor envelope'):
|
||||
memory.free_keys(np.zeros((2,3)), np.array([[9.,0,0]]), np.array([1]))
|
||||
|
||||
Reference in New Issue
Block a user