Bind Nav2 route transitions to current observed body support
Return a separate positive-surface body receipt before reaching a guide vertex. Keep mission arrival and command admission independent, reject stale transaction reuse, and include the bridge helper in module identity. Validate the actual Nav2 plan entry with observed, unknown and obstructed support.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"""Current observed body support for an intent transition, never a drive goal."""
|
||||
import math
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
def route_support(monitor, observed, value, inputs):
|
||||
target = value.get("route_transition_target")
|
||||
if target is None:
|
||||
return None
|
||||
pose = np.asarray(value["pose"], dtype=float)
|
||||
target = np.asarray(target, dtype=float)
|
||||
if (target.shape != (2,) or not np.isfinite(target).all()
|
||||
or math.dist(pose[:2], target) > 3.5
|
||||
or value["execution_inputs_sha256"] != inputs["sha256"]):
|
||||
raise ValueError("Invalid route transition observation")
|
||||
support = observed["permitted_terrain"]
|
||||
receipt = monitor.assess_pose(observed["terrain"], pose,
|
||||
value["body_contact_height_m"], support_terrain=support)
|
||||
return {**receipt, "positive_surface_required": True,
|
||||
"authority": "current-body; intent-transition-only",
|
||||
"observation": dict(pose=pose.tolist(), target_xy=target.tolist(),
|
||||
simulation_time_seconds=value["simulation_time_seconds"],
|
||||
execution_inputs_sha256=inputs["sha256"])}
|
||||
@@ -27,6 +27,7 @@ from navigation.route_observation import route_observation
|
||||
from navigation.support_policy import SupportPolicy
|
||||
from observed_collision import ObservedCollision
|
||||
from rig_collision import collision_geometry
|
||||
from route_support import route_support
|
||||
from ros_navigation import RosNavigation, yaw_of
|
||||
from std_srvs.srv import Trigger
|
||||
from terrain_process import TerrainProcess
|
||||
@@ -98,6 +99,12 @@ class Navigation:
|
||||
return None
|
||||
|
||||
def plan(self, value):
|
||||
# Transaction-local metadata cannot survive a stale/failed observation.
|
||||
receipts = {}
|
||||
result = self._plan(value, receipts)
|
||||
return {**result, **receipts}
|
||||
|
||||
def _plan(self, value, receipts):
|
||||
entered = time.monotonic()
|
||||
if self.failure:
|
||||
raise RuntimeError(self.failure)
|
||||
@@ -130,6 +137,9 @@ class Navigation:
|
||||
detected=observed['detected']):
|
||||
return self.reply('stale-range')
|
||||
route = route_observation(terrain, pose, value, self.monitor.max_step)
|
||||
support = route_support(self.monitor, observed, value, self.inputs)
|
||||
if support is not None:
|
||||
receipts["route_support"] = support
|
||||
orientation = validate_orientation(value.get('orientation_target'))
|
||||
target = value.get('arrival_target')
|
||||
if target is not None:
|
||||
|
||||
@@ -133,6 +133,8 @@ class TerrainObservation:
|
||||
points, forbidden = self.semantics.apply(points, time.monotonic())
|
||||
search, _ = self.support_obstacles.apply(points, pose=pose, monitor=self.monitor)
|
||||
return dict(terrain=points, search_terrain=search, physical_terrain=physical, detected=detected,
|
||||
permitted_terrain=(self.semantics.permitted_terrain(points, time.monotonic())
|
||||
if request.get("route_transition_target") is not None else None),
|
||||
current_points=current,
|
||||
metrics=dict(detection_candidates=len(candidates),
|
||||
detection_ground_returns=len(candidates)-len(detected),
|
||||
|
||||
Reference in New Issue
Block a user