Skip to content

Commit

Permalink
Change name robot_id to isar_id and robot_name
Browse files Browse the repository at this point in the history
Add isar_id and robot_name
  • Loading branch information
OleDrange committed Mar 16, 2023
1 parent 16aff49 commit 61160ad
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 27 deletions.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
threads.append(robot_info_thread)

publishers: List[Thread] = robot.get_telemetry_publishers(
queue=queues.mqtt_queue, robot_id=settings.ROBOT_ID
queue=queues.mqtt_queue,
robot_name=settings.ROBOT_NAME,
isar_id=settings.ISAR_ID,
)
if publishers:
threads.extend(publishers)
Expand Down
3 changes: 2 additions & 1 deletion src/isar/apis/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class ControlMissionResponse(BaseModel):

class RobotInfoResponse(BaseModel):
robot_package: str
robot_id: str
isar_id: str
robot_name: str
robot_capabilities: List[str]
robot_map_name: str
plant_short_name: str
Expand Down
3 changes: 2 additions & 1 deletion src/isar/apis/schedule/scheduling_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def drive_to(
def get_info(self):
return RobotInfoResponse(
robot_package=settings.ROBOT_PACKAGE,
robot_id=settings.ROBOT_ID,
isar_id=settings.ISAR_ID,
robot_name=settings.ROBOT_NAME,
robot_map_name=settings.DEFAULT_MAP,
robot_capabilities=robot_settings.CAPABILITIES,
plant_short_name=settings.STID_PLANT_NAME,
Expand Down
1 change: 0 additions & 1 deletion src/isar/config/settings.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ISAR_MQTT_SSL_ENABLED = true

ISAR_AUTHENTICATION_ENABLED = false

ISAR_ROBOT_ID = R2-D2
ISAR_PLANT_SHORT_NAME = KAA
ISAR_STID_PLANT_NAME = KAA

Expand Down
9 changes: 6 additions & 3 deletions src/isar/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ class Settings(BaseSettings):
# Type of robot ISAR is monitoring
ROBOT_TYPE: str = Field(default="robot")

# Name or unique ID of robot
ROBOT_ID: str = Field(default="R2-D2")
# Name of robot
ROBOT_NAME: str = Field(default="Placebot")

# Unique identifier for this ISAR instance. Note that this should be a generated UUID.
ISAR_ID: str = Field(default="00000000-0000-0000-0000-000000000000")

# Serial number of the robot ISAR is connected to
SERIAL_NUMBER: str = Field(default="0001")
Expand Down Expand Up @@ -292,7 +295,7 @@ def set_log_levels(cls, v, values) -> dict:
always=True,
)
def prefix_isar_topics(cls, v, values):
return f"isar/{values['ROBOT_ID']}/{v}"
return f"isar/{values['ISAR_ID']}/{v}"

class Config:
with pkg_resources.path("isar.config", "settings.env") as path:
Expand Down
4 changes: 2 additions & 2 deletions src/isar/models/mission/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ def set_unique_id_and_metadata(self) -> None:

def _set_unique_id(self) -> None:
plant_short_name: str = settings.PLANT_SHORT_NAME
robot_id: str = settings.ROBOT_ID
robot_name: str = settings.ROBOT_NAME
now: datetime = datetime.utcnow()
self.id = (
f"{plant_short_name.upper()}{robot_id.upper()}"
f"{plant_short_name.upper()}{robot_name.upper()}"
f"{now.strftime('%d%m%Y%H%M%S%f')[:-3]}"
)

Expand Down
3 changes: 2 additions & 1 deletion src/isar/models/mission_metadata/mission_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MissionMetadata:
media_orientation_reference_system: str = (
settings.MEDIA_ORIENTATION_REFERENCE_SYSTEM
)
robot_id: str = settings.ROBOT_ID
isar_id: str = settings.ISAR_ID
robot_name: str = settings.ROBOT_NAME
robot_model: str = settings.ROBOT_TYPE
mission_date: date = datetime.utcnow().date()
3 changes: 2 additions & 1 deletion src/isar/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def provide_task_selector(self) -> TaskSelectorInterface:
"queues": (QueuesModule, "required"),
"request_handler": (RequestHandlerModule, "required"),
"robot_package": (RobotModule, settings.ROBOT_PACKAGE),
"robot_id": (RobotModule, settings.ROBOT_ID),
"isar_id": (RobotModule, settings.ISAR_ID),
"robot_name": (RobotModule, settings.ROBOT_NAME),
"mission_planner": (
{
"default": LocalPlannerModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def __init__(self, mqtt_queue: Queue):
def run(self) -> None:
while True:
payload: RobotInfoPayload = RobotInfoPayload(
robot_name=settings.ROBOT_ID,
isar_id=settings.ISAR_ID,
robot_name=settings.ROBOT_NAME,
robot_model=robot_settings.ROBOT_MODEL, # type: ignore
robot_serial_number=settings.SERIAL_NUMBER,
video_streams=settings.VIDEO_STREAMS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def run(self) -> None:
)

payload: RobotStatusPayload = RobotStatusPayload(
robot_name=settings.ROBOT_ID,
isar_id=settings.ISAR_ID,
robot_name=settings.ROBOT_NAME,
robot_status=combined_status,
current_isar_state=self.state_machine.current_state,
current_mission_id=self.state_machine.current_mission.id
Expand Down
12 changes: 8 additions & 4 deletions src/isar/state_machine/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ def publish_mission_status(self) -> None:
return
payload: str = json.dumps(
{
"robot_id": settings.ROBOT_ID,
"isar_id": settings.ISAR_ID,
"robot_name": settings.ROBOT_NAME,
"mission_id": self.current_mission.id if self.current_mission else None,
"status": self.current_mission.status if self.current_mission else None,
"timestamp": datetime.utcnow(),
Expand All @@ -456,7 +457,8 @@ def publish_task_status(self) -> None:
return
payload: str = json.dumps(
{
"robot_id": settings.ROBOT_ID,
"isar_id": settings.ISAR_ID,
"robot_name": settings.ROBOT_NAME,
"mission_id": self.current_mission.id if self.current_mission else None,
"task_id": self.current_task.id if self.current_task else None,
"status": self.current_task.status if self.current_task else None,
Expand All @@ -477,7 +479,8 @@ def publish_step_status(self) -> None:
return
payload: str = json.dumps(
{
"robot_id": settings.ROBOT_ID,
"isar_id": settings.ISAR_ID,
"robot_name": settings.ROBOT_NAME,
"mission_id": self.current_mission.id if self.current_mission else None,
"task_id": self.current_task.id if self.current_task else None,
"step_id": self.current_step.id if self.current_step else None,
Expand All @@ -501,7 +504,8 @@ def publish_state(self) -> None:
return
payload: str = json.dumps(
{
"robot_id": settings.ROBOT_ID,
"isar_id": settings.ISAR_ID,
"robot_name": settings.ROBOT_NAME,
"state": self.current_state,
"timestamp": datetime.utcnow(),
},
Expand Down
4 changes: 2 additions & 2 deletions src/isar/storage/slimm_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _construct_multiform_request_image(
"Geodetic.CoordinateReferenceSystemCode": metadata.coordinate_reference_system, # noqa: E501
"Geodetic.VerticalCoordinateReferenceSystemCode": metadata.vertical_reference_system, # noqa: E501
"Geodetic.OrientationReferenceSystem": metadata.media_orientation_reference_system, # noqa: E501
"SensorCarrier.SensorCarrierId": metadata.robot_id,
"SensorCarrier.SensorCarrierId": metadata.isar_id,
"SensorCarrier.ModelName": metadata.robot_model,
"Mission.MissionId": metadata.mission_id,
"Mission.Client": "Equinor",
Expand Down Expand Up @@ -150,7 +150,7 @@ def _construct_multiform_request_video(
"Geodetic.CoordinateReferenceSystemCode": metadata.coordinate_reference_system, # noqa: E501
"Geodetic.VerticalCoordinateReferenceSystemCode": metadata.vertical_reference_system, # noqa: E501
"Geodetic.OrientationReferenceSystem": metadata.media_orientation_reference_system, # noqa: E501
"SensorCarrier.SensorCarrierId": metadata.robot_id,
"SensorCarrier.SensorCarrierId": metadata.isar_id,
"SensorCarrier.ModelName": metadata.robot_model,
"Mission.MissionId": metadata.mission_id,
"Mission.Client": "Equinor",
Expand Down
3 changes: 2 additions & 1 deletion src/isar/storage/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def construct_metadata_file(
"mission_id": metadata.mission_id,
"plant_name": metadata.plant_name,
"mission_date": metadata.mission_date,
"robot_id": metadata.robot_id,
"isar_id": metadata.isar_id,
"robot_name": metadata.robot_name,
},
"data": [
{
Expand Down
6 changes: 4 additions & 2 deletions src/robot_interface/robot_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ def initialize(self, params: InitializeParams) -> None:
raise NotImplementedError

@abstractmethod
def get_telemetry_publishers(self, queue: Queue, robot_id: str) -> List[Thread]:
def get_telemetry_publishers(
self, queue: Queue, isar_id: str, robot_name: str
) -> List[Thread]:
"""
Set up telemetry publisher threads to publish regular updates for pose, battery
level etc. from the robot to the MQTT broker. The publishers on the robot side
will use the queue to pass messages to the MQTT Client on the ISAR side.
The robot_id is passed to the robot to ensure the messages are published to the
The isar_id is passed to the robot to ensure the messages are published to the
correct topics.
Note that this functionality will only be utilized if MQTT is enabled in the
Expand Down
6 changes: 4 additions & 2 deletions src/robot_interface/telemetry/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ def __init__(
self.qos: int = qos
self.retain: bool = retain

def run(self, robot_id: str) -> None:
def run(self, isar_id: str, robot_name: str) -> None:
while True:
try:
payload: str = self.telemetry_method(robot_id)
payload: str = self.telemetry_method(
isar_id=isar_id, robot_name=robot_name
)
except RobotInvalidTelemetryException:
continue

Expand Down
8 changes: 6 additions & 2 deletions src/robot_interface/telemetry/payloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
@dataclass
class TelemetryPosePayload:
pose: Pose
robot_id: str
isar_id: str
robot_name: str
timestamp: datetime


@dataclass
class TelemetryBatteryPayload:
battery_level: float
robot_id: str
isar_id: str
robot_name: str
timestamp: datetime


Expand All @@ -31,6 +33,7 @@ class VideoStream:

@dataclass
class RobotStatusPayload:
isar_id: str
robot_name: str
robot_status: RobotStatus
current_isar_state: State
Expand All @@ -42,6 +45,7 @@ class RobotStatusPayload:

@dataclass
class RobotInfoPayload:
isar_id: str
robot_name: str
robot_model: str
robot_serial_number: str
Expand Down
4 changes: 3 additions & 1 deletion tests/mocks/robot_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def get_inspections(self, step: InspectionStep) -> Sequence[Inspection]:
def initialize(self, params: InitializeParams) -> None:
return

def get_telemetry_publishers(self, queue: Queue, robot_id: str) -> List[Thread]:
def get_telemetry_publishers(
self, queue: Queue, isar_id: str, robot_name: str
) -> List[Thread]:
return []

def robot_status(self) -> RobotStatus:
Expand Down

0 comments on commit 61160ad

Please sign in to comment.