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
+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