21 from cob_msgs.msg
import EmergencyStopState
22 from diagnostic_msgs.msg
import DiagnosticArray
25 from simple_script_server
import *
31 now = rospy.Time.now()
37 for component
in list(self.components.keys()):
40 rospy.Service(
'~enable',Trigger,self.
enable_cb)
41 rospy.Service(
'~disable',Trigger,self.
disable_cb)
49 if msg.emergency_state == 0
and self.
em_state != 0:
50 rospy.loginfo(
"auto_recover from emergency state")
51 self.
recover(list(self.components.keys()))
52 self.
em_state = copy.deepcopy(msg.emergency_state)
58 for status
in msg.status:
59 for component
in list(self.components.keys()):
61 rospy.loginfo(
"auto_recover from diagnostic failure")
68 return TriggerResponse(
True,
"auto recover enabled")
74 return TriggerResponse(
True,
"auto recover disabled")
81 self.em_stop_state_subscriber.unregister()
82 self.diagnostics_subscriber.unregister()
86 for component
in components:
87 handle = sss.recover(component)
88 if not (handle.get_error_code() == 0):
89 rospy.logerr(
"[auto_recover]: Could not recover %s", component)
91 rospy.loginfo(
"[auto_recover]: Component %s recovered successfully", component)
94 if __name__ ==
"__main__":
95 rospy.init_node(
"auto_recover")
97 rospy.loginfo(
"auto recover running")
def recover(self, components)
def disable_cb(self, req)
def diagnostics_cb(self, msg)