Пример #1
0
    def execute(self):

        # small testblock (circle r=1, time=3)
        self.atf.start("testblock_small")
        # FIXME: due to timing problem the first tf message is sometimes omitted
        #        so next line (pub_zero) is used as a workaround
        self.ptf.pub_zero()
        self.ptf.pub_circ(radius=1, period_time=10)

        # user result
        metric_result = MetricResult()
        metric_result.data.data = 0.8
        metric_result.groundtruth.result = Groundtruth.SUCCEEDED
        metric_result.groundtruth.error_message = "all ok in application of atf_test"
        self.atf.stop("testblock_small", metric_result)

        # large testblock (circle r=2, time=10)
        self.atf.start("testblock_large")
        self.ptf.pub_circ(radius=2, period_time=10)

        # user result
        metric_result = MetricResult()
        metric_result.data.data = 0.7
        self.atf.stop("testblock_large", metric_result)

        # shutdown atf
        self.atf.shutdown()
Пример #2
0
    def get_result(self):
        metric_result = MetricResult()
        metric_result.name = self.name
        metric_result.unit = self.unit
        metric_result.mode = self.mode
        metric_result.status = self.status.status
        metric_result.series = []
        metric_result.groundtruth.available = self.groundtruth.available
        metric_result.groundtruth.data = self.groundtruth.data
        metric_result.groundtruth.epsilon = self.groundtruth.epsilon

        if self.status.status != TestblockStatus.SUCCEEDED:
            metric_result.groundtruth.result = Groundtruth.FAILED
            metric_result.groundtruth.error_message = metrics_helper.extract_error_message(self.status)
            return metric_result

        # check if result is available
        if len(self.series) == 0:
            # let the analyzer know that this test failed
            metric_result.groundtruth.result = Groundtruth.FAILED
            metric_result.groundtruth.error_message = "testblock {} stopped without result. " \
                                                      "No transforms found between {} & {}".format(self.testblock_name,
                                                                                                   self.root_frame,
                                                                                                   self.measured_frame)
            return metric_result

        # at this point we're sure that any result is available

        # set series
        if self.series_mode != None:
            metric_result.series = self.series

        # calculate metric data
        [metric_result.data, metric_result.min, metric_result.max, metric_result.mean, metric_result.std] = metrics_helper.calculate_metric_data(metric_result.name, metric_result.mode, self.series)

        # fill details as KeyValue messages
        details = []
        details.append(KeyValue("root_frame", self.root_frame))
        details.append(KeyValue("measured_frame", self.measured_frame))
        metric_result.details = details

        # evaluate metric data
        if metric_result.groundtruth.available: # groundtruth available
            if math.fabs(metric_result.groundtruth.data - metric_result.data.data) <= metric_result.groundtruth.epsilon:
                metric_result.groundtruth.result = Groundtruth.SUCCEEDED
                metric_result.groundtruth.error_message = "all OK"
            else:
                metric_result.groundtruth.result = Groundtruth.FAILED
                metric_result.groundtruth.error_message = "groundtruth missmatch: %f not within %f+-%f"%(metric_result.data.data, metric_result.groundtruth.data, metric_result.groundtruth.epsilon)

        else: # groundtruth not available
            metric_result.groundtruth.result = Groundtruth.SUCCEEDED
            metric_result.groundtruth.error_message = "all OK (no groundtruth available)"

        return metric_result
Пример #3
0
    def execute(self):

        self.atf.start("testblock_8s")
        self.atf.start("testblock_3s")

        rospy.sleep(3)

        # user result
        metric_result = MetricResult()
        metric_result.data = 0.8
        metric_result.groundtruth_result = True
        metric_result.groundtruth_error_message = "all ok in application of atf_test"
        self.atf.stop("testblock_3s",
                      metric_result)  # user result with groundtruth result
        self.atf.start("testblock_5s")

        rospy.sleep(5)

        # user result
        metric_result = MetricResult()
        metric_result.data = 0.7
        self.atf.stop("testblock_5s",
                      metric_result)  # user result without groundtruth result
        self.atf.stop("testblock_8s")  # no user result

        # shutdown atf
        self.atf.shutdown()
