Пример #1
0
    def parse_parameter(self, testblock_name, metric_name, params):
        """
        Method that returns the metric method with the given parameter.
        :param params: Parameter
        """
        metric_type = "user_result"

        split_name = metric_name.split("::")
        if len(split_name) != 2:
            raise ATFConfigurationError(
                "no valid metric name for metric '%s' in testblock '%s'" %
                (metric_name, testblock_name))
        if split_name[0] != metric_type:
            raise ATFConfigurationError(
                "called invalid metric handle for metric '%s' in testblock '%s'."
                % (metric_name, testblock_name))

        if type(params) is not dict:
            rospy.logerr("metric config not a dictionary")
            raise ATFConfigurationError(
                "no valid metric configuration for metric '%s' in testblock '%s': %s"
                % (metric_name, testblock_name, str(params)))

        # check for optional parameters
        groundtruth = Groundtruth()
        try:
            groundtruth.data = params["groundtruth"]
            groundtruth.epsilon = params["groundtruth_epsilon"]
            groundtruth.available = True
        except (TypeError, KeyError):
            groundtruth.data = 0
            groundtruth.epsilon = 0
            groundtruth.available = False

        return CalculateUserResult(metric_name, testblock_name, groundtruth)
Пример #2
0
    def parse_parameter(self, testblock_name, metric_name, params):
        """
        Method that returns the metric method with the given parameter.
        :param params: Parameter
        """
        metric_type = "topic_data"

        split_name = metric_name.split("::")
        if len(split_name) != 2:
            raise ATFConfigurationError(
                "no valid metric name for metric '%s' in testblock '%s'" %
                (metric_name, testblock_name))
        if split_name[0] != metric_type:
            raise ATFConfigurationError(
                "called invalid metric handle for metric '%s' in testblock '%s'."
                % (metric_name, testblock_name))

        if type(params) is not dict:
            rospy.logerr("metric config not a dictionary")
            raise ATFConfigurationError(
                "no valid metric configuration for metric '%s' in testblock '%s': %s"
                % (metric_name, testblock_name, str(params)))

        try:
            message_field = params["message_field"]
        except (TypeError, KeyError):
            message_field = ""

        # check for optional parameters
        try:
            unit = params["unit"]
        except (TypeError, KeyError):
            unit = ""
        groundtruth = Groundtruth()
        try:
            groundtruth.data = params["groundtruth"]["data"]
            groundtruth.epsilon = params["groundtruth"]["epsilon"]
            groundtruth.available = True
        except (TypeError, KeyError):
            groundtruth.data = 0
            groundtruth.epsilon = 0
            groundtruth.available = False
        try:
            mode = params["mode"]
        except (TypeError, KeyError):
            mode = MetricResult.SPAN_MEAN
        try:
            series_mode = params["series_mode"]
        except (TypeError, KeyError):
            series_mode = None

        return CalculateTopicData(metric_name, testblock_name, params["topic"],
                                  message_field, groundtruth, mode,
                                  series_mode, unit)
Пример #3
0
    def parse_parameter(self, testblock_name, metric_name, params):
        """
        Method that returns the metric method with the given parameter.
        :param params: Parameter
        """
        metric_type = "tf_acceleration_translation"
        unit = "m/s^2"

        split_name = metric_name.split("::")
        if len(split_name) != 2:
            raise ATFConfigurationError(
                "no valid metric name for metric '%s' in testblock '%s'" %
                (metric_name, testblock_name))
        if split_name[0] != metric_type:
            raise ATFConfigurationError(
                "called invalid metric handle for metric '%s' in testblock '%s'."
                % (metric_name, testblock_name))

        if type(params) is not dict:
            rospy.logerr("metric config not a dictionary")
            raise ATFConfigurationError(
                "no valid metric configuration for metric '%s' in testblock '%s': %s"
                % (metric_name, testblock_name, str(params)))

        # check for optional parameters
        groundtruth = Groundtruth()
        try:
            groundtruth.data = params["groundtruth"]["data"]
            groundtruth.epsilon = params["groundtruth"]["epsilon"]
            groundtruth.available = True
        except (TypeError, KeyError):
            groundtruth.data = 0
            groundtruth.epsilon = 0
            groundtruth.available = False
        try:
            mode = params["mode"]
        except (TypeError, KeyError):
            mode = MetricResult.SPAN_ABSMAX
        try:
            series_mode = params["series_mode"]
        except (TypeError, KeyError):
            series_mode = None

        return CalculateTfAccelerationTranslation(metric_name, testblock_name,
                                                  params["topics"],
                                                  params["root_frame"],
                                                  params["measured_frame"],
                                                  groundtruth, mode,
                                                  series_mode, unit)
