def _parse_interval_and_timeout(ConstraintHandler, const_dict): """Parse min_reaction_interval and reaction_timeout out of the dictionary. Both are attributes of a constraint. If the interval and timeout is not specified in the dict default values are assigned. :param const_dict: The dict from the parameter server holding the interval and timeout. :type: dict :return: the min_reaction_interval and reaction_timeout :rtype: tuple (rospy.Duration, rospy.Duration) """ # default values min_reaction_interval = helper.get_param_duration( helper.ARNI_CTM_CFG_NS + "default/min_reaction_interval") reaction_timeout = helper.get_param_duration( helper.ARNI_CTM_CFG_NS + "default/reaction_timeout") # check if interval and timeout have interger values try: if 'min_reaction_interval' in const_dict: min_reaction_interval = rospy.Duration( const_dict['min_reaction_interval']) except ValueError: rospy.logwarn( "min_reaction_interval '%s'" % (const_dict['min_reaction_interval']) + " is of invalid value. (Only numbers allowed.)") try: if 'reaction_timeout' in const_dict: reaction_timeout = rospy.Duration( const_dict['reaction_timeout']) except ValueError: rospy.logwarn( "reaction_timeout '%s'" % (const_dict['reaction_timeout']) + " is of invalid value. (Only numbers allowed.)") return (min_reaction_interval, reaction_timeout)
def _parse_interval_and_timeout(ConstraintHandler, const_dict): """Parse min_reaction_interval and reaction_timeout out of the dictionary. Both are attributes of a constraint. If the interval and timeout is not specified in the dict default values are assigned. :param const_dict: The dict from the parameter server holding the interval and timeout. :type: dict :return: the min_reaction_interval and reaction_timeout :rtype: tuple (rospy.Duration, rospy.Duration) """ # default values min_reaction_interval = helper.get_param_duration( helper.ARNI_CTM_CFG_NS + "default/min_reaction_interval") reaction_timeout = helper.get_param_duration( helper.ARNI_CTM_CFG_NS + "default/reaction_timeout") # check if interval and timeout have interger values try: if 'min_reaction_interval' in const_dict: min_reaction_interval = rospy.Duration( const_dict['min_reaction_interval']) except ValueError: rospy.logwarn("min_reaction_interval '%s'" % (const_dict['min_reaction_interval']) + " is of invalid value. (Only numbers allowed.)") try: if 'reaction_timeout' in const_dict: reaction_timeout = rospy.Duration( const_dict['reaction_timeout']) except ValueError: rospy.logwarn("reaction_timeout '%s'" % (const_dict['reaction_timeout']) + " is of invalid value. (Only numbers allowed.)") return (min_reaction_interval, reaction_timeout)
def __init__(self): super(RatedStatisticStorage, self).__init__() #: A dictionary containing all rated statis tic #: information with their outcome and an timestamp #: when they got added / updated to the dictionary. self.__statistic_storage = dict() #: The timeout after which an item in ratedstatistic #: is declared too old and should be removed #: from the dict. #: type: Duration self.__timeout = helper.get_param_duration(helper.ARNI_CTM_CFG_NS + "storage_timeout")
def __init__(self): super(RatedStatisticStorage, self).__init__() #: A dictionary containing all rated statis tic #: information with their outcome and an timestamp #: when they got added / updated to the dictionary. self.__statistic_storage = dict() #: The timeout after which an item in ratedstatistic #: is declared too old and should be removed #: from the dict. #: type: Duration self.__timeout = helper.get_param_duration( helper.ARNI_CTM_CFG_NS + "storage_timeout")
def __init__(self): """Periodically (threading) evaluate the constraints and clean old statistics.""" super(CountermeasureNode, self).__init__() rospy.init_node("countermeasure", log_level=rospy.DEBUG) self.__enabled = False self.__init_params() #: The storage of all incoming rated statistic. self.__rated_statistic_storage = RatedStatisticStorage() #: The handler for all constraints. self.__constraint_handler = ConstraintHandler(self.__rated_statistic_storage) #: The time to wait between two evaluations. self.__evaluation_period = helper.get_param_duration(helper.ARNI_CTM_CFG_NS + "evaluation_period") self.__register_subscriber() self.__register_services()
def __init__(self): """Periodically (threading) evaluate the constraints and clean old statistics.""" super(CountermeasureNode, self).__init__() rospy.init_node("countermeasure", log_level=rospy.DEBUG) self.__enabled = False self.__init_params() #: The storage of all incoming rated statistic. self.__rated_statistic_storage = RatedStatisticStorage() #: The handler for all constraints. self.__constraint_handler = ConstraintHandler( self.__rated_statistic_storage) #: The time to wait between two evaluations. self.__evaluation_period = helper.get_param_duration( helper.ARNI_CTM_CFG_NS + "evaluation_period") self.__register_subscriber() self.__register_services()