isar 1.24.5__py3-none-any.whl → 1.25.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of isar might be problematic. Click here for more details.

@@ -1,8 +1,8 @@
1
- from dataclasses import dataclass, field
2
1
  from enum import Enum
3
- from typing import Iterator, Literal, Optional, Type, Union
2
+ from typing import Literal, Optional, Type, Union
4
3
 
5
4
  from alitra import Pose, Position
5
+ from pydantic import BaseModel, Field
6
6
 
7
7
  from robot_interface.models.exceptions.robot_exceptions import ErrorMessage
8
8
  from robot_interface.models.inspection import (
@@ -29,18 +29,16 @@ class TaskTypes(str, Enum):
29
29
  DockingProcedure = "docking_procedure"
30
30
 
31
31
 
32
- @dataclass
33
- class ZoomDescription:
32
+ class ZoomDescription(BaseModel):
34
33
  objectWidth: float
35
34
  objectHeight: float
36
35
 
37
36
 
38
- @dataclass
39
- class Task:
40
- status: TaskStatus = field(default=TaskStatus.NotStarted, init=False)
41
- error_message: Optional[ErrorMessage] = field(default=None, init=False)
42
- tag_id: Optional[str] = field(default=None)
43
- id: str = field(default_factory=uuid4_string, init=True)
37
+ class Task(BaseModel):
38
+ status: TaskStatus = Field(default=TaskStatus.NotStarted)
39
+ error_message: Optional[ErrorMessage] = Field(default=None)
40
+ tag_id: Optional[str] = Field(default=None)
41
+ id: str = Field(default_factory=uuid4_string)
44
42
 
45
43
  def is_finished(self) -> bool:
46
44
  if (
@@ -56,69 +54,63 @@ class Task:
56
54
  return self.status
57
55
 
58
56
 
59
- @dataclass
60
57
  class InspectionTask(Task):
61
58
  """
62
59
  Base class for all inspection tasks which produce results to be uploaded.
63
60
  """
64
61
 
65
- inspection: Inspection = field(default=None, init=True)
66
- robot_pose: Pose = field(default=None, init=True)
67
- metadata: Optional[dict] = field(default_factory=dict, init=True)
68
- zoom: Optional[ZoomDescription] = field(default=None)
62
+ inspection_id: str = Field(default_factory=uuid4_string)
63
+ robot_pose: Pose = Field(default=None, init=True)
64
+ metadata: Optional[dict] = Field(default_factory=dict)
65
+ zoom: Optional[ZoomDescription] = Field(default=None)
69
66
 
70
67
  @staticmethod
71
68
  def get_inspection_type() -> Type[Inspection]:
72
69
  return Inspection
73
70
 
74
71
 
75
- @dataclass
76
72
  class DockingProcedure(Task):
77
73
  """
78
74
  Task which causes the robot to dock or undock
79
75
  """
80
76
 
81
- behavior: Literal["dock", "undock"] = field(default=None, init=True)
77
+ behavior: Literal["dock", "undock"] = Field(default=None)
82
78
  type: Literal[TaskTypes.DockingProcedure] = TaskTypes.DockingProcedure
83
79
 
84
80
 
85
- @dataclass
86
81
  class ReturnToHome(Task):
87
82
  """
88
83
  Task which cases the robot to return home
89
84
  """
90
85
 
91
- pose: Pose = field(default=None, init=True)
86
+ pose: Pose = Field(default=None)
92
87
  type: Literal[TaskTypes.ReturnToHome] = TaskTypes.ReturnToHome
93
88
 
94
89
 
95
- @dataclass
96
90
  class Localize(Task):
97
91
  """
98
92
  Task which causes the robot to localize
99
93
  """
100
94
 
101
- localization_pose: Pose = field(default=None, init=True)
95
+ localization_pose: Pose = Field(default=None)
102
96
  type: Literal[TaskTypes.Localize] = TaskTypes.Localize
103
97
 
104
98
 
105
- @dataclass
106
99
  class MoveArm(Task):
107
100
  """
108
101
  Task which causes the robot to move its arm
109
102
  """
110
103
 
111
- arm_pose: str = field(default=None, init=True)
104
+ arm_pose: str = Field(default=None)
112
105
  type: Literal[TaskTypes.MoveArm] = TaskTypes.MoveArm
113
106
 
114
107
 
115
- @dataclass
116
108
  class TakeImage(InspectionTask):
117
109
  """
118
- Task which causes the robot to take an image towards the given coordinate.
110
+ Task which causes the robot to take an image towards the given target.
119
111
  """
120
112
 
121
- target: Position = field(default=None, init=True)
113
+ target: Position = Field(default=None)
122
114
  type: Literal[TaskTypes.TakeImage] = TaskTypes.TakeImage
123
115
 
124
116
  @staticmethod
@@ -126,13 +118,12 @@ class TakeImage(InspectionTask):
126
118
  return Image
127
119
 
128
120
 
129
- @dataclass
130
121
  class TakeThermalImage(InspectionTask):
131
122
  """
132
- Task which causes the robot to take a thermal image towards the given coordinate.
123
+ Task which causes the robot to take a thermal image towards the given target.
133
124
  """
134
125
 
135
- target: Position = field(default=None, init=True)
126
+ target: Position = Field(default=None)
136
127
  type: Literal[TaskTypes.TakeThermalImage] = TaskTypes.TakeThermalImage
137
128
 
138
129
  @staticmethod
@@ -140,16 +131,15 @@ class TakeThermalImage(InspectionTask):
140
131
  return ThermalImage
141
132
 
142
133
 
143
- @dataclass
144
134
  class TakeVideo(InspectionTask):
145
135
  """
146
- Task which causes the robot to take a video towards the given coordinate.
136
+ Task which causes the robot to take a video towards the given target.
147
137
 
148
138
  Duration of video is given in seconds.
149
139
  """
150
140
 
151
- target: Position = field(default=None, init=True)
152
- duration: float = field(default=None, init=True)
141
+ target: Position = Field(default=None)
142
+ duration: float = Field(default=None)
153
143
  type: Literal[TaskTypes.TakeVideo] = TaskTypes.TakeVideo
154
144
 
155
145
  @staticmethod
@@ -157,16 +147,15 @@ class TakeVideo(InspectionTask):
157
147
  return Video
158
148
 
159
149
 
160
- @dataclass
161
150
  class TakeThermalVideo(InspectionTask):
162
151
  """
163
- Task which causes the robot to record thermal video towards the given coordinate
152
+ Task which causes the robot to record thermal video towards the given target
164
153
 
165
154
  Duration of video is given in seconds.
166
155
  """
167
156
 
168
- target: Position = field(default=None, init=True)
169
- duration: float = field(default=None, init=True)
157
+ target: Position = Field(default=None)
158
+ duration: float = Field(default=None)
170
159
  type: Literal[TaskTypes.TakeThermalVideo] = TaskTypes.TakeThermalVideo
171
160
 
172
161
  @staticmethod
@@ -174,7 +163,6 @@ class TakeThermalVideo(InspectionTask):
174
163
  return ThermalVideo
175
164
 
176
165
 
177
- @dataclass
178
166
  class RecordAudio(InspectionTask):
179
167
  """
180
168
  Task which causes the robot to record a video at its position, facing the target.
@@ -182,8 +170,8 @@ class RecordAudio(InspectionTask):
182
170
  Duration of audio is given in seconds.
183
171
  """
184
172
 
185
- target: Position = field(default=None, init=True)
186
- duration: float = field(default=None, init=True)
173
+ target: Position = Field(default=None)
174
+ duration: float = Field(default=None)
187
175
  type: Literal[TaskTypes.RecordAudio] = TaskTypes.RecordAudio
188
176
 
189
177
  @staticmethod
@@ -1,14 +1,14 @@
1
1
  from abc import ABCMeta, abstractmethod
2
2
  from queue import Queue
3
3
  from threading import Thread
4
- from typing import Callable, List
4
+ from typing import Callable, List, Optional
5
5
 
6
- from robot_interface.models.robots.media import MediaConfig
7
6
  from robot_interface.models.initialize import InitializeParams
8
7
  from robot_interface.models.inspection.inspection import Inspection
9
8
  from robot_interface.models.mission.mission import Mission
10
9
  from robot_interface.models.mission.status import RobotStatus, TaskStatus
11
10
  from robot_interface.models.mission.task import InspectionTask, Task
11
+ from robot_interface.models.robots.media import MediaConfig
12
12
 
13
13
 
14
14
  class RobotInterface(metaclass=ABCMeta):
@@ -166,8 +166,10 @@ class RobotInterface(metaclass=ABCMeta):
166
166
 
167
167
  Returns
168
168
  -------
169
- Sequence[InspectionResult]
170
- List containing all the inspection results connected to the given task
169
+ Sequence[Inspection]
170
+ List containing all the inspection connected to the given task.
171
+ get_inspection has responsibility to assign the inspection_id of the task
172
+ to the inspection that it returns.
171
173
 
172
174
  Raises
173
175
  ------
@@ -226,7 +228,7 @@ class RobotInterface(metaclass=ABCMeta):
226
228
  raise NotImplementedError
227
229
 
228
230
  @abstractmethod
229
- def generate_media_config(self) -> MediaConfig:
231
+ def generate_media_config(self) -> Optional[MediaConfig]:
230
232
  """
231
233
  Generate a JSON containing the url and token needed to establish a media stream
232
234
  connection to a robot.
File without changes
@@ -1,37 +0,0 @@
1
- import json
2
- import logging
3
- from dataclasses import is_dataclass
4
- from logging import Logger
5
- from pathlib import Path
6
- from typing import Any, Optional
7
-
8
- from dacite import Config, from_dict
9
-
10
- logger: Logger = logging.getLogger("api")
11
-
12
-
13
- class BaseReader:
14
- @staticmethod
15
- def read_json(location: Path) -> dict:
16
- with open(location) as json_file:
17
- return json.load(json_file)
18
-
19
- @staticmethod
20
- def dict_to_dataclass(
21
- dataclass_dict: dict,
22
- target_dataclass: Any,
23
- cast_config: list = [],
24
- strict_config: bool = False,
25
- ) -> Optional[Any]:
26
- if not is_dataclass(target_dataclass):
27
- raise BaseReaderError("{target_dataclass} is not a dataclass")
28
- generated_dataclass = from_dict(
29
- data_class=target_dataclass,
30
- data=dataclass_dict,
31
- config=Config(cast=cast_config, strict=strict_config),
32
- )
33
- return generated_dataclass
34
-
35
-
36
- class BaseReaderError(Exception):
37
- pass
File without changes
File without changes