Select urban passage intent from measured world geometry

This commit is contained in:
DCCONSTRUCTIONS
2026-10-10 02:12:18 +03:00
parent 7ee42c44f0
commit e3d116d5b0
4 changed files with 98 additions and 33 deletions
+56 -2
View File
@@ -545,9 +545,63 @@ def test_selected_passage_survives_range_crop_without_creating_new_sensor_suppor
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
# A new intention uses the same observed passage, even after the previous
# goal is reached. This is old measured evidence, not new sensor support.
replacement=selector.choose(crop,turned,target,None,(),GEOMETRY,2.,
travel_direction=rotation@[1.,0.])
assert replacement is not None
assert abs(((np.array(replacement[:2])-shift)@rotation)[1]) < .13
assert dict(selector.surface.cells)==stamps
np.testing.assert_array_equal(crop,saved)
# Without the earlier full-width observation, the same narrow crop cannot
# invent a traversable destination.
unseen=type(selector)()
unseen.observe(np.c_[crop,np.ones(len(crop))],1.,turned)
assert unseen.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
@pytest.mark.parametrize('angle,shift', [(0,(0,0)),(73,(42,-17)),(-138,(-250,52))])
def test_local_intent_geometry_does_not_rotate_with_chassis(selector,angle,shift):
_,pose,target,_,rotation=road(angle,shift)
xy=np.array([[x,y] for x in np.arange(-4.,6.01,.08)
for y in np.arange(-1.6,1.61,.08)])
points=np.c_[xy@rotation.T+shift,np.zeros(len(xy))]
geometry={**GEOMETRY,'length_m':1.3636,'max_step_m':.1}
selector.observe(np.c_[points,np.ones(len(points))],1.,pose)
reference=selector.choose(points,pose,target,None,(),geometry,2.,
travel_direction=rotation@[1.,0.])
assert reference is not None
for offset in [-45,-30,-15,15,30,45]:
heading=math.radians(angle+offset)
turned=[*pose[:3],0,0,math.sin(heading/2),math.cos(heading/2)]
chosen=selector.choose(points,turned,target,None,(),geometry,2.,
travel_direction=rotation@[1.,0.])
np.testing.assert_allclose(chosen,reference,atol=1e-8)
def test_memory_goal_selection_does_not_refresh_expired_or_revoked_evidence(selector):
points,pose,target,_,_=road()
selector.observe(np.c_[points,np.ones(len(points))],1.,pose)
crop=points[points[:,1]>.7]
assert selector.choose(crop,pose,target,None,(),GEOMETRY,2.) is not None
original=dict(selector.surface.cells)
# Move the memory's retention centre away, making these old samples expire.
selector.surface.position=np.array([100.,100.])
assert selector.choose(crop,pose,target,None,(),GEOMETRY,40.) is None
assert dict(selector.surface.cells)==original
selector.observe(np.c_[points,np.zeros(len(points))],41.,pose)
assert selector.choose(crop,pose,target,None,(),GEOMETRY,41.) is None
def test_explicit_route_direction_is_separate_from_remote_goal(selector):
points,pose,_,_,_=road()
selector.observe(np.c_[points,np.ones(len(points))],1.,pose)
goals=[selector.choose(points,pose,target,None,(),GEOMETRY,2.,
travel_direction=[1.,0.])
for target in ([8.,-5.],[8.,0.],[8.,5.],[675.,-9.])]
assert goals[0] is not None
assert all(np.array_equal(goal,goals[0]) for goal in goals)