Пример #4
0
    def execute(self):

        self.atf.start("testblock_3s")
        self.atf.start("testblock_1s")

        rospy.sleep(1)

        # user result
        metric_result = MetricResult()
        metric_result.data.data = 0.83
        metric_result.unit = "my_unit"
        metric_result.groundtruth.result = Groundtruth.SUCCEEDED
        metric_result.groundtruth.error_message = "all ok in application of atf_test"
        self.atf.stop("testblock_1s",
                      metric_result)  # user result with groundtruth result
        self.atf.start("testblock_2s")

        rospy.sleep(2)

        # user result
        metric_result = MetricResult()
        metric_result.data.data = 0.85
        metric_result.unit = "my_other_unit"
        self.atf.stop("testblock_2s",
                      metric_result)  # user result without groundtruth result

        metric_result = MetricResult()
        metric_result.groundtruth.result = Groundtruth.SUCCEEDED
        self.atf.stop("testblock_3s",
                      metric_result)  # empty but successfull user result

        # shutdown atf
        self.atf.shutdown()
Пример #5
0
    def stop(self, testblock, metric_result = None):
        if testblock not in list(self.test.testblockset_config.keys()):
            error_msg = "testblock \'%s\' not in list of testblocks"%testblock
            self._send_error(error_msg)
            raise ATFError(error_msg)

        if metric_result != None:

            #TODO  check if metric_result is of type atf_msgs/MetricResult

            metric_result = copy.deepcopy(metric_result) # deepcopy is needed to be able to overwrite metric_result.name
            metric_result.name = "user_result"
            
            rospy.loginfo("setting user result for testblock \'%s\'"%testblock)
            if not isinstance(metric_result, MetricResult):
                error_msg = "metric_result of testblock %s for " \
                            "metric %s is not a MetricResult. data=%s, type=%s" % (
                            testblock, metric_result.name, str(metric_result), type(metric_result))
                self._send_error(error_msg)
                raise ATFError(error_msg)
            if not isinstance(metric_result.data, DataStamped):
                error_msg = "metric_result.data of testblock %s for " \
                            "metric %s is not a DataStamped. data=%s, type=%s" % (
                            testblock, metric_result.name, str(metric_result.data), type(metric_result.data))
                self._send_error(error_msg)
                raise ATFError(error_msg)
            if not isinstance(metric_result.data.data, float) and not isinstance(metric_result.data.data, int):
                error_msg = "metric_result.data.data of testblock %s for " \
                            "metric %s is not a float or int. data=%s, type=%s" % (
                    testblock, metric_result.name, str(metric_result.data.data), type(metric_result.data.data))
                self._send_error(error_msg)
                raise ATFError(error_msg)
            if type(metric_result.details) is not list:
                error_msg = "metric_result.details of testblock %s for " \
                            "metric %s is not a list. detail=%s" % (
                    testblock, metric_result.name, str(metric_result.details))
                self._send_error(error_msg)
                raise ATFError(error_msg)

        else:
            rospy.loginfo("no user result set for testblock \'%s\'"%testblock)
            metric_result = MetricResult()

        rospy.loginfo("stopping testblock \'%s\'"%testblock)
        trigger = TestblockTrigger()
        trigger.stamp = rospy.Time.now()
        trigger.name = testblock
        trigger.trigger = TestblockTrigger.STOP
        trigger.user_result = metric_result
        self.publisher_trigger.publish(trigger)
