Preserve native command ownership for a moving direction hint
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user