Separate forbidden ground from body collision and retain capture phase
This commit is contained in:
@@ -30,6 +30,7 @@ class ContinuousControl:
|
||||
clock=time.monotonic, body_top_m=math.inf, native_only=False):
|
||||
self.monitor, self.support = monitor, support_policy
|
||||
self.detections = DetectionObstacles(monitor)
|
||||
self.ground_monitor = monitor.ground_envelope()
|
||||
self.publish_pose, self.publish_path, self.native_command = (
|
||||
publish_pose, publish_path, native_command)
|
||||
self.clock, self.lock = clock, threading.Lock()
|
||||
@@ -61,7 +62,7 @@ class ContinuousControl:
|
||||
self.geometry = (self.clock() - age, points)
|
||||
self.range_sequence = sequence
|
||||
|
||||
def accept(self, value, result, terrain, *, detections=None):
|
||||
def accept(self, value, result, terrain, *, detections=None, collision_terrain=None):
|
||||
candidates = self.detections.observed(value)
|
||||
if detections is None:
|
||||
detections = candidates
|
||||
@@ -69,8 +70,18 @@ class ContinuousControl:
|
||||
detections = np.asarray(detections, dtype=float).reshape(-1, 3).copy()
|
||||
if not set(map(tuple, detections)) <= set(map(tuple, candidates)):
|
||||
raise ValueError("Refined detection is not an original associated range return")
|
||||
terrain = np.asarray(terrain, dtype=float).reshape(-1, 4).copy()
|
||||
collision = (terrain.copy() if collision_terrain is None else
|
||||
np.asarray(collision_terrain, dtype=float).reshape(-1, 4).copy())
|
||||
if (collision.shape != terrain.shape or not np.isfinite([terrain, collision]).all()
|
||||
or not np.array_equal(collision[:, :3], terrain[:, :3])
|
||||
or np.any(collision[:, 3] > terrain[:, 3])):
|
||||
raise ValueError("Collision and surface layers must share the measured terrain")
|
||||
# Only costs added by the semantic overlay belong to ground exclusion.
|
||||
# Physical terrain and detected solids retain the complete body envelope.
|
||||
floor = terrain[terrain[:, 3] > collision[:, 3]].copy()
|
||||
record = dict(value=value, result=result, detections=detections,
|
||||
terrain=np.asarray(terrain, dtype=float).reshape(-1, 4).copy(),
|
||||
terrain=terrain, collision_terrain=collision, forbidden_ground=floor,
|
||||
received_at=self.clock())
|
||||
with self.lock:
|
||||
self.plans[value["observation_id"]] = record
|
||||
@@ -84,7 +95,9 @@ class ContinuousControl:
|
||||
return None
|
||||
identity, plan = next(reversed(self.plans.items()))
|
||||
return dict(observation_id=identity, request=copy.deepcopy(plan["value"]),
|
||||
result=copy.deepcopy(plan["result"]), terrain=plan["terrain"].tolist())
|
||||
result=copy.deepcopy(plan["result"]), terrain=plan["terrain"].tolist(),
|
||||
collision_terrain=plan["collision_terrain"].tolist(),
|
||||
forbidden_ground=plan["forbidden_ground"].tolist())
|
||||
|
||||
def tick(self, value):
|
||||
started = self.clock()
|
||||
@@ -147,6 +160,7 @@ class ContinuousControl:
|
||||
raised = (height > self.monitor.max_step + 1e-4) & (height <= self.body_top_m)
|
||||
hazards = np.column_stack((points[raised], np.ones(int(raised.sum()))))
|
||||
terrain = np.concatenate((plan["terrain"], hazards))
|
||||
collision = np.concatenate((plan["collision_terrain"], hazards))
|
||||
def admit(command):
|
||||
speed, angular = map(float, command)
|
||||
if not all(math.isfinite(x) for x in (speed, angular)):
|
||||
@@ -162,12 +176,16 @@ class ContinuousControl:
|
||||
min(self.support.partial_yaw_rps, angular)) if stationary else 0.0
|
||||
if (reverse and (speed > 0 or abs(angular) > 0.15)) or (not reverse and speed < 0):
|
||||
return output(reason="direction")
|
||||
speed, angular, obstacle_scale = self.monitor.regulate_command(speed, angular, terrain, pose)
|
||||
speed, angular, obstacle_scale = self.monitor.regulate_command(speed, angular, collision, pose)
|
||||
if obstacle_scale == 0:
|
||||
return output(reason="obstacle")
|
||||
speed, angular, ground_scale = self.ground_monitor.regulate_command(
|
||||
speed, angular, plan["forbidden_ground"], pose)
|
||||
if ground_scale == 0:
|
||||
return output(reason="forbidden-ground-sweep")
|
||||
speed, angular, support_scale, support = self.support.regulate(
|
||||
speed, angular, terrain, pose, request["body_contact_height_m"],
|
||||
current_points=points,
|
||||
current_points=points, collision_terrain=collision,
|
||||
observed_retreat=bool(reverse and request.get("continuous")),
|
||||
)
|
||||
evidence = dict(support_policy=support["policy"]["reason"],
|
||||
|
||||
Reference in New Issue
Block a user