Пример #6
0
    def get_result(self):
        metric_result = MetricResult()
        metric_result.name = self.name
        metric_result.status = self.status.status

        if self.status.status != TestblockStatus.SUCCEEDED:
            metric_result.groundtruth.result = Groundtruth.FAILED
            metric_result.groundtruth.error_message = metrics_helper.extract_error_message(
                self.status)
            return metric_result

        # check if result is available
        if self.metric_result.groundtruth.result == Groundtruth.UNSET and not self.groundtruth.available:
            # let the analyzer know that this test failed
            metric_result.groundtruth.result = Groundtruth.FAILED
            metric_result.groundtruth.error_message = "testblock %s stopped without user_result" % self.testblock_name
            return metric_result

        # at this point we're sure that any user_result is available

        # overwrite user_result data with mandatory ATF fields
        metric_result = self.metric_result
        metric_result.name = self.name
        metric_result.status = self.status.status

        # evaluate metric data
        if self.groundtruth.available:  # groundtruth available
            # overwrite grundtruth with data from yaml file
            metric_result.groundtruth = self.groundtruth
            if math.fabs(metric_result.groundtruth.data -
                         metric_result.data.data
                         ) <= metric_result.groundtruth.epsilon:
                metric_result.groundtruth.result = Groundtruth.SUCCEEDED
                metric_result.groundtruth.error_message = "all OK"
            else:
                metric_result.groundtruth.result = Groundtruth.FAILED
                metric_result.groundtruth.error_message = "groundtruth missmatch: %f not within %f+-%f" % (
                    metric_result.data.data, metric_result.groundtruth.data,
                    metric_result.groundtruth.epsilon)

        else:  # groundtruth not available
            # we'll keep what is set in self.metric_result: user_result set by user
            pass

        return metric_result
Пример #7
0
    def execute(self):

        # small testblock (circle r=0.5, time=3)
        self.atf.start("testblock_small")
        self.pub_tf_circle("link1", "link2", radius=1, time=3)

        # user result
        metric_result = MetricResult()
        metric_result.data = 0.8
        metric_result.groundtruth_result = True
        metric_result.groundtruth_error_message = "all ok in application of atf_test"
        self.atf.stop("testblock_small", metric_result)

        # large testblock (circle r=1, time=5)
        self.atf.start("testblock_large")
        self.pub_tf_circle("link1", "link2", radius=2, time=5)

        # user result
        metric_result = MetricResult()
        metric_result.data = 0.7
        self.atf.stop("testblock_large", metric_result)

        # shutdown atf
        self.atf.shutdown()
