Skip to content

Commit

Permalink
Modularise creating a new mission definition
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Feb 16, 2024
1 parent 679f060 commit 75b8848
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/isar_exr/robotinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def create_new_stage(self) -> str:
stage_id: str = self.api.create_stage(site_id=settings.ROBOT_EXR_SITE_ID)
return stage_id

def update_site_with_tasks(self, tasks) -> List[str]: # Returns a list of POI IDs
def update_site_with_tasks(self, tasks: List[Task]) -> List[str]: # Returns a list of POI IDs
new_stage_id = None
poi_ids: List[str] = []
is_possible_return_to_home_mission = False
Expand Down Expand Up @@ -157,13 +157,9 @@ def update_site_with_tasks(self, tasks) -> List[str]: # Returns a list of POI ID
):
time.sleep(settings.API_SLEEP_TIME)
return poi_ids

def initiate_mission(self, mission: Mission) -> None:
try:
poi_ids: List[str] = self.update_site_with_tasks(mission.tasks)
except RobotMissionNotSupportedException:
return


def create_mission_definition(self, mission: Mission, poi_ids: List[str]) -> str: # Returns a mission definition ID
# Note that the POI IDs need to be in the same order as inspection steps in the provided mission
mission_definition_id: str = self.api.create_mission_definition(
site_id=settings.ROBOT_EXR_SITE_ID,
mission_name=mission.id,
Expand All @@ -187,6 +183,15 @@ def initiate_mission(self, mission: Mission) -> None:
task_name="dock",
mission_definition_id=mission_definition_id,
)
return mission_definition_id

def initiate_mission(self, mission: Mission) -> None:
try:
poi_ids: List[str] = self.update_site_with_tasks(mission.tasks)
except RobotMissionNotSupportedException:
return

mission_definition_id: str = self.create_mission_definition(mission, poi_ids)

self.api.start_mission_execution(
mission_definition_id=mission_definition_id, robot_id=settings.ROBOT_EXR_ID
Expand Down

0 comments on commit 75b8848

Please sign in to comment.