Skip to content

Commit

Permalink
Catch telemetry pose exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreo committed Oct 15, 2024
1 parent 33618f8 commit cbd84f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/robot_interface/models/exceptions/robot_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
RobotTelemetryPoseException: str = "robot_telemetry_pose_exception"
RobotMapException: str = "robot_map_exception"
RobotTransformException: str = "robot_transform_exception"
RobotUnknownErrorException: str = "robot_unknown_error_exception"
Expand Down Expand Up @@ -189,6 +190,18 @@ def __init__(self, error_description: str) -> None:
pass


# An exception which should be thrown by the robot package if it is unable to retrieve
# telemetry pose data. It should be used exclusively by the telemetry pose publisher.
class RobotTelemetryPoseException(RobotException):
def __init__(self, error_description: str) -> None:
super().__init__(
error_reason=ErrorReason.RobotTelemetryPoseException,
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
Expand Down
8 changes: 7 additions & 1 deletion src/robot_interface/telemetry/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
from queue import Queue
from typing import Callable, Tuple

from robot_interface.models.exceptions.robot_exceptions import RobotTelemetryException
from robot_interface.models.exceptions.robot_exceptions import (
RobotTelemetryException,
RobotTelemetryPoseException,
)
from robot_interface.telemetry.payloads import CloudHealthPayload
from robot_interface.utilities.json_service import EnhancedJSONEncoder

Expand Down Expand Up @@ -71,6 +74,9 @@ 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:
time.sleep(self.interval)
continue
except RobotTelemetryException:
payload = json.dumps(
CloudHealthPayload(isar_id, robot_name, datetime.now(timezone.utc)),
Expand Down

0 comments on commit cbd84f2

Please sign in to comment.