Skip to content

Commit

Permalink
Set id in Inspection at instantiation of Image etc
Browse files Browse the repository at this point in the history
to be equal the incoming task.inspection_id
  • Loading branch information
tsundvoll committed Dec 13, 2024
1 parent 9a9cc07 commit 03e367c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
30 changes: 12 additions & 18 deletions src/isar_robot/inspections.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
)


def create_image(task_actions: Union[TakeImage, TakeThermalImage]):
def create_image(task_actions: Union[TakeImage, TakeThermalImage]) -> Image:
now: datetime = datetime.utcnow()
image_metadata: ImageMetadata = ImageMetadata(
start_time=now,
Expand All @@ -51,15 +51,13 @@ def create_image(task_actions: Union[TakeImage, TakeThermalImage]):
image_metadata.analysis_type = ["test1", "test2"]
image_metadata.additional = task_actions.metadata

image: Image = Image(metadata=image_metadata)

filepath: Path = random.choice(list(example_images.iterdir()))
image.data = _read_data_from_file(filepath)
data = _read_data_from_file(filepath)

return image
return Image(metadata=image_metadata, id=task_actions.inspection_id, data=data)


def create_video(task_actions: TakeVideo):
def create_video(task_actions: TakeVideo) -> Video:
now: datetime = datetime.utcnow()
video_metadata: VideoMetadata = VideoMetadata(
start_time=now,
Expand All @@ -71,12 +69,10 @@ def create_video(task_actions: TakeVideo):
video_metadata.analysis_type = ["test1", "test2"]
video_metadata.additional = task_actions.metadata

video: Video = Video(metadata=video_metadata)

filepath: Path = random.choice(list(example_videos.iterdir()))
video.data = _read_data_from_file(filepath)
data = _read_data_from_file(filepath)

return video
return Video(metadata=video_metadata, id=task_actions.inspection_id, data=data)


def create_thermal_video(task_actions: TakeThermalVideo):
Expand All @@ -91,12 +87,12 @@ def create_thermal_video(task_actions: TakeThermalVideo):
thermal_video_metadata.analysis_type = ["test1", "test2"]
thermal_video_metadata.additional = task_actions.metadata

thermal_video: ThermalVideo = ThermalVideo(metadata=thermal_video_metadata)

filepath: Path = random.choice(list(example_thermal_videos.iterdir()))
thermal_video.data = _read_data_from_file(filepath)
data = _read_data_from_file(filepath)

return thermal_video
return ThermalVideo(
metadata=thermal_video_metadata, id=task_actions.inspection_id, data=data
)


def create_audio(task_actions: RecordAudio):
Expand All @@ -111,12 +107,10 @@ def create_audio(task_actions: RecordAudio):
audio_metadata.analysis_type = ["test1", "test2"]
audio_metadata.additional = task_actions.metadata

audio: Audio = Audio(metadata=audio_metadata)

filepath: Path = random.choice(list(example_thermal_videos.iterdir()))
audio.data = _read_data_from_file(filepath)
data = _read_data_from_file(filepath)

return audio
return Audio(metadata=audio_metadata, id=task_actions.inspection_id, data=data)


def _read_data_from_file(filename: Path) -> bytes:
Expand Down
7 changes: 2 additions & 5 deletions src/isar_robot/robotinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from robot_interface.models.initialize import InitializeParams
from robot_interface.models.inspection.inspection import Inspection
from robot_interface.models.mission.mission import Mission
from robot_interface.models.mission.task import Task
from robot_interface.models.mission.status import RobotStatus, TaskStatus
from robot_interface.models.mission.task import (
InspectionTask,
Expand All @@ -17,17 +16,15 @@
TakeThermalImage,
TakeThermalVideo,
TakeVideo,
Task,
)
from robot_interface.models.robots.media import MediaConfig
from robot_interface.robot_interface import RobotInterface
from robot_interface.telemetry.mqtt_client import MqttTelemetryPublisher

from isar_robot import inspections, telemetry
from isar_robot.config.settings import settings
from isar_robot.utilities import (
is_localization_task,
is_return_to_home_task,
)
from isar_robot.utilities import is_localization_task, is_return_to_home_task


class Robot(RobotInterface):
Expand Down

0 comments on commit 03e367c

Please sign in to comment.