Preserve installed operator workspace before consolidation
Local preservation snapshot, not a new deployment or simulation acceptance.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""Reconcile coarse elevation costs using measured local ground patches.
|
||||
|
||||
CMU's low-quantile reference spans a wider neighborhood than a contact patch.
|
||||
A nearby depression can give a level sidewalk a high cost. Only low returns
|
||||
near the measured body contact plane are candidates; their complete measured
|
||||
neighborhood must independently pass the existing support estimator. This runs
|
||||
before semantic/object overlays and never fills an unobserved ground region.
|
||||
"""
|
||||
import math
|
||||
|
||||
import numpy as np
|
||||
|
||||
if __package__:
|
||||
from .support_surface import SupportSurface
|
||||
else:
|
||||
from support_surface import SupportSurface
|
||||
|
||||
|
||||
def observed_ground_costs(terrain, pose, contact_height_m, *, monitor):
|
||||
terrain = np.asarray(terrain)
|
||||
pose = np.asarray(pose, dtype=float)
|
||||
if (terrain.ndim != 2 or terrain.shape[1] != 4 or pose.shape != (7,)
|
||||
or not np.isfinite(terrain).all() or not np.isfinite(pose).all()):
|
||||
raise ValueError("Invalid observed ground cost input")
|
||||
x, y, z, w = pose[3:]
|
||||
up = np.array([2*(x*z+w*y), 2*(y*z-w*x), 1-2*(x*x+y*y)])
|
||||
height = (terrain[:, :3]-pose[:3]) @ up + contact_height_m
|
||||
band = min(.08, .8*monitor.max_step)
|
||||
candidates = (terrain[:, 3] > monitor.max_step+1e-4) & (np.abs(height) <= band)
|
||||
if not candidates.any() or up[2] < 1/math.sqrt(1+monitor.max_slope**2):
|
||||
return terrain, 0
|
||||
# Separate raised objects from the ground fit, as the live range guard
|
||||
# does. Otherwise a wall/bench column tilts the fit of the pavement beside
|
||||
# it, and that pavement becomes a phantom solid obstacle in path search.
|
||||
# Raised returns retain their ORIGINAL costs; negative returns remain in
|
||||
# the fit, so this cannot erase a drop or manufacture its floor.
|
||||
ground_cost = np.where(height > monitor.max_step+1e-4, monitor.max_step+1, 0)
|
||||
surface = SupportSurface(np.column_stack((terrain[:, :3], ground_cost)),
|
||||
pose, contact_height_m, monitor.max_step, monitor.max_slope,
|
||||
anchor_radius_m=math.hypot(monitor.half_length, monitor.half_width))
|
||||
indices = np.flatnonzero(candidates)
|
||||
states, _ = surface.classify(terrain[indices, :2]-pose[:2])
|
||||
accepted = indices[states == "observed-supported"]
|
||||
result = terrain.copy()
|
||||
result[accepted, 3] = np.abs(height[accepted])
|
||||
return result, len(accepted)
|
||||
Reference in New Issue
Block a user