Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable return to home settings #135

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.17
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
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ dacite==1.8.1
# isar
ecdsa==0.19.0
# via python-jose
fastapi==0.110.1
fastapi==0.110.2
# via
# fastapi-azure-auth
# isar
Expand All @@ -86,7 +86,7 @@ idna==3.7
# requests
injector==0.21.0
# via isar
isar==1.16.17
isar==1.17.0
# via isar-robot (pyproject.toml)
isodate==0.6.1
# via
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)