From ee8b2413c9ee46cd4717b031febe9bcb49f53bfb Mon Sep 17 00:00:00 2001 From: Dozgulbas Date: Thu, 15 Aug 2024 14:40:44 -0700 Subject: [PATCH] Added Move and Dock actions --- src/mir_rest_node.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/mir_rest_node.py b/src/mir_rest_node.py index 4748b5a..b6dfaf7 100644 --- a/src/mir_rest_node.py +++ b/src/mir_rest_node.py @@ -55,6 +55,46 @@ def state(state: State): return ModuleState(status=state.status, error="") +@rest_module.action( + name="move", + description="Send a Move command to the MIR Base", +) +def move( + state: State, + action: ActionRequest, + target_location: Annotated[List[dict], "Target location name"], + description: Annotated[str, "Description of the location"], + priority: Annotated[Optional[int], "Prority of the movement in the queue. Defult is 1"], +) -> StepResponse: + """Sends a move command to the MIR Base""" + state.move( + location_name=target_location, + description=description, + priority=priority, + ) + return StepResponse.step_succeeded(f"MIR Base moved to the location: {target_location} ") + + +@rest_module.action( + name="dock", + description="Sends a dock command to the MIR Base", +) +def dock( + state: State, + action: ActionRequest, + target_location: Annotated[List[dict], "Name of the docking location"], + description: Annotated[str, "Description of the docking location"], + priority: Annotated[Optional[int], "Prority of the docking in the queue. Defult is 1"], +) -> StepResponse: + """Sends a docking command to the MIR Base""" + state.dock( + location_name=target_location, + description=description, + priority=priority, + ) + return StepResponse.step_succeeded(f"MIR Base moved to the location: {target_location} ") + + @rest_module.action( name="queue_mission", description="Adds a new mission to the queue. A mission could have multiple movement actions",