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

Reintroduce isar task id in mission task definition #678

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
130 changes: 92 additions & 38 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 @@ -115,48 +116,101 @@ def to_inspection_task(task_definition: StartMissionTaskDefinition) -> TASKS:
inspection_definition = task_definition.inspection

if inspection_definition.type == InspectionTypes.image:
return TakeImage(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
if task_definition.id:
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(),
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
else:
return TakeImage(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
elif inspection_definition.type == InspectionTypes.video:
return TakeVideo(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
if task_definition.id:
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(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
else:
return TakeVideo(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
elif inspection_definition.type == InspectionTypes.thermal_image:
return TakeThermalImage(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
if task_definition.id:
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(),
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
else:
return TakeThermalImage(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
elif inspection_definition.type == InspectionTypes.thermal_video:
return TakeThermalVideo(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
if task_definition.id:
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(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
else:
return TakeThermalVideo(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
elif inspection_definition.type == InspectionTypes.audio:
return RecordAudio(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
if task_definition.id:
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(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
else:
return RecordAudio(
robot_pose=task_definition.pose.to_alitra_pose(),
tag_id=task_definition.tag,
target=task_definition.inspection.inspection_target.to_alitra_position(),
duration=inspection_definition.duration,
metadata=task_definition.inspection.metadata,
zoom=task_definition.zoom,
)
else:
raise ValueError(
f"Inspection type '{inspection_definition.type}' not supported"
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
Loading