Retain observed passage intent through range crop changes

This commit is contained in:
DCCONSTRUCTIONS
2026-10-10 01:42:04 +03:00
parent d0f6c80ee2
commit 7ee42c44f0
3 changed files with 57 additions and 28 deletions
@@ -349,7 +349,7 @@ class ObservedGoals:
offsets = np.linspace(-geometry["width_m"] / 2, geometry["width_m"] / 2,
math.ceil(geometry["width_m"] / 0.1) + 1)
def supported(point):
def supported(point, support=permitted, *, source="current-range-and-observed-semantic-memory"):
bearing = point[:2]-pose[:2]
bearing /= max(np.linalg.norm(bearing), 1e-9)
lateral = np.array([-bearing[1], bearing[0]])
@@ -357,29 +357,44 @@ class ObservedGoals:
# Bind each lateral query to measured, permitted ground at its own
# height. Do not copy the centre elevation across a cross-slope or
# project a sidewalk label through an overhang onto another floor.
distances = np.linalg.norm(across[:,None,:]-permitted[None,:,:2],axis=2)
distances = np.linalg.norm(across[:,None,:]-support[None,:,:2],axis=2)
nearest = np.argmin(distances,axis=1)
if np.any(distances[np.arange(len(across)),nearest] > .15):
return False
keys = [tuple(cell) for cell in self.surface.cell_keys(permitted[nearest])]
keys = [tuple(cell) for cell in self.surface.cell_keys(support[nearest])]
self.evidence = {
"source": "current-range-and-observed-semantic-memory",
"source": source,
"goal": point.tolist(),
"oldest_surface_age_seconds": max(now - allowed[key] for key in keys),
"authority": "intent-only; native swept-obstacle-and-support-admission-required",
}
return True
# A lens switch cannot replace a currently measured, permitted goal.
# A new prohibition, missing current range or changed corridor can.
# A selected passage is a spatial intention, not a fresh sensor return.
# Retain its actually observed surface through a changing range crop.
# Current geometry still owns every native obstacle/support admission;
# this memory never enters that physical terrain or renews a timestamp.
remembered = np.array([point for key, point in self.measured.items()
if key in allowed], dtype=float).reshape(-1, 3)
if len(remembered):
local = np.linalg.norm(remembered[:, :2]-pose[:2], axis=1)
remembered = remembered[(local <= 6.) & (np.abs(remembered[:, 2] -
(pose[2]-geometry['body_contact_height_m'])) <= geometry.get('max_step_m', .1)
+ local*math.tan(math.radians(geometry['max_slope_degrees'])))]
if candidate_mask is not None:
remembered = remembered[candidate_mask(remembered)]
passage_points = np.concatenate((permitted, remembered))
retain = None
if prior is not None:
before = np.asarray(prior, dtype=float)
matched = np.linalg.norm(candidates - before, axis=1) <= 0.15
if (math.dist(before[:2], pose[:2]) > 0.8 and matched.any()
cell = tuple(self.surface.cell_keys(before[None])[0])
matched = np.linalg.norm(passage_points - before, axis=1) <= 0.15
if (0.8 < math.dist(before[:2], pose[:2]) <= 3.5
and math.dist(before[:2], target) < remaining - 0.1
and cell in allowed and matched.any()
and all(math.dist(before[:2], failed[:2]) > 0.6 for failed in excluded)
and (candidate_mask is None or candidate_mask(before[None])[0])
and supported(before)):
and supported(before, passage_points, source="retained-observed-passage")):
retain = before
horizon = min(remaining, 3.5)
retained_clearance = (self.approach_clearance(
@@ -395,20 +410,8 @@ class ObservedGoals:
observed = self.clearance_observation
obstacles = (observed[1] if observed is not None and 0 <= now-observed[0] <= .8
else np.empty((0, 2)))
# A sensor crop edge is not a passage boundary. Preserve the spatial
# extent of still-positive measured surface cells when choosing intent.
# Current range above still owns candidate selection/lateral support;
# this memory cannot certify a drive goal or admit any motion.
remembered = np.array([point for key, point in self.measured.items()
if key in allowed], dtype=float).reshape(-1, 3)
if len(remembered):
distance = np.linalg.norm(remembered[:, :2]-pose[:2], axis=1)
remembered = remembered[(distance <= 6.) & (np.abs(remembered[:, 2] -
(pose[2]-geometry['body_contact_height_m'])) <= geometry.get('max_step_m', .1)
+ distance*math.tan(math.radians(geometry['max_slope_degrees'])))]
if candidate_mask is not None:
remembered = remembered[candidate_mask(remembered)]
passage_points = np.concatenate((permitted, remembered))
# Retained measured extent supplies the passage boundaries. New goals
# still require current range support, independently of prior retention.
for passages in passage_centres(passage_points, pose, target, geometry, obstacles):
for passage in passages:
distance = np.linalg.norm(candidates[:, :2]-passage['xy'], axis=1)
+3 -3
View File
@@ -589,9 +589,9 @@ class ComposedInference:
calibration = inputs["source.camera.calibration"]
if observed_goals is not None:
# Every lens contributes to the same causal surface memory.
# The current range packet must still measure the proposed goal.
# This is a newly assessed spatial intent, not a timestamp renewal
# of the previous image-space goal during a survey.
# New destinations need current range; an observed passage can
# retain its intent across a changing crop without renewing its
# evidence. Native live body/support admission remains separate.
return observed_goals.choose(
inputs["source.lidar"], inputs["source.pose"], target,
None if prior_was_approach else prior, excluded, self.geometry,
+28 -2
View File
@@ -104,7 +104,7 @@ def test_new_prohibition_revokes_goal_and_cannot_be_refreshed_by_read(selector):
assert selector.choose(points, pose, target, goal, (), GEOMETRY, 40) is None
def test_current_range_corridor_and_exclusions_revoke_retained_goal(selector):
def test_corridor_and_exclusions_revoke_retained_goal_but_range_crop_does_not(selector):
points, pose, target, _, _ = road()
selector.observe(np.column_stack((points, np.ones(len(points)))), 0, pose)
goal = selector.choose(points, pose, target, None, (), GEOMETRY, .1)
@@ -113,7 +113,7 @@ def test_current_range_corridor_and_exclusions_revoke_retained_goal(selector):
assert result is not None and allowed(np.array([result]))[0]
assert selector.choose(points, pose, target, goal, [goal], GEOMETRY, .2) != goal
absent = points[np.linalg.norm(points - goal, axis=1) > .5]
assert selector.choose(absent, pose, target, goal, (), GEOMETRY, .2) != goal
assert selector.choose(absent, pose, target, goal, (), GEOMETRY, .2) == goal
def test_chassis_width_is_enforced_across_accumulated_views(selector):
@@ -525,3 +525,29 @@ def test_wide_passage_does_not_erase_obstacle_clearance_for_route_direction(sele
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
@pytest.mark.parametrize("angle,shift", [(0,(0,0)), (73,(42,-17)), (-138,(-250,52))])
def test_selected_passage_survives_range_crop_without_creating_new_sensor_support(selector,angle,shift):
points,pose,target,_,rotation=road(angle,shift)
selector.observe(np.c_[points,np.ones(len(points))],1.,pose)
goal=selector.choose(points,pose,target,None,(),GEOMETRY,1.)
stamps=dict(selector.surface.cells)
# The same world goal leaves the live metric crop during a body turn.
local=(points[:,:2]-shift)@rotation
crop=points[local[:,1]>.7]
saved=crop.copy()
turn=math.radians(angle+20)
turned=[*pose[:3],0,0,math.sin(turn/2),math.cos(turn/2)]
retained=selector.choose(crop,turned,target,goal,(),GEOMETRY,2.)
assert retained==goal
assert selector.evidence['source']=='retained-observed-passage'
assert selector.evidence['oldest_surface_age_seconds']==1.
assert dict(selector.surface.cells)==stamps
np.testing.assert_array_equal(crop,saved)
# A first destination cannot be manufactured from a narrow current crop.
assert selector.choose(crop,turned,target,None,(),GEOMETRY,2.) is None
# Current obstacle geometry can still revoke that retained intent.
obstacle=(np.asarray(shift)+rotation@[1.6,0.]).tolist()
selector.observe_navigation(clearance_receipt(turned,[obstacle]),turned,1,'run',2.)
assert selector.choose(crop,turned,target,goal,(),GEOMETRY,2.1)!=goal