Пример #8
0
    def aggregate_results(self, atf_result):
        test_list = self.configuration_parser.get_test_list()

        ret = self.configuration_parser.get_sorted_plot_dicts(
            atf_result, "", "", "")

        mbt = ret['mbt']
        mbt_aggregated = {}
        for metric in list(mbt.keys()):
            #print "m=", metric
            if metric not in list(mbt_aggregated.keys()):
                mbt_aggregated[metric] = {}
            for testblock in list(mbt[metric].keys()):
                #print "  b=", testblock
                if testblock not in list(mbt_aggregated[metric].keys()):
                    mbt_aggregated[metric][testblock] = {}
                for tl_tests in test_list:
                    #print "tl_tests=", tl_tests
                    for tl_test in list(tl_tests.keys()):
                        #print "    tl_test=", tl_test
                        metric_result = MetricResult()
                        status = TestblockStatus.SUCCEEDED
                        groundtruth_result = Groundtruth.SUCCEEDED
                        groundtruth_error_message = ""
                        details = []
                        for test in list(mbt[metric][testblock].keys()):
                            if test.startswith(tl_test):
                                # aggregate status SUCCEEDED from every metric_result
                                if mbt[metric][testblock][
                                        test].status != TestblockStatus.SUCCEEDED:
                                    status = TestblockStatus.ERROR

                                # aggregate data from every metric_result
                                data = mbt[metric][testblock][test].data
                                stamp = data.stamp
                                # check if data is set (not all default values anymore)
                                if data.stamp == rospy.Time(
                                        0) and data.data == 0:
                                    stamp = rospy.Time(
                                        0
                                    )  # mark metric result as invalid by settimg timestamp to zero
                                metric_result.series.append(data)

                                # aggregate groundtruth from every metric_result
                                groundtruth = mbt[metric][testblock][
                                    test].groundtruth
                                if groundtruth.result != Groundtruth.SUCCEEDED:
                                    groundtruth_result = Groundtruth.FAILED
                                    if groundtruth_error_message != "":
                                        groundtruth_error_message += "\n"
                                    groundtruth_error_message += "groundtruth missmatch in subtest %s" % (
                                        test)

                                # aggregate details from every metric_result
                                details = details + mbt[metric][testblock][
                                    test].details

                        if len(metric_result.series
                               ) == 0:  # no matching substest found
                            continue

                        metric_result.groundtruth = groundtruth
                        metric_result.groundtruth.result = groundtruth_result
                        metric_result.groundtruth.error_message = groundtruth_error_message

                        metric_result.name = mbt[metric][testblock][test].name
                        metric_result.unit = mbt[metric][testblock][test].unit
                        metric_result.mode = MetricResult.SPAN_MEAN  # aggregated metrics are always SPAN_MEAN
                        metric_result.status = status
                        # metric_result.series is set above
                        metric_result.data.stamp = stamp
                        metric_result.data.data = metrics_helper.get_mean(
                            metric_result.series)
                        metric_result.min = metrics_helper.get_min(
                            metric_result.series)
                        metric_result.max = metrics_helper.get_max(
                            metric_result.series)
                        metric_result.mean = metric_result.data.data
                        metric_result.std = metrics_helper.get_std(
                            metric_result.series)
                        # metric_result.groundtruth is set above
                        metric_result.details = details
                        mbt_aggregated[metric][testblock][
                            tl_test] = metric_result

        # convert mbt to tbm
        tbm = {}
        for metric in list(mbt_aggregated.keys()):
            #print "m=", metric
            for testblock in list(mbt_aggregated[metric].keys()):
                #print "  b=", testblock
                for test in list(mbt_aggregated[metric][testblock].keys()):
                    #print "    t=", test
                    if test not in list(tbm.keys()):
                        tbm[test] = {}
                    if testblock not in list(tbm[test].keys()):
                        tbm[test][testblock] = {}
                    tbm[test][testblock][metric] = mbt_aggregated[metric][
                        testblock][test]

        # convert tbm to atf_result_aggregated
        atf_result_aggregated = AtfResult()
        atf_result_aggregated.header = atf_result.header
        atf_result_aggregated.name = atf_result.name
        atf_result_aggregated.result = True
        for test in sorted(tbm.keys()):
            test_result = TestResult()
            test_result.name = test
            test_result.result = True

            # find test metadata in atf_result
            for t in atf_result.results:
                if t.name.startswith(test):
                    test_result.test_config = t.test_config
                    test_result.robot = t.robot
                    test_result.env = t.env
                    test_result.testblockset = t.testblockset
                    break

            for testblock in sorted(tbm[test].keys()):
                testblock_result = TestblockResult()
                testblock_result.name = testblock
                testblock_result.result = True
                for metric in sorted(tbm[test][testblock].keys()):
                    metric_result = tbm[test][testblock][metric]
                    testblock_result.results.append(metric_result)
                    # aggregate metric result
                    if metric_result.groundtruth.result != Groundtruth.SUCCEEDED:
                        testblock_result.result = False
                        testblock_result.error_message += "\n     - metric '%s': %s" % (
                            metric_result.name,
                            metric_result.groundtruth.error_message)

                test_result.results.append(testblock_result)
                # aggregate testblock result
                if testblock_result.result == False:
                    test_result.result = False
                    test_result.error_message += "\n   - testblock '%s': %s" % (
                        testblock_result.name, testblock_result.error_message)

            atf_result_aggregated.results.append(test_result)
            # aggregate test result
            if test_result.result == False:
                atf_result_aggregated.result = False
                atf_result_aggregated.error_message += "\n - test '%s' (%s, %s, %s, %s): %s" % (
                    test_result.name, test_result.test_config,
                    test_result.robot, test_result.env,
                    test_result.testblockset, test_result.error_message)

        return atf_result_aggregated
    def get_result(self):
        metric_result = MetricResult()
        metric_result.name = self.name
        metric_result.mode = self.mode
        metric_result.started = self.started  # FIXME remove
        metric_result.finished = self.finished  # FIXME remove
        metric_result.series = []
        metric_result.groundtruth.available = self.groundtruth.available
        metric_result.groundtruth.data = self.groundtruth.data
        metric_result.groundtruth.epsilon = self.groundtruth.epsilon

        # assign default value
        metric_result.groundtruth.result = None
        metric_result.groundtruth.error_message = None

        if metric_result.started and metric_result.finished and len(
                self.series
        ) != 0:  #  we check if the testblock was ever started and stopped and if result data is available
            # calculate metric data
            if self.series_mode != None:
                metric_result.series = self.series
            if metric_result.mode == MetricResult.SNAP:
                metric_result.data = self.series[
                    -1]  # take last element from self.series for data and stamp
                metric_result.min = metric_result.data
                metric_result.max = metric_result.data
                metric_result.mean = metric_result.data.data
                metric_result.std = 0.0
            elif metric_result.mode == MetricResult.SPAN_MEAN:
                metric_result.min = metrics_helper.get_min(self.series)
                metric_result.max = metrics_helper.get_max(self.series)
                metric_result.mean = metrics_helper.get_mean(self.series)
                metric_result.std = metrics_helper.get_std(self.series)
                metric_result.data.data = metric_result.mean  # take mean for data
                metric_result.data.stamp = self.series[
                    -1].stamp  # take stamp from last element in self.series for stamp
            elif metric_result.mode == MetricResult.SPAN_MIN:
                metric_result.min = metrics_helper.get_min(self.series)
                metric_result.max = metrics_helper.get_max(self.series)
                metric_result.mean = metrics_helper.get_mean(self.series)
                metric_result.std = metrics_helper.get_std(self.series)
                metric_result.data = metric_result.min
            elif metric_result.mode == MetricResult.SPAN_ABSMIN:
                metric_result.min = metrics_helper.get_absmin(self.series)
                metric_result.max = metrics_helper.get_absmax(self.series)
                metric_result.mean = metrics_helper.get_mean(self.series)
                metric_result.std = metrics_helper.get_std(self.series)
                metric_result.data = metric_result.min
            elif metric_result.mode == MetricResult.SPAN_MAX:
                metric_result.min = metrics_helper.get_min(self.series)
                metric_result.max = metrics_helper.get_max(self.series)
                metric_result.mean = metrics_helper.get_mean(self.series)
                metric_result.std = metrics_helper.get_std(self.series)
                metric_result.data = metric_result.max
            elif metric_result.mode == MetricResult.SPAN_ABSMAX:
                metric_result.min = metrics_helper.get_absmin(self.series)
                metric_result.max = metrics_helper.get_absmax(self.series)
                metric_result.mean = metrics_helper.get_mean(self.series)
                metric_result.std = metrics_helper.get_std(self.series)
                metric_result.data = metric_result.max
            else:  # invalid mode
                raise ATFAnalyserError(
                    "Analysing failed, invalid mode '%s' for metric '%s'." %
                    (metric_result.mode, metric_result.name))

            # fill details as KeyValue messages
            details = []
            details.append(KeyValue("root_frame", self.root_frame))
            details.append(KeyValue("measured_frame", self.measured_frame))
            metric_result.details = details

            # evaluate metric data
            if not metric_result.groundtruth.available:  # no groundtruth given
                metric_result.groundtruth.result = True
                metric_result.groundtruth.error_message = "all OK (no groundtruth available)"
            else:  # groundtruth available
                if math.fabs(metric_result.groundtruth.data -
                             metric_result.data.data
                             ) <= metric_result.groundtruth.epsilon:
                    metric_result.groundtruth.result = True
                    metric_result.groundtruth.error_message = "all OK"
                else:
                    metric_result.groundtruth.result = False
                    metric_result.groundtruth.error_message = "groundtruth missmatch: %f not within %f+-%f" % (
                        metric_result.data.data,
                        metric_result.groundtruth.data,
                        metric_result.groundtruth.epsilon)

        else:  # testblock did not start and/or finish
            metric_result.groundtruth.result = False
            metric_result.groundtruth.error_message = "no result"

        if metric_result.groundtruth.result == None:
            raise ATFAnalyserError(
                "Analysing failed, metric result is None for metric '%s'." %
                metric_result.name)

        return metric_result