Пример #4
0
    def __init__(self, name, testblock_name, params, mode, series_mode, unit):
        """
        Class for calculating the interface type.
        """
        self.name = name
        self.testblock_name = testblock_name
        self.status = TestblockStatus()
        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.unit = unit

        self.interface_details = {}
        self.params = params
Пример #5
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
Пример #6
0
 def calculate_data_and_details(self):
     # As interface metric is not numeric, we'll use the following numeric representation:
     # max score = 100.0
     # node in api: score = 33.3
     # all interfaces available: score = 66.6
     # all types correct: score = 100.0
     data = None
     groundtruth = Groundtruth()
     details = None
     node_name = self.params['node']
     if node_name not in self.api_dict:
         details = "node " + node_name + " is not in api"
         groundtruth.result = False
         data = 0.0
     else:
         details = "node " + node_name + " is in api"
         groundtruth.result = True
         data = 100.0
         for interface, interface_data in self.params.items():
             if interface == "publishers" or interface == "subscribers" or interface == "services":
                 for topic_name, topic_type in interface_data:
                     #print "node_name=", node_name
                     #print "topic_name=", topic_name
                     #print "topic_type=", topic_type
                     #print "self.api_dict[node_name][interface]=", self.api_dict[node_name][interface]
                     name_check, type_check = self.check_interface(
                         topic_name, topic_type,
                         self.api_dict[node_name][interface])
                     if not name_check:
                         details += ", but " + topic_name + " is not an interface of node " + node_name + ". Interfaces are: " + str(
                             self.api_dict[node_name][interface])
                         groundtruth.result = False
                         data = 33.3
                     else:
                         if not type_check:
                             details += ", but " + topic_name + " (with type " + topic_type + ") is not an interface of node " + node_name + ". Interfaces are: " + str(
                                 self.api_dict[node_name][interface])
                             groundtruth.result = False
                             data = 66.0
                         else:  # all Ok
                             details += ", all interfaces of node " + node_name + ": OK"
                             groundtruth.result = True
                             data = 100.0
     return data, details
Пример #7
0
    def calculate_data_and_details(self, api_dict):
        # As interface metric is not numeric, we'll use the following numeric representation:
        # max score = 100.0
        # node in api: score = 33.3
        # all interfaces available: score = 66.6
        # all types correct: score = 100.0
        data = None
        groundtruth = Groundtruth()
        details = None
        node_name = self.params['node']

        if node_name not in api_dict:
            details = "node " + node_name + " is not in api"
            groundtruth.result = Groundtruth.FAILED
            data = 0.0
            return data, details

        details = "node " + node_name + " is in api"
        groundtruth.result = Groundtruth.SUCCEEDED
        data = 100.0
        for interface, interface_data in list(self.params.items()):
            if interface == "publishers" or interface == "subscribers" or interface == "services":
                for topic_name, topic_type in interface_data:
                    #print "node_name=", node_name
                    #print "topic_name=", topic_name
                    #print "topic_type=", topic_type
                    #print "api_dict[node_name][interface]=", api_dict[node_name][interface]
                    name_check, type_check = self.check_interface(
                        topic_name, topic_type, api_dict[node_name][interface])
                    if not name_check:
                        details += ", but " + topic_name + " is not in the list of " + interface + " of node " + node_name + ". " + interface + " are: " + str(
                            api_dict[node_name][interface])
                        groundtruth.result = Groundtruth.FAILED
                        data = min(data, 33.3)
                    else:
                        if not type_check:
                            details += ", but " + topic_name + " (of type " + topic_type + ") is not in the list of " + interface + " of node " + node_name + ". " + interface + " are: " + str(
                                api_dict[node_name][interface])
                            groundtruth.result = Groundtruth.FAILED
                            data = min(data, 66.6)
        return data, details