From ba441fed90d04dfdbb906495f1d2fc2a090419a0 Mon Sep 17 00:00:00 2001 From: Cameron Brown Date: Sun, 3 Nov 2024 13:28:30 -0500 Subject: [PATCH] navigator_missions: Add autonomous mission for RobotX 2024 --- .../navigator_missions/__init__.py | 1 + .../navigator_missions/autonomous_2024.py | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 NaviGator/mission_control/navigator_missions/navigator_missions/autonomous_2024.py diff --git a/NaviGator/mission_control/navigator_missions/navigator_missions/__init__.py b/NaviGator/mission_control/navigator_missions/navigator_missions/__init__.py index 3d29fcf60..45b0133b3 100644 --- a/NaviGator/mission_control/navigator_missions/navigator_missions/__init__.py +++ b/NaviGator/mission_control/navigator_missions/navigator_missions/__init__.py @@ -1,6 +1,7 @@ import mil_missions_core from . import pose_editor +from .autonomous_2024 import Autonomous2024 from .back_and_forth import BackAndForth from .circle import Circle from .circle_tower import CircleTower diff --git a/NaviGator/mission_control/navigator_missions/navigator_missions/autonomous_2024.py b/NaviGator/mission_control/navigator_missions/navigator_missions/autonomous_2024.py new file mode 100644 index 000000000..d1ff9007d --- /dev/null +++ b/NaviGator/mission_control/navigator_missions/navigator_missions/autonomous_2024.py @@ -0,0 +1,44 @@ +from __future__ import annotations + +import asyncio + +import rospy + +from .docking import Docking +from .entrance_gate2 import EntranceGate2 +from .navigation import Navigation +from .navigator import NaviGatorMission +from .scan_the_code import ScanTheCodeMission +from .wildlife import Wildlife + + +class Autonomous2024(NaviGatorMission): + + # timeout (in secs) + TIMEOUT = 180 + + async def run_mission(self, mission_cls: type[NaviGatorMission], name: str): + rospy.loginfo(f"[autonomous] beginning {name}...") + try: + await asyncio.wait_for(mission_cls().run(""), self.TIMEOUT) + except asyncio.TimeoutError: + rospy.logwarn(f"[autonomous] ran out of time on {name}!") + + async def run(self, args: str): + # Step 1: Entrance and exit gates + await self.run_mission(EntranceGate2, "entrance gate") + + # Step 2: Scan the Code + await self.run_mission(ScanTheCodeMission, "scan the code") + + # Step 3: Wildlife Mission + await self.run_mission(Wildlife, "wildlife") + + # Step 4: Navigation Mission + await self.run_mission(Navigation, "navigation") + + # Step 5: Dock Mission + await self.run_mission(Docking, "docking") + + # Step 6: UAV Mission + pass