Preserve native command ownership for a moving direction hint

This commit is contained in:
DCCONSTRUCTIONS
2026-10-10 00:46:23 +03:00
parent 41fa11e6c8
commit 04b940e8e1
4 changed files with 70 additions and 7 deletions
+4 -4
View File
@@ -20,7 +20,7 @@ import yaml
from action_msgs.msg import GoalStatus
from configuration import observed_configuration
from differential_motion import alignment_angle
from navigation.arrival_approach import validate_orientation
from navigation.arrival_approach import validate_orientation, orientation_identity
from navigation.continuous_control import ContinuousControl
from navigation.footprint import Footprint
from navigation.route_observation import route_observation
@@ -103,8 +103,8 @@ class Navigation:
or not value.get('continuous', False)):
return None
target = value.get('arrival_target')
return (orientation['key'], tuple(orientation['xy']),
value['max_speed_mps'], tuple(target) if target is not None else None)
return (orientation_identity(orientation), value['max_speed_mps'],
tuple(target) if target is not None else None)
@staticmethod
def reply(reason, *, status='waiting-for-plan', **extra):
@@ -199,7 +199,7 @@ class Navigation:
if not value.get('visual_goal_available'):
goal[:2] = target
reverse = value['allow_reverse']
orientation_key = ('spin', orientation['key'], tuple(orientation['xy'])) if orientation else None
orientation_key = ('spin', *orientation_identity(orientation)) if orientation else None
if (orientation_key is not None and self.action_key == orientation_key
and self.node.terminal is not None and self.node.terminal.done()
and self.node.terminal.result().status == GoalStatus.STATUS_SUCCEEDED):
@@ -182,7 +182,7 @@ def validate_orientation(value):
return None
if (
not isinstance(value, dict)
or set(value) != {"key", "xy"}
or set(value) not in ({"key", "xy"}, {"key", "xy", "direction_xy"})
or not isinstance(value["key"], str)
or not re.fullmatch(r"[a-zA-Z0-9_-]{1,80}", value["key"])
or not isinstance(value["xy"], list)
@@ -193,9 +193,24 @@ def validate_orientation(value):
)
):
raise ValueError("Invalid orientation intent")
direction = value.get("direction_xy")
if "direction_xy" in value and (
not isinstance(direction, list) or len(direction) != 2
or any(isinstance(v, bool) or not isinstance(v, (float, int))
or not math.isfinite(v) for v in direction)
or not math.isclose(math.hypot(*direction), 1., abs_tol=1e-9)
):
raise ValueError("Invalid orientation direction")
return value
def orientation_identity(value):
"""A translated bearing endpoint is the same intent; a new bearing is not."""
direction = value.get("direction_xy")
return (value["key"], "direction", tuple(direction)) if direction is not None else (
value["key"], "point", tuple(value["xy"]))
class ArrivalApproach:
def __init__(self):
self.turning = self.completed = False