Пример #1
0
def calculate_metric_data(metric_name, mode, series):
    # return data, min, max, mean, std
    data = None
    min = None
    max = None
    mean = None
    std = None
    if mode == MetricResult.SNAP:
        data = series[-1]  # take last element from series for data and stamp
        min = data
        max = data
        mean = data.data
        std = 0.0
    elif mode == MetricResult.SPAN_MEAN:
        min = get_min(series)
        max = get_max(series)
        mean = get_mean(series)
        std = get_std(series)
        data = DataStamped()
        data.data = mean  # take mean for data
        data.stamp = series[
            -1].stamp  # take stamp from last element in series for stamp
    elif mode == MetricResult.SPAN_MIN:
        min = get_min(series)
        max = get_max(series)
        mean = get_mean(series)
        std = get_std(series)
        data = min
    elif mode == MetricResult.SPAN_ABSMIN:
        min = get_absmin(series)
        max = get_absmax(series)
        mean = get_mean(series)
        std = get_std(series)
        data = min
    elif mode == MetricResult.SPAN_MAX:
        min = get_min(series)
        max = get_max(series)
        mean = get_mean(series)
        std = get_std(series)
        data = max
    elif mode == MetricResult.SPAN_ABSMAX:
        min = get_absmin(series)
        max = get_absmax(series)
        mean = get_mean(series)
        std = get_std(series)
        data = max
    else:  # invalid mode
        raise ATFAnalyserError(
            "Analysing failed, invalid mode '%s' for metric '%s'." %
            (mode, metric_name))

    res = [data, min, max, mean, std]

    # verify that all field are set
    if None in res:
        ATFAnalyserError("Analysing failed, invalid data for metric '%s'." %
                         (metric_name))

    return res
Пример #2
0
 def update(self, topic, msg, t):
     # get data if testblock is active
     if self.status.status == TestblockStatus.ACTIVE:
         if topic == self.topic:
             ds = DataStamped()
             ds.stamp = t
             ds.data = self.get_data(msg)
             self.series.append(ds)
Пример #3
0
 def update(self, topic, msg, t):
     # get data if testblock is active
     if self.status.status == TestblockStatus.ACTIVE:
         if topic == "/atf/api" and msg.testblock_name == self.testblock_name:
             api_dict = self.msg_to_dict(msg)
             interface_data, self.interface_details = self.calculate_data_and_details(
                 api_dict)
             data = DataStamped()
             data.stamp = t
             data.data = interface_data
             self.series.append(data)  # FIXME handle fixed rates
    def update(self, topic, msg, t):
        # make sure we're handling a TFMessage (from /tf or /tf_static)
        # TODO check type instead of topic names
        if topic in self.topics:
            for transform in msg.transforms:
                self.t.setTransform(transform)

        # get data if testblock is active
        if self.status.status == TestblockStatus.ACTIVE:
            raw_data = self.get_data(t)
            if raw_data == None:
                return
            data = DataStamped()
            data.stamp = t
            data.data = round(raw_data, 6)
            self.series.append(data)  # FIXME handle fixed rates
    def __init__(self, name, topics, root_frame, measured_frame, groundtruth,
                 mode, series_mode):
        """
        Class for calculating the jerk by the given frame in relation to a given root frame.
        The tf data is sent over the tf topics given in the test_config.yaml.
        :param root_frame: name of the first frame
        :type  root_frame: string
        :param measured_frame: name of the second frame. The jerk will be measured in relation to the root_frame.
        :type  measured_frame: string
        """
        self.name = name
        self.started = False
        self.finished = False
        self.active = False
        self.groundtruth = groundtruth
        self.topics = topics
        self.root_frame = root_frame
        self.measured_frame = measured_frame
        self.mode = mode
        self.series_mode = series_mode
        self.series = []
        self.data = DataStamped()
        self.trans_old = []
        self.rot_old = []
        self.time_old = None
        self.velocity_old = None
        self.acceleration_old = None

        self.t = tf.Transformer(True, rospy.Duration(10.0))
    def __init__(self, topics, root_frame, measured_frame, groundtruth,
                 groundtruth_epsilon, series_mode):
        """
        Class for calculating the distance covered by the given frame in relation to a given root frame.
        The tf data is sent over the tf topics given in the test_config.yaml.
        :param root_frame: name of the first frame
        :type  root_frame: string
        :param measured_frame: name of the second frame. The distance will be measured in relation to the root_frame.
        :type  measured_frame: string
        """
        self.name = 'tf_length_rotation'
        self.started = False
        self.finished = False
        self.active = False
        self.groundtruth = groundtruth
        self.groundtruth_epsilon = groundtruth_epsilon
        self.topics = topics
        self.root_frame = root_frame
        self.measured_frame = measured_frame
        self.series_mode = series_mode
        self.series = []
        self.data = DataStamped()
        self.first_value = True
        self.trans_old = []
        self.rot_old = []

        self.t = tf.Transformer(True, rospy.Duration(10.0))