Пример #10
0
    def get_result(self):
        interface_data, interface_details = self.calculate_data_and_details()
        groundtruth_result = None  # interface metric not usable without groundtruth
        groundtruth = 100  # this is the max score
        groundtruth_epsilon = 0  # no deviation from max score allowed

        metric_result = MetricResult()
        metric_result.name = "interface"
        metric_result.started = self.started  # FIXME remove
        metric_result.finished = self.finished  # FIXME remove
        metric_result.data = None
        metric_result.groundtruth = self.groundtruth
        metric_result.groundtruth_epsilon = self.groundtruth_epsilon

        # assign default value
        metric_result.groundtruth_result = None
        metric_result.groundtruth_error_message = None

        if metric_result.started and metric_result.finished:  #  we check if the testblock was ever started and stopped
            # calculate metric data
            metric_result.data = interface_data

            # fill details as KeyValue messages
            details = []
            details.append(KeyValue("api_status", interface_details))
            metric_result.details = details

            # evaluate metric data
            if metric_result.data != None and metric_result.groundtruth != None and metric_result.groundtruth_epsilon != None:
                if math.fabs(metric_result.groundtruth - metric_result.data
                             ) <= metric_result.groundtruth_epsilon:
                    metric_result.groundtruth_result = True
                    metric_result.groundtruth_error_message = "all OK"
                else:
                    metric_result.groundtruth_result = False
                    metric_result.groundtruth_error_message = "groundtruth missmatch: %f not within %f+-%f" % (
                        metric_result.data, metric_result.groundtruth,
                        metric_result.groundtruth_epsilon)
                    #print metric_result.groundtruth_error_message

        if metric_result.data == None:
            metric_result.groundtruth_result = False
            metric_result.groundtruth_error_message = "no result"

        #print "\nmetric_result:\n", metric_result
        return metric_result
