Skip to content

Commit

Permalink
Add configurable return to home settings
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonsf authored and oysand committed Apr 23, 2024
1 parent ef94b18 commit b912302
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY . .
RUN --mount=source=.git,target=.git,type=bind
RUN pip install .

FROM ghcr.io/equinor/isar:v1.16.14
FROM ghcr.io/equinor/isar:v1.17.0
WORKDIR /app
COPY --from=build /app/venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Libraries",
]
dependencies = ["alitra", "isar"]
dependencies = ["alitra", "isar>=1.17.0"]
dynamic = ["version"]

[project.urls]
Expand Down
2 changes: 1 addition & 1 deletion src/isar_robot/config/settings.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CAPABILITIES = '["take_thermal_image", "take_image", "take_video", "take_thermal_video", "drive_to_pose", "record_audio", "localize", "docking_procedure"]'
CAPABILITIES = '["take_thermal_image", "take_image", "take_video", "take_thermal_video", "drive_to_pose", "record_audio", "localize", "return_to_home", "docking_procedure"]'
ROBOT_MODEL = Robot
2 changes: 2 additions & 0 deletions src/isar_robot/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def __init__(self) -> None:
SHOULD_FAIL_LOCALIZATION_MISSION: bool = Field(default=False)
SHOULD_FAIL_NORMAL_STEP: bool = Field(default=False)
SHOULD_FAIL_LOCALIZATION_STEP: bool = Field(default=False)
SHOULD_FAIL_RETURN_TO_HOME_STEP: bool = Field(default=False)
SHOULD_FAIL_RETURN_TO_HOME_MISSION: bool = Field(default=False)

model_config = SettingsConfigDict(
env_prefix="ROBOT_",
Expand Down
17 changes: 14 additions & 3 deletions src/isar_robot/robotinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@

from isar_robot import inspections, telemetry
from isar_robot.config.settings import settings
from isar_robot.utilities import is_localization_mission, is_localization_step
from isar_robot.utilities import (
is_localization_mission,
is_localization_step,
is_return_to_home_mission,
is_return_to_home_step,
)


class Robot(RobotInterface):
Expand All @@ -42,7 +47,10 @@ def mission_status(self) -> MissionStatus:
if settings.SHOULD_FAIL_LOCALIZATION_MISSION:
return MissionStatus.Failed

return MissionStatus.Successful
if is_return_to_home_mission(self.current_mission):
self.current_step = None
if settings.SHOULD_FAIL_RETURN_TO_HOME_MISSION:
return StepStatus.Failed

self.current_mission = None
if settings.SHOULD_FAIL_NORMAL_MISSION:
Expand All @@ -61,7 +69,10 @@ def step_status(self) -> StepStatus:
if settings.SHOULD_FAIL_LOCALIZATION_STEP:
return StepStatus.Failed

return StepStatus.Successful
if is_return_to_home_step(self.current_step):
self.current_step = None
if settings.SHOULD_FAIL_RETURN_TO_HOME_STEP:
return StepStatus.Failed

self.current_step = None
if settings.SHOULD_FAIL_NORMAL_STEP:
Expand Down
16 changes: 15 additions & 1 deletion src/isar_robot/utilities.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from robot_interface.models.mission.mission import Mission
from robot_interface.models.mission.step import Localize, Step
from robot_interface.models.mission.step import Localize, ReturnToHome, Step


def is_localization_mission(mission: Mission):
Expand All @@ -14,3 +14,17 @@ def is_localization_mission(mission: Mission):

def is_localization_step(step: Step):
return isinstance(step, Localize)


def is_return_to_home_mission(mission: Mission):
if len(mission.tasks) != 1:
return False
if len(mission.tasks[0].steps) != 1:
return False
if not isinstance(mission.tasks[0].steps[0], ReturnToHome):
return False
return True


def is_return_to_home_step(step: Step):
return isinstance(step, ReturnToHome)

0 comments on commit b912302

Please sign in to comment.