Select urban passage intent from measured world geometry
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Local intent from current range and causal multi-view surface observations.
|
||||
"""Local intent from a causal, measured world-space surface.
|
||||
|
||||
Changing the camera sector must not move a still observed goal to that sector's
|
||||
image centre. This selects measured points, never a route or permission to move;
|
||||
@@ -304,7 +304,7 @@ class ObservedGoals:
|
||||
return dict(goal=candidates[i].tolist(), reverse=False, kind="orient")
|
||||
return inspect_heading()
|
||||
|
||||
def choose(self, points, pose, target, prior, excluded, geometry, now, candidate_mask=None):
|
||||
def choose(self, points, pose, target, prior, excluded, geometry, now, candidate_mask=None, *, travel_direction=None):
|
||||
self.evidence = None
|
||||
if target is None:
|
||||
return None
|
||||
@@ -317,6 +317,21 @@ class ObservedGoals:
|
||||
remaining = float(np.linalg.norm(direction))
|
||||
if remaining <= 0.4:
|
||||
return None # Exact arrival remains the native whole-body receipt.
|
||||
allowed = {
|
||||
key: stamp for key, (permission, stamp) in self.surface.cells.items()
|
||||
if permission == 1 and self.surface.retained(key, stamp, now)
|
||||
}
|
||||
# A current observation must still see some known permitted surface.
|
||||
# A wholly missing/other-height scene cannot be replaced by old memory.
|
||||
if not any(tuple(key) in allowed for key in self.surface.cell_keys(points)):
|
||||
return None
|
||||
remembered = np.array([point for key, point in self.measured.items()
|
||||
if key in allowed], dtype=float).reshape(-1, 3)
|
||||
# Goal selection consumes the observed world, not just the current
|
||||
# body-facing range crop. Both new and retained intentions may refer to
|
||||
# actual earlier returns; no timestamp or physical support is created.
|
||||
# Native planning and live swept-body admission still use current range.
|
||||
points = np.concatenate((points, remembered))
|
||||
delta = points[:, :2] - pose[:2]
|
||||
distance = np.linalg.norm(delta, axis=1)
|
||||
progress = np.linalg.norm(points[:, :2] - target, axis=1)
|
||||
@@ -331,10 +346,6 @@ class ObservedGoals:
|
||||
good &= np.linalg.norm(points[:, :2] - np.asarray(failed[:2]), axis=1) > 0.6
|
||||
if not np.any(good):
|
||||
return None
|
||||
allowed = {
|
||||
key: stamp for key, (permission, stamp) in self.surface.cells.items()
|
||||
if permission == 1 and self.surface.retained(key, stamp, now)
|
||||
}
|
||||
permitted = points[[tuple(key) in allowed for key in self.surface.cell_keys(points)]]
|
||||
local = np.linalg.norm(permitted[:, :2]-pose[:2], axis=1)
|
||||
permitted = permitted[(local <= 6.) & (np.abs(permitted[:, 2] -
|
||||
@@ -349,7 +360,7 @@ class ObservedGoals:
|
||||
offsets = np.linspace(-geometry["width_m"] / 2, geometry["width_m"] / 2,
|
||||
math.ceil(geometry["width_m"] / 0.1) + 1)
|
||||
|
||||
def supported(point, support=permitted, *, source="current-range-and-observed-semantic-memory"):
|
||||
def supported(point, support=permitted, *, source="measured-surface-memory"):
|
||||
bearing = point[:2]-pose[:2]
|
||||
bearing /= max(np.linalg.norm(bearing), 1e-9)
|
||||
lateral = np.array([-bearing[1], bearing[0]])
|
||||
@@ -370,20 +381,9 @@ class ObservedGoals:
|
||||
}
|
||||
return True
|
||||
|
||||
# A selected passage is a spatial intention, not a fresh sensor return.
|
||||
# Retain its actually observed surface through a changing range crop.
|
||||
# Current geometry still owns every native obstacle/support admission;
|
||||
# this memory never enters that physical terrain or renews a timestamp.
|
||||
remembered = np.array([point for key, point in self.measured.items()
|
||||
if key in allowed], dtype=float).reshape(-1, 3)
|
||||
if len(remembered):
|
||||
local = np.linalg.norm(remembered[:, :2]-pose[:2], axis=1)
|
||||
remembered = remembered[(local <= 6.) & (np.abs(remembered[:, 2] -
|
||||
(pose[2]-geometry['body_contact_height_m'])) <= geometry.get('max_step_m', .1)
|
||||
+ local*math.tan(math.radians(geometry['max_slope_degrees'])))]
|
||||
if candidate_mask is not None:
|
||||
remembered = remembered[candidate_mask(remembered)]
|
||||
passage_points = np.concatenate((permitted, remembered))
|
||||
# Positive measured extent has already been bounded by local distance,
|
||||
# height, permission lifetime and the mission's permitted region.
|
||||
passage_points = permitted
|
||||
retain = None
|
||||
if prior is not None:
|
||||
before = np.asarray(prior, dtype=float)
|
||||
@@ -410,9 +410,9 @@ class ObservedGoals:
|
||||
observed = self.clearance_observation
|
||||
obstacles = (observed[1] if observed is not None and 0 <= now-observed[0] <= .8
|
||||
else np.empty((0, 2)))
|
||||
# Retained measured extent supplies the passage boundaries. New goals
|
||||
# still require current range support, independently of prior retention.
|
||||
for passages in passage_centres(passage_points, pose, target, geometry, obstacles):
|
||||
# New and retained goals share one measured world-space representation.
|
||||
for passages in passage_centres(passage_points, pose, target, geometry, obstacles,
|
||||
travel_direction=travel_direction):
|
||||
for passage in passages:
|
||||
distance = np.linalg.norm(candidates[:, :2]-passage['xy'], axis=1)
|
||||
for index in np.argsort(distance, kind="stable"):
|
||||
@@ -425,7 +425,8 @@ class ObservedGoals:
|
||||
self.evidence.update(source="observed-passage-centre",
|
||||
passage_width_m=float(passage['width']),
|
||||
passage_centre_xy=passage['xy'].tolist(),
|
||||
route_role="rank-distinct-passages-only",
|
||||
route_role=("continuation-direction-and-branch-selection" if travel_direction is not None
|
||||
else "rank-distinct-passages-only"),
|
||||
approach_clearance_m=float(clearance) if math.isfinite(clearance) else None)
|
||||
return selected.tolist()
|
||||
return None
|
||||
|
||||
@@ -10,10 +10,19 @@ import numpy as np
|
||||
from scipy.spatial import cKDTree
|
||||
|
||||
|
||||
def passage_centres(points, pose, target, geometry, obstacles):
|
||||
def passage_centres(points, pose, target, geometry, obstacles, *, travel_direction=None):
|
||||
position = np.asarray(pose[:2])
|
||||
x, y, z, w = pose[3:7]
|
||||
yaw = math.atan2(2*(w*z+x*y), 1-2*(y*y+z*z))
|
||||
# An explicitly selected route continuation stations the observed corridor.
|
||||
# It is a direction, never the vector toward a remote endpoint. Legacy
|
||||
# unrouted tasks retain their body-forward observation convention.
|
||||
if travel_direction is None:
|
||||
x, y, z, w = pose[3:7]
|
||||
yaw = math.atan2(2*(w*z+x*y), 1-2*(y*y+z*z))
|
||||
else:
|
||||
direction = np.asarray(travel_direction, dtype=float)
|
||||
if direction.shape != (2,) or not np.isfinite(direction).all() or np.linalg.norm(direction) <= 1e-9:
|
||||
raise ValueError("Invalid passage travel direction")
|
||||
yaw = math.atan2(direction[1], direction[0])
|
||||
axes = np.array([[math.cos(yaw), -math.sin(yaw)],
|
||||
[math.sin(yaw), math.cos(yaw)]])
|
||||
local = (points[:, :2]-position) @ axes
|
||||
|
||||
@@ -589,14 +589,15 @@ class ComposedInference:
|
||||
calibration = inputs["source.camera.calibration"]
|
||||
if observed_goals is not None:
|
||||
# Every lens contributes to the same causal surface memory.
|
||||
# New destinations need current range; an observed passage can
|
||||
# retain its intent across a changing crop without renewing its
|
||||
# evidence. Native live body/support admission remains separate.
|
||||
# Intent uses actually measured world-space surface across
|
||||
# changing body views. Native live body/support admission stays
|
||||
# separate and never receives synthetic range from this memory.
|
||||
return observed_goals.choose(
|
||||
inputs["source.lidar"], inputs["source.pose"], target,
|
||||
None if prior_was_approach else prior, excluded, self.geometry,
|
||||
time.monotonic(), self.mission.goals_permitted
|
||||
if isinstance(self.mission, RoutedMission) else None,
|
||||
travel_direction=(self.mission.orientation_target() or {}).get("direction_xy"),
|
||||
)
|
||||
if calibration.get("view_role") == "survey":
|
||||
observed = self.task_view_intent.recall(target, time.monotonic())
|
||||
|
||||
Reference in New Issue
Block a user