Skip to content

Commit

Permalink
Handle communication exception in robot status
Browse files Browse the repository at this point in the history
  • Loading branch information
aeshub committed Mar 4, 2023
1 parent 4a93cfd commit c3b4ea2
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import json
import logging
import time
from datetime import datetime
from logging import Logger
from queue import Queue
from threading import Thread

from isar.config.settings import settings
from isar.state_machine.states_enum import States
from isar.state_machine.state_machine import StateMachine
from isar.state_machine.states_enum import States
from robot_interface.models.exceptions import RobotCommunicationException
from robot_interface.models.mission.status import RobotStatus
from robot_interface.robot_interface import RobotInterface
from robot_interface.telemetry.mqtt_client import MqttPublisher
Expand Down Expand Up @@ -74,10 +77,16 @@ def run(self) -> None:

class RobotStatusMonitor:
def __init__(self, robot: RobotInterface):
self.robot = robot
self.robot: RobotInterface = robot
self.robot_status: RobotStatus = RobotStatus.Offline
self.logger: Logger = logging.getLogger("robot_status_monitor")

def run(self) -> None:
while True:
self.robot_status = self.robot.robot_status()
time.sleep(settings.ROBOT_API_STATUS_POLL_INTERVAL)
try:
self.robot_status = self.robot.robot_status()
except RobotCommunicationException:
self.logger.warning(
"Failed to get robot status due to a communication exception"
)
time.sleep(settings.ROBOT_API_STATUS_POLL_INTERVAL)

0 comments on commit c3b4ea2

Please sign in to comment.