From a26f4a762f0d2e3b1496bbc43f6d56008c3deea1 Mon Sep 17 00:00:00 2001 From: oysand Date: Fri, 29 Nov 2024 11:45:40 +0100 Subject: [PATCH] Add telemetry no update exception --- .../models/exceptions/robot_exceptions.py | 12 ++++++++++++ src/robot_interface/telemetry/mqtt_client.py | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/robot_interface/models/exceptions/robot_exceptions.py b/src/robot_interface/models/exceptions/robot_exceptions.py index f3c50e32..e2cc3e2b 100644 --- a/src/robot_interface/models/exceptions/robot_exceptions.py +++ b/src/robot_interface/models/exceptions/robot_exceptions.py @@ -16,6 +16,7 @@ class ErrorReason(str, Enum): RobotRetrieveDataException: str = "robot_retrieve_data_exception" RobotRetrieveInspectionException: str = "robot_retrieve_inspection_exception" RobotTelemetryException: str = "robot_telemetry_exception" + RobotTelemetryNoUpdateException: str = "robot_telemetry_no_update_exception" RobotTelemetryPoseException: str = "robot_telemetry_pose_exception" RobotMapException: str = "robot_map_exception" RobotTransformException: str = "robot_transform_exception" @@ -202,6 +203,17 @@ def __init__(self, error_description: str) -> None: pass +# An exception which should be thrown by the robot package if there is no new telemetry update. +class RobotTelemetryNoUpdateException(RobotException): + def __init__(self, error_description: str) -> None: + super().__init__( + error_reason=ErrorReason.RobotTelemetryNoUpdateException, + error_description=error_description, + ) + + pass + + # An exception which should be thrown by the robot package if it is unable to load the # configuration for maps and transformations. This could be caused by faulty # configuration and this exception will cause ISAR to crash as further execution is not diff --git a/src/robot_interface/telemetry/mqtt_client.py b/src/robot_interface/telemetry/mqtt_client.py index 7048db2f..9f2b410b 100644 --- a/src/robot_interface/telemetry/mqtt_client.py +++ b/src/robot_interface/telemetry/mqtt_client.py @@ -7,6 +7,7 @@ from robot_interface.models.exceptions.robot_exceptions import ( RobotTelemetryException, + RobotTelemetryNoUpdateException, RobotTelemetryPoseException, ) from robot_interface.telemetry.payloads import CloudHealthPayload @@ -74,7 +75,7 @@ def run(self, isar_id: str, robot_name: str) -> None: try: payload = self.telemetry_method(isar_id=isar_id, robot_name=robot_name) topic = self.topic - except RobotTelemetryPoseException: + except (RobotTelemetryPoseException, RobotTelemetryNoUpdateException): time.sleep(self.interval) continue except RobotTelemetryException: