Keep advisory route joints directional and preserve observed clearance

This commit is contained in:
DCCONSTRUCTIONS
2026-10-10 00:29:41 +03:00
parent daabdb9450
commit 41fa11e6c8
4 changed files with 62 additions and 9 deletions
@@ -52,6 +52,10 @@ def passage_centres(points, pose, target, geometry, obstacles):
queries = direction[:,None,:]*radial[None,:,None]
distances = tree.query(queries.reshape(-1,2))[0].reshape(len(delta),-1)
centre_clearance = np.minimum(centre_clearance, distances.min(axis=1))
# Beyond the observation horizon, extra empty width has no local
# preference. Route direction can break ties only among equally
# clear interior samples, never overwrite an obstacle score.
centre_clearance = np.minimum(centre_clearance, 3.5)
peak = centre_clearance.max()
maxima = np.flatnonzero(centre_clearance >= peak-.025)
lobes = np.split(maxima, np.flatnonzero(np.diff(maxima)>1)+1)
@@ -59,10 +63,10 @@ def passage_centres(points, pose, target, geometry, obstacles):
# Averaging them would put the goal back through the obstacle.
lobe = min(lobes, key=lambda ids: abs(lateral_samples[ids].mean()-(low+high)/2))
middle = float(lateral_samples[lobe].mean())
# A broad open area has no nearby pair of boundaries to centre
# between. The route can choose a direction within its interior.
if high-low >= 2*3.5 and route[0] > .1:
middle=float(np.clip(along*route[1]/route[0],low+width,high-width))
if peak >= 3.5 and route[0] > .1:
preferred = along*route[1]/route[0]
middle = float(lateral_samples[maxima[np.argmin(
np.abs(lateral_samples[maxima]-preferred))]])
xy=position+axes @ np.array([along,middle])
if np.linalg.norm(xy-position) > 3.5:
continue