Skip to content

Commit

Permalink
wip Set task.inspection.id on start_mission
Browse files Browse the repository at this point in the history
  • Loading branch information
tsundvoll committed Dec 3, 2024
1 parent ce0e4e4 commit c2fd084
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/isar/apis/models/start_mission_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from robot_interface.models.mission.task import (
TASKS,
DockingProcedure,
InspectionTask,
Localize,
RecordAudio,
ReturnToHome,
Expand Down Expand Up @@ -69,7 +70,17 @@ def to_isar_mission(start_mission_definition: StartMissionDefinition) -> Mission
for start_mission_task_definition in start_mission_definition.tasks:
task: TASKS = create_isar_task(start_mission_task_definition)
if start_mission_task_definition.id:
# If the id is None from the incoming start_mission_task_definition, we will
# just use the autogenerated id
task.id = start_mission_task_definition.id

if isinstance(task, InspectionTask):
if start_mission_task_definition.inspection.id:
# If the id is None from the incoming
# start_mission_task_definition.inspection, we will just use the
# autogenerated id
task.inspection.id = start_mission_task_definition.inspection.id

isar_tasks.append(task)

if not isar_tasks:
Expand Down
4 changes: 2 additions & 2 deletions src/isar/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
from isar.services.service_connections.mqtt.robot_info_publisher import (
RobotInfoPublisher,
)
from robot_interface.models.inspection.inspection import Inspection
from robot_interface.models.mission.mission import Mission
from isar.state_machine.state_machine import StateMachine, main
from isar.storage.uploader import Uploader
from robot_interface.models.inspection.inspection import Inspection
from robot_interface.models.mission.mission import Mission
from robot_interface.robot_interface import RobotInterface


Expand Down
Empty file.
44 changes: 44 additions & 0 deletions tests/isar/apis/models/test_start_mission_definition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from isar.apis.models.models import InputOrientation, InputPose, InputPosition
from isar.apis.models.start_mission_definition import (
InspectionTypes,
StartMissionDefinition,
StartMissionInspectionDefinition,
StartMissionTaskDefinition,
TaskType,
to_isar_mission,
)
from robot_interface.models.mission.mission import Mission
from robot_interface.models.mission.task import TakeImage


def test_to_isar_mission():

DUMMY_MISSION_ID = "123-45-567"
DUMMY_MISSION_NAME = "mission_name"
DUMMY_ISAR_TASK_ID = "abc-de-fgh"

inspection_definition = StartMissionInspectionDefinition(
type=InspectionTypes.image,
inspection_target=InputPosition(x=0, y=0, z=0),
id=DUMMY_ISAR_TASK_ID,
)
task_pose = InputPose(
position=InputPosition(x=0, y=0, z=0),
orientation=InputOrientation(x=0, y=0, z=0, w=0),
)
task_definition = StartMissionTaskDefinition(
type=TaskType.Inspection, pose=task_pose, inspection=inspection_definition
)
mission_definition = StartMissionDefinition(
tasks=[task_definition], id=DUMMY_MISSION_ID, name=DUMMY_MISSION_NAME
)

# expected_task = TakeImage()

# # expected_mission = Mission(
# # tasks=[expected_task], id=DUMMY_MISSION_ID, name=DUMMY_MISSION_NAME
# # )

resulting_isar_mission = to_isar_mission(mission_definition)

assert resulting_isar_mission.tasks[0].inspection.id == DUMMY_ISAR_TASK_ID

0 comments on commit c2fd084

Please sign in to comment.