Skip to content

Commit

Permalink
Reintroduce isar task id in mission task definition
Browse files Browse the repository at this point in the history
for Flotilla to be able to match its existing task request to the
one that is returned from ISAR
  • Loading branch information
tsundvoll committed Dec 12, 2024
1 parent c8ff71c commit 000ec32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/isar/apis/models/start_mission_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class StartMissionInspectionDefinition(BaseModel):


class StartMissionTaskDefinition(BaseModel):
id: Optional[str] = None
type: TaskType = Field(default=TaskType.Inspection)
pose: InputPose
inspection: Optional[StartMissionInspectionDefinition] = None
Expand Down Expand Up @@ -116,6 +117,7 @@ def to_inspection_task(task_definition: StartMissionTaskDefinition) -> TASKS:

if inspection_definition.type == InspectionTypes.image:
return TakeImage(
id=task_definition.id,
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
Expand All @@ -124,6 +126,7 @@ def to_inspection_task(task_definition: StartMissionTaskDefinition) -> TASKS:
)
elif inspection_definition.type == InspectionTypes.video:
return TakeVideo(
id=task_definition.id,
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
Expand All @@ -133,6 +136,7 @@ def to_inspection_task(task_definition: StartMissionTaskDefinition) -> TASKS:
)
elif inspection_definition.type == InspectionTypes.thermal_image:
return TakeThermalImage(
id=task_definition.id,
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
Expand All @@ -141,6 +145,7 @@ def to_inspection_task(task_definition: StartMissionTaskDefinition) -> TASKS:
)
elif inspection_definition.type == InspectionTypes.thermal_video:
return TakeThermalVideo(
id=task_definition.id,
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
Expand All @@ -150,6 +155,7 @@ def to_inspection_task(task_definition: StartMissionTaskDefinition) -> TASKS:
)
elif inspection_definition.type == InspectionTypes.audio:
return RecordAudio(
id=task_definition.id,
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
Expand Down
4 changes: 2 additions & 2 deletions src/robot_interface/models/mission/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Task(BaseModel):
status: TaskStatus = Field(default=TaskStatus.NotStarted)
error_message: Optional[ErrorMessage] = Field(default=None)
tag_id: Optional[str] = Field(default=None)
id: str = Field(default_factory=uuid4_string)
id: str = Field(default_factory=uuid4_string, frozen=True)

def is_finished(self) -> bool:
if (
Expand All @@ -59,7 +59,7 @@ class InspectionTask(Task):
Base class for all inspection tasks which produce results to be uploaded.
"""

inspection_id: str = Field(default_factory=uuid4_string)
inspection_id: str = Field(default_factory=uuid4_string, frozen=True)
robot_pose: Pose = Field(default=None, init=True)
metadata: Optional[dict] = Field(default_factory=dict)
zoom: Optional[ZoomDescription] = Field(default=None)
Expand Down

0 comments on commit 000ec32

Please sign in to comment.