Пример #11
0
    def get_result(self):
        metric_result = MetricResult()
        metric_result.name = self.name
        metric_result.started = self.started  # FIXME remove
        metric_result.finished = self.finished  # FIXME remove

        # check if user result is set
        if self.metric_result != None and not (self.metric_result.groundtruth_result == False\
            and self.metric_result.groundtruth_error_message == ""\
            and self.metric_result.groundtruth == 0.0\
            and self.metric_result.groundtruth_epsilon == 0.0):
            #print "groundtruth data is set from user within atf application for testblock %s. Skipping groundtruth evaluation from test_config"%self.testblock_name
            # use data from user result
            metric_result = self.metric_result
            return metric_result

        metric_result.data = None
        metric_result.groundtruth = self.groundtruth
        metric_result.groundtruth_epsilon = self.groundtruth_epsilon

        # assign default value
        metric_result.groundtruth_result = None
        metric_result.groundtruth_error_message = None

        if metric_result.started and metric_result.finished:  #  we check if the testblock was ever started and stopped
            # calculate metric data
            if self.metric_result == None:
                print "ERROR user result for testblock %s not set" % self.testblock_name
                metric_result.data = None
            else:
                metric_result.data = self.metric_result.data

            # fill details as KeyValue messages
            metric_result.details = self.metric_result.details

            # evaluate metric data
            if metric_result.data != None and metric_result.groundtruth != None and metric_result.groundtruth_epsilon != None:
                if math.fabs(metric_result.groundtruth -
                             metric_result.data.data
                             ) <= metric_result.groundtruth_epsilon:
                    metric_result.groundtruth_result = True
                    metric_result.groundtruth_error_message = "all OK"
                else:
                    metric_result.groundtruth_result = False
                    metric_result.groundtruth_error_message = "groundtruth missmatch: %f not within %f+-%f" % (
                        metric_result.data.data, metric_result.groundtruth,
                        metric_result.groundtruth_epsilon)

        if metric_result.data == None:
            metric_result.groundtruth_result = False
            metric_result.groundtruth_error_message = "no result"

        return metric_result
