Retain measured local intent support across range resampling
This commit is contained in:
@@ -29,6 +29,7 @@ class ObservedGoals:
|
|||||||
self.clearance_observation = None
|
self.clearance_observation = None
|
||||||
self.clearance_index = None
|
self.clearance_index = None
|
||||||
self.continuation_anchor = None
|
self.continuation_anchor = None
|
||||||
|
self.intent_samples = None
|
||||||
|
|
||||||
def observe(self, samples, captured_at, pose, *, frame_id=None, capture_id=None):
|
def observe(self, samples, captured_at, pose, *, frame_id=None, capture_id=None):
|
||||||
if frame_id is not None and frame_id in self.seen_semantics:
|
if frame_id is not None and frame_id in self.seen_semantics:
|
||||||
@@ -332,7 +333,18 @@ class ObservedGoals:
|
|||||||
# body-facing range crop. Both new and retained intentions may refer to
|
# body-facing range crop. Both new and retained intentions may refer to
|
||||||
# actual earlier returns; no timestamp or physical support is created.
|
# actual earlier returns; no timestamp or physical support is created.
|
||||||
# Native planning and live swept-body admission still use current range.
|
# Native planning and live swept-body admission still use current range.
|
||||||
points = np.concatenate((points, remembered))
|
# Re-sampling a 20 cm semantic voxel can replace its representative
|
||||||
|
# return by >15 cm without changing the observed surface. Preserve
|
||||||
|
# the actual returns that established this one local intent; otherwise
|
||||||
|
# that sampling change spuriously destroys the goal and moves the
|
||||||
|
# corridor centre sideways. This bounded evidence belongs only to the
|
||||||
|
# matching prior goal and cannot refresh or override semantic cells.
|
||||||
|
retained_samples = np.empty((0, 3))
|
||||||
|
if (prior is not None and self.intent_samples is not None
|
||||||
|
and np.array_equal(self.intent_samples[0], prior)):
|
||||||
|
keys = self.surface.cell_keys(self.intent_samples)
|
||||||
|
retained_samples = self.intent_samples[[tuple(key) in allowed for key in keys]]
|
||||||
|
points = np.concatenate((points, remembered, retained_samples))
|
||||||
delta = points[:, :2] - pose[:2]
|
delta = points[:, :2] - pose[:2]
|
||||||
distance = np.linalg.norm(delta, axis=1)
|
distance = np.linalg.norm(delta, axis=1)
|
||||||
progress = np.linalg.norm(points[:, :2] - target, axis=1)
|
progress = np.linalg.norm(points[:, :2] - target, axis=1)
|
||||||
@@ -373,6 +385,7 @@ class ObservedGoals:
|
|||||||
nearest = np.argmin(distances,axis=1)
|
nearest = np.argmin(distances,axis=1)
|
||||||
if np.any(distances[np.arange(len(across)),nearest] > .15):
|
if np.any(distances[np.arange(len(across)),nearest] > .15):
|
||||||
return False
|
return False
|
||||||
|
self.intent_samples = np.vstack((point, support[nearest])).copy()
|
||||||
keys = [tuple(cell) for cell in self.surface.cell_keys(support[nearest])]
|
keys = [tuple(cell) for cell in self.surface.cell_keys(support[nearest])]
|
||||||
self.evidence = {
|
self.evidence = {
|
||||||
"source": source,
|
"source": source,
|
||||||
|
|||||||
@@ -684,3 +684,32 @@ def test_range_sampling_error_does_not_accumulate_into_lateral_drift(selector, a
|
|||||||
replacement = selector.choose(points, moved, position+rotation@[6.,0.],goal,
|
replacement = selector.choose(points, moved, position+rotation@[6.,0.],goal,
|
||||||
(), geometry,2.1,travel_direction=rotation@[1.,0.])
|
(), geometry,2.1,travel_direction=rotation@[1.,0.])
|
||||||
assert replacement is None or abs(((np.asarray(replacement[:2])-shift)@rotation)[1])>.3
|
assert replacement is None or abs(((np.asarray(replacement[:2])-shift)@rotation)[1])>.3
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('yaw,shift', [(0,(0,0)),(73,(42,-17)),(-138,(-250,52))])
|
||||||
|
def test_resampling_semantic_cells_preserves_actual_intent_support(selector,yaw,shift):
|
||||||
|
points,pose,target,_,rotation = road(yaw,shift)
|
||||||
|
selector.observe(np.c_[points,np.ones(len(points))],1.,pose)
|
||||||
|
goal = selector.choose(points,pose,target,None,(),GEOMETRY,1.1)
|
||||||
|
assert goal is not None
|
||||||
|
# A subsequent view samples different positions inside the same semantic
|
||||||
|
# voxels. Keep one actual return per voxel, farthest from the old goal.
|
||||||
|
# The permission has not changed and no new obstacle has appeared.
|
||||||
|
cells = selector.surface.cell_keys(points)
|
||||||
|
selected = {}
|
||||||
|
for cell,point in zip(cells,points):
|
||||||
|
key = tuple(cell)
|
||||||
|
if key not in selected or math.dist(point,goal)>math.dist(selected[key],goal):
|
||||||
|
selected[key] = point
|
||||||
|
resampled = np.array(list(selected.values()))
|
||||||
|
selector.observe(np.c_[resampled,np.ones(len(resampled))],1.2,pose)
|
||||||
|
stamps = dict(selector.surface.cells)
|
||||||
|
retained = selector.choose(resampled,pose,target,goal,(),GEOMETRY,1.3)
|
||||||
|
assert retained == goal
|
||||||
|
assert selector.evidence['source'] == 'retained-observed-passage'
|
||||||
|
assert dict(selector.surface.cells) == stamps
|
||||||
|
assert len(selector.intent_samples) <= math.ceil(GEOMETRY['width_m']/.1)+2
|
||||||
|
# A real new exclusion revokes the retained measured samples as well.
|
||||||
|
for now in [1.4,1.5,1.6]:
|
||||||
|
selector.observe(np.c_[resampled,np.zeros(len(resampled))],now,pose)
|
||||||
|
assert selector.choose(resampled,pose,target,goal,(),GEOMETRY,1.7) is None
|
||||||
|
|||||||
Reference in New Issue
Block a user