Source code for alarm_handlers.thruster_out

import rospy
from ros_alarms import Alarm, HandlerBase
from subjugator_msgs.srv import UpdateThrusterLayout


[docs]class ThrusterOut(HandlerBase): """ Alarm class to indicate that some of the thrusters in the thruster layout are offline. Attributes: alarm_name (str): The name of the alarm. Set to ``thruster-out``. """ alarm_name = "thruster-out" def __init__(self): # Alarm server will set this as the initial state of kill alarm self.initial_alarm = Alarm( self.alarm_name, False, node_name="alarm_server", parameters={"offline_thruster_names": []}, ) self._update_layout_proxy = rospy.ServiceProxy( "update_thruster_layout", UpdateThrusterLayout, )
[docs] def update_layout(self, *args, **kwargs): """ Attempts to update the thruster layout with the name of any offline thrusters. """ try: self._update_layout_proxy(*args, **kwargs) except rospy.ServiceException as e: rospy.logwarn(f"Error updating thruster layout: {e}")
[docs] def raised(self, alarm: Alarm): """ Called when the alarm is raised. Attempts to update the thruster layout with :meth:`~.update_layout`. """ self.update_layout(alarm.parameters["offline_thruster_names"])
[docs] def cleared(self, alarm: Alarm): """ Called when the alarm is cleared. Attempts to update the thruster layout with :meth:`~.update_layout`. """ self.update_layout(alarm.parameters["offline_thruster_names"])