Пример #12
0
    def get_result(self):
        metric_result = MetricResult()
        metric_result.name = "path_length"
        metric_result.started = self.started # FIXME remove
        metric_result.finished = self.finished # FIXME remove
        metric_result.data = None
        metric_result.groundtruth = self.groundtruth
        metric_result.groundtruth_epsilon = self.groundtruth_epsilon
        
        # assign default value
        metric_result.groundtruth_result = None
        metric_result.groundtruth_error_message = None

        if metric_result.started and metric_result.finished: #  we check if the testblock was ever started and stopped
            # calculate metric data
            metric_result.data = round(self.path_length, 3)

            # fill details as KeyValue messages
            details = []
            details.append(KeyValue("root_frame", self.root_frame))
            details.append(KeyValue("measured_frame", self.measured_frame))
            metric_result.details = details

            # evaluate metric data
            if metric_result.data != None and metric_result.groundtruth != None and metric_result.groundtruth_epsilon != None:
                if math.fabs(metric_result.groundtruth - metric_result.data) <= metric_result.groundtruth_epsilon:
                    metric_result.groundtruth_result = True
                    metric_result.groundtruth_error_message = "all OK"
                else:
                    metric_result.groundtruth_result = False
                    metric_result.groundtruth_error_message = "groundtruth missmatch: %f not within %f+-%f"%(metric_result.data, metric_result.groundtruth, metric_result.groundtruth_epsilon)
                    #print metric_result.groundtruth_error_message

        if metric_result.data == None:
            metric_result.groundtruth_result = False
            metric_result.groundtruth_error_message = "no result"

        #print "\nmetric_result:\n", metric_result
        return metric_result
    def get_result(self):
        metric_result = MetricResult()
        metric_result.name = self.name
        metric_result.started = self.started  # FIXME remove
        metric_result.finished = self.finished  # FIXME remove
        metric_result.series = []
        metric_result.data = None
        metric_result.groundtruth = self.groundtruth
        metric_result.groundtruth_epsilon = self.groundtruth_epsilon

        # assign default value
        metric_result.groundtruth_result = None
        metric_result.groundtruth_error_message = None

        if metric_result.started and metric_result.finished:  #  we check if the testblock was ever started and stopped
            # calculate metric data
            if self.series_mode != None:
                metric_result.series = self.series
            metric_result.data = self.series[
                -1]  # take last element from self.series
            metric_result.min = metrics_helper.get_min(self.series)
            metric_result.max = metrics_helper.get_max(self.series)
            metric_result.mean = metrics_helper.get_mean(self.series)
            metric_result.std = metrics_helper.get_std(self.series)

            # fill details as KeyValue messages
            details = []
            details.append(KeyValue("root_frame", self.root_frame))
            details.append(KeyValue("measured_frame", self.measured_frame))
            metric_result.details = details

            # evaluate metric data
            if metric_result.data != None and metric_result.groundtruth != None and metric_result.groundtruth_epsilon != None:
                if math.fabs(metric_result.groundtruth -
                             metric_result.data.data
                             ) <= metric_result.groundtruth_epsilon:
                    metric_result.groundtruth_result = True
                    metric_result.groundtruth_error_message = "all OK"
                else:
                    metric_result.groundtruth_result = False
                    metric_result.groundtruth_error_message = "groundtruth missmatch: %f not within %f+-%f" % (
                        metric_result.data.data, metric_result.groundtruth,
                        metric_result.groundtruth_epsilon)

        if metric_result.data == None:
            metric_result.groundtruth_result = False
            metric_result.groundtruth_error_message = "no result"

        return metric_result