Пример #7
0
 def __init__(self, groundtruth, groundtruth_epsilon):
     """
     Class for calculating the time between the trigger 'ACTIVATE' and 'FINISH' on the topic assigned to the
     testblock.
     """
     self.name = 'time'
     self.started = False
     self.finished = False
     self.active = False
     self.groundtruth = groundtruth
     self.groundtruth_epsilon = groundtruth_epsilon
     self.series_mode = None  # Time metrics cannot have a series
     self.series = []
     self.data = DataStamped()
     self.start_time = None
Пример #8
0
 def __init__(self, name, groundtruth, mode, series_mode):
     """
     Class for calculating the time between the trigger 'ACTIVATE' and 'FINISH' on the topic assigned to the
     testblock.
     """
     self.name = name
     self.started = False
     self.finished = False
     self.active = False
     self.groundtruth = groundtruth
     self.mode = mode
     self.series_mode = series_mode
     self.series = []
     self.data = DataStamped()
     self.start_time = None
Пример #9
0
 def __init__(self, testblock_name, metric, series_mode):
     """
     Class for calculating the interface type.
     """
     self.name = 'interface'
     self.started = False
     self.finished = False
     self.active = False
     self.groundtruth = 100  # this is the max score
     self.groundtruth_epsilon = 0  # no deviation from max score allowed
     self.series_mode = series_mode
     self.series = []
     self.data = DataStamped()
     self.interface_details = {}
     self.api_dict = {}
     self.testblock_name = testblock_name
     self.metric = metric
Пример #10
0
 def __init__(self, name, min_observation_time, topic, groundtruth, mode, series_mode):
     self.name = name
     self.min_observation_time = min_observation_time
     self.started = False
     self.finished = False
     self.active = False
     self.groundtruth = groundtruth
     if topic.startswith("/"): # we need to use global topics because rostopic.get_topic_class(topic) can not handle non-global topics and recorder will always record global topics starting with "/"
         self.topic = topic
     else:
         self.topic = "/" + topic
     self.mode = mode
     self.series_mode = series_mode
     self.series = []
     self.data = DataStamped()
     self.counter = 0
     self.start_time = None
Пример #11
0
 def __init__(self, topic, groundtruth, groundtruth_epsilon, series_mode):
     self.name = 'publish_rate'
     self.started = False
     self.finished = False
     self.active = False
     self.groundtruth = groundtruth
     self.groundtruth_epsilon = groundtruth_epsilon
     if topic.startswith(
             "/"
     ):  # we need to use global topics because rostopic.get_topic_class(topic) can not handle non-global topics and recorder will always record global topics starting with "/"
         self.topic = topic
     else:
         self.topic = "/" + topic
     self.series_mode = series_mode
     self.series = []
     self.data = DataStamped()
     self.counter = 0
     self.start_time = None
Пример #12
0
 def __init__(self, name, testblock_name, params, mode, series_mode):
     """
     Class for calculating the interface type.
     """
     self.name = name
     self.started = False
     self.finished = False
     self.active = False
     self.groundtruth = Groundtruth()
     self.groundtruth.available = True
     self.groundtruth.data = 100  # this is the max score
     self.groundtruth.epsilon = 0  # no deviation from max score allowed
     self.mode = mode
     self.series_mode = series_mode
     self.series = []
     self.data = DataStamped()
     self.interface_details = {}
     self.api_dict = {}
     self.testblock_name = testblock_name
     self.params = params
Пример #13
0
 def calculate_publish_rate(self, stamp):
     data = DataStamped()
     data.stamp = stamp
     data.data = round(self.counter / (data.stamp - self.start_time).to_sec(),6)
     self.series.append(data)  # FIXME handle fixed rates
Пример #14
0
 def stop(self, status):
     self.status = status
     data = DataStamped()
     data.stamp = status.stamp
     data.data = round((data.stamp - self.start_time).to_sec(), 6)
     self.series.append(data)  # FIXME handle fixed rates