Beispiel #1
0
    def set_alarm(self, srv):
        ''' Sets or updates the alarm
        Updating the alarm triggers all of the alarms callbacks
        '''
        alarm = srv.alarm

        # If the alarm name is `all`, clear all alarms
        if alarm.alarm_name == "all":
            rospy.loginfo("Clearing all alarms.")
            for alarm in self.alarms.values():
                # Don't want to clear meta alarms until the end
                if alarm in self.meta_alarms:
                    continue
                cleared_alarm = alarm.as_msg()
                cleared_alarm.raised = False
                self._alarm_pub.publish(alarm.as_msg())
                alarm.update(cleared_alarm)

            for _alarm in self.meta_alarms.keys():
                alarm = self.alarms[_alarm]
                cleared_alarm = alarm.as_msg()
                cleared_alarm.raised = False
                self._alarm_pub.publish(alarm.as_msg())
                alarm.update(cleared_alarm)

            return True

        if alarm.alarm_name in self.alarms:
            self.alarms[alarm.alarm_name].update(alarm)
        else:
            self.alarms[alarm.alarm_name] = Alarm.from_msg(alarm)

        self._alarm_pub.publish(alarm)
        return True
Beispiel #2
0
 def make_tagged_alarm(self, name):
     '''
     Makes a blank alarm with the node_name of the alarm_server so that users know it is the
     initial state
     '''
     alarm = Alarm.blank(name)
     alarm.node_name = 'alarm_server'
     return alarm
Beispiel #3
0
 def __init__(self):
     self._killed = False
     self.initial_alarm = Alarm(self.alarm_name, True,
                                node_name='alarm_server',
                                problem_description='Initial kill')
     self.bag_client = SimpleActionClient("/online_bagger/bag", BagOnlineAction)
     self.task_client = MissionClient()
     self.first = True
    def __init__(self):
        # Alarm server wil set this as the intial state of kill alarm
        self.initial_alarm = Alarm(self.alarm_name,
                                   False,
                                   node_name='alarm_server',
                                   parameters={'offline_thruster_names': []})

        self.update_layout = rospy.ServiceProxy('update_thruster_layout',
                                                UpdateThrusterLayout)
Beispiel #5
0
    def __init__(self):
        # Alarm server wil set this as the intial state of kill alarm (starts killed)
        self.initial_alarm = Alarm(self.alarm_name,
                                   True,
                                   node_name='alarm_server',
                                   problem_description='Initial kill')

        self._killed = False
        self._last_mission_killed = False
        self.bag_client = SimpleActionClient('/online_bagger/bag',
                                             BagOnlineAction)
        self.first = True
Beispiel #6
0
    def meta_predicate(self, meta_alarm, alarms):
        ignore = []

        # Don't kill on low battery, only on critical
        # if alarms['battery-voltage'].raised and alarms['battery-voltage'].severity < 2:
        #     ignore.append('battery-voltage')

        # Raised if any alarms besides the two above are raised
        raised = [name for name, alarm in alarms.items() if name not in ignore and alarm.raised]
        if len(raised):
            return Alarm('kill', True, node_name=rospy.get_name(),
                         problem_description='Killed by meta alarm(s) ' + ', '.join(raised),
                         parameters={'Raised': raised})
        return self._killed
Beispiel #7
0
    def set_alarm(self, alarm):
        ''' Sets or updates the alarm
        Updating the alarm triggers all of the alarms callbacks
        '''
        if alarm.alarm_name in self.handlers:
            res = self.handlers[alarm.alarm_name].on_set(alarm)
            if res is False:
                return False

        if alarm.alarm_name in self.alarms:
            self.alarms[alarm.alarm_name].update(alarm)
        else:
            self.alarms[alarm.alarm_name] = Alarm.from_msg(alarm)

        self._alarm_pub.publish(alarm)
        return True
Beispiel #8
0
 def _on_get_alarm(self, srv):
     ''' Either returns the alarm request if it exists or a blank alarm '''
     rospy.logdebug("Got request for alarm: {}".format(srv.alarm_name))
     return self.alarms.get(srv.alarm_name,
                            Alarm.blank(srv.alarm_name)).as_srv_resp()
 def __init__(self):
     self.initial_alarm = Alarm(self.alarm_name,
                                False,
                                node_name='alarm_server')