Bound urban route clearance preference and expose Nav2 costmap diagnostics
This commit is contained in:
@@ -92,7 +92,15 @@ def ground_envelope(vertices, faces, seed):
|
||||
return origin,height,envelope,unknown
|
||||
|
||||
|
||||
def route_graph(origin, height, envelope, unknown, positions, source, world_sha256):
|
||||
def route_graph(origin, height, envelope, unknown, positions, source, world_sha256,
|
||||
*, body_extent_m=1.):
|
||||
if not math.isfinite(body_extent_m) or body_extent_m <= 0:
|
||||
raise ValueError("Invalid route body extent")
|
||||
# Once half the body plus one preparation cell fits, additional open area
|
||||
# earns no discount. Otherwise every narrow sidewalk is attracted toward
|
||||
# the centre of a wider carriageway, despite having enough usable space.
|
||||
# This is a geometric preference, never pedestrian or live permission.
|
||||
preferred_clearance = body_extent_m/2 + CELL
|
||||
clearance = ndimage.distance_transform_edt(envelope)*CELL
|
||||
ids = np.full(envelope.shape,-1,dtype=np.int32)
|
||||
cells = np.argwhere(envelope & (clearance >= .75))
|
||||
@@ -112,8 +120,8 @@ def route_graph(origin, height, envelope, unknown, positions, source, world_sha2
|
||||
return None
|
||||
if not envelope[ij[:,0],ij[:,1]].all():
|
||||
return None
|
||||
# Keep boundaries expensive. The route follows broad ground structure,
|
||||
# with a bounded preference that cannot outweigh a long useful detour.
|
||||
# Preserve measured envelope width; only insufficient comfort clearance
|
||||
# contributes a soft penalty below.
|
||||
width=float(np.min(clearance[ij[:,0],ij[:,1]]))
|
||||
z=height[ij[:,0],ij[:,1]]
|
||||
if np.any(np.abs(np.diff(z))>.5):
|
||||
@@ -132,7 +140,7 @@ def route_graph(origin, height, envelope, unknown, positions, source, world_sha2
|
||||
if length < .05:
|
||||
return
|
||||
edges.append(dict(id=str(len(edges)),start=str(i),end=str(j),half_width_m=min(20,width),
|
||||
bidirectional=True,cost_m=length*(1+2/max(.5,width))))
|
||||
bidirectional=True,cost_m=length*(1+2*max(0.,1-width/preferred_clearance)**2)))
|
||||
|
||||
for i,a in enumerate(cells):
|
||||
for dx,dy in ((STRIDE,0),(0,STRIDE),(STRIDE,STRIDE),(STRIDE,-STRIDE)):
|
||||
@@ -192,7 +200,9 @@ def prepare(request, collider, output, field_cache):
|
||||
with cache.open("rb") as stream:
|
||||
receipt.write_text(json.dumps({"sha256":hashlib.file_digest(stream,"sha256").hexdigest(),"identity":field_identity}))
|
||||
source={k:identity[k] for k in ('provider','provider_sha256','collider_sha256')}
|
||||
routing=route_graph(origin,height,envelope,unknown,positions,source,world['sha256'])
|
||||
geometry=robot_geometry(request['robot'])
|
||||
routing=route_graph(origin,height,envelope,unknown,positions,source,world['sha256'],
|
||||
body_extent_m=max(geometry['length_m'],geometry['width_m']))
|
||||
inputs=dict(routing=routing,mission={"route_xy":[p[:2] for p in positions[1:]]},
|
||||
robot={"geometry":robot_geometry(request['robot'])},sha256=request['key'])
|
||||
route=build_route(inputs)
|
||||
|
||||
Reference in New Issue
Block a user