Keep clearance refresh bounded and preserve rear recovery observation

This commit is contained in:
DCCONSTRUCTIONS
2026-10-09 13:29:20 +03:00
parent ade3c19d2a
commit 35c1b88cd7
4 changed files with 75 additions and 6 deletions
+38
View File
@@ -316,3 +316,41 @@ def test_clearance_receipt_is_bound_and_does_not_invent_semantics(selector,misma
elif mismatch=='pose':position=[1.,*position[1:]]
selector.observe_navigation(receipt,position,seconds,run,1.)
assert selector.clearance_observation is None and not selector.surface.cells
def test_clear_retained_intent_does_not_recompute_alternative_approaches(selector, monkeypatch):
points, position, target, _, _ = road()
selector.observe(np.c_[points, np.ones(len(points))], 1., position)
goal = selector.choose(points, position, target, None, (), GEOMETRY, 1.)
selector.observe_navigation(clearance_receipt(position, [[1.6, 1.5]]), position, 1, 'run', 1.)
evaluate = selector.approach_clearance
sizes = []
def measured(candidates, *args):
sizes.append(len(candidates))
return evaluate(candidates, *args)
monkeypatch.setattr(selector, 'approach_clearance', measured)
assert selector.choose(points, position, target, goal, (), GEOMETRY, 1.1) == goal
assert sizes == [1]
# New nearby geometry must still cause the alternatives to be evaluated.
selector.observe_navigation(clearance_receipt(position, [[1.6, 0.]]), position, 1, 'run', 1.1)
assert selector.choose(points, position, target, goal, (), GEOMETRY, 1.2) != goal
assert max(sizes) > 1
def test_clearance_matches_exact_continuous_segments(selector):
rng = np.random.default_rng(122)
position = [17., -31., .37, 0., 0., 0., 1.]
candidates = np.c_[rng.uniform(-3., 3., (259, 2))+position[:2], np.zeros(259)]
obstacles = rng.uniform(-4., 4., (137, 2))+position[:2]
selector.observe_navigation(clearance_receipt(position, obstacles.tolist()), position, 1, 'run', 1.)
actual = selector.approach_clearance(candidates, position, GEOMETRY, 1.1)
expected = []
for goal in candidates:
delta = goal[:2]-position[:2]
length = np.linalg.norm(delta)
direction = delta/length
a = np.asarray(position[:2])+min(length, GEOMETRY['width_m']/2)*direction
b = goal[:2]
projection = np.clip((obstacles-a) @ (b-a) / max(np.sum((b-a)**2), 1e-20), 0, 1)
expected.append(np.min(np.linalg.norm(obstacles-(a+projection[:, None]*(b-a)), axis=1)))
np.testing.assert_allclose(actual, expected, atol=1e-7, rtol=1e-7)
+15
View File
@@ -365,3 +365,18 @@ def test_native_owner_does_not_bypass_unknown_view_or_progress_budget():
assert r.excluded == [selected['goal']]
r.tick(pose(-.45), now+12.1, choose)
assert r.native_action is None
def test_backup_keeps_rear_observation_when_lateral_error_dominates_near_goal():
r = ObservedRecovery()
r.phase = 'executing'
r.sequence, r.option = 1, 1
r.selected = dict(goal=[-.7, 0., 0.], reverse=True)
request = r.view_request(pose(), 1.)
assert request['yaw_degrees'] == 180
near = pose()
near[0], near[1] = -.68, -.05
assert r.view_request(near, 2.) == request
# Observation freshness still expires; stable direction grants no motion.
r.observe_view(request, pose(), 1.)
assert not r.view_current(near, 4.)