Пример #14
0
    def get_result(self):
        metric_result = MetricResult()
        metric_result.name = self.name
        metric_result.started = self.started  # FIXME remove
        metric_result.finished = self.finished  # FIXME remove

        # check if user result is set at all
        if self.metric_result == None:
            #print "no user result set"
            metric_result.groundtruth.result = False
            metric_result.groundtruth.error_message = "no result"
            #print "EXIT 0", metric_result.data.data, metric_result.groundtruth.result, metric_result.groundtruth.error_message
            return metric_result

        # check if groundtruth is set via user result (not all default values anymore)
        if self.metric_result.groundtruth.result\
            or self.metric_result.groundtruth.available\
            or self.metric_result.groundtruth.error_message != ""\
            or self.metric_result.groundtruth.data != 0\
            or self.metric_result.groundtruth.epsilon != 0:

            #print "groundtruth data is set from user within atf application for testblock %s. Skipping groundtruth evaluation from test_config"%self.testblock_name

            # use data from user result
            metric_result = self.metric_result

            # overwrite user_result data with mandatory ATF filds
            metric_result.name = self.name
            metric_result.started = True
            metric_result.finished = True
            metric_result.groundtruth.available = True
            #print "EXIT 1", metric_result.data.data, metric_result.groundtruth.result, metric_result.groundtruth.error_message
            return metric_result

        #print "no groundtruth set via user_result", self.metric_result.groundtruth

        metric_result.groundtruth.available = self.groundtruth.available
        metric_result.groundtruth.data = self.groundtruth.data
        metric_result.groundtruth.epsilon = self.groundtruth.epsilon

        # assign default value
        metric_result.groundtruth.result = None
        metric_result.groundtruth.error_message = None

        if metric_result.started and metric_result.finished:  #  we check if the testblock was ever started and stopped
            # calculate metric data
            # check if user has set any metric_result (not all default values anymore)
            if not self.metric_result.started\
                and not self.metric_result.finished\
                and len(self.metric_result.series) == 0\
                and self.metric_result.data.stamp == rospy.Time(0)\
                and self.metric_result.data.data == 0:

                # let the analyzer know that this test failed
                metric_result.groundtruth.result = False
                metric_result.groundtruth.error_message = "user result for testblock %s not set" % self.testblock_name
                #print "EXIT 2", metric_result.data.data, metric_result.groundtruth.result, metric_result.groundtruth.error_message
                return metric_result

            metric_result.data = self.metric_result.data

            # fill details as KeyValue messages
            metric_result.details = self.metric_result.details

            # evaluate metric data
            if not metric_result.groundtruth.available:  # no groundtruth given
                metric_result.groundtruth.result = True
                metric_result.groundtruth.error_message = "all OK (no groundtruth available)"
            else:  # groundtruth available
                if math.fabs(metric_result.groundtruth.data -
                             metric_result.data.data
                             ) <= metric_result.groundtruth.epsilon:
                    metric_result.groundtruth.result = True
                    metric_result.groundtruth.error_message = "all OK"
                else:
                    metric_result.groundtruth.result = False
                    metric_result.groundtruth.error_message = "groundtruth missmatch: %f not within %f+-%f" % (
                        metric_result.data.data,
                        metric_result.groundtruth.data,
                        metric_result.groundtruth.epsilon)

        else:  # testblock did not start and/or finish
            metric_result.groundtruth.result = False
            metric_result.groundtruth.error_message = "no result"

        if metric_result.groundtruth.result == None:
            raise ATFAnalyserError(
                "Analysing failed, metric result is None for metric '%s'." %
                metric_result.name)

        #print "EXIT 3", metric_result.data.data, metric_result.groundtruth.result, metric_result.groundtruth.error_message
        return metric_result