Esempio n. 1
0
        def __init__(self):
            Tester.__init__(self, "Navigation")

            # tests to run:
            #   square with Motion module, minimal.launch
            #   square with Motion module, navigation launch
            # expect all to turn out the same, but need to sanity check
            #self.motion = Motion()

            # flag for a jerky stop
            self.jerky = False

            # I'm a bit concerned about robot safety if we don't slow things down,
            # but I'm also worried it won't be an accurate test if we change the speed
            self.walking_speed = 1  # if not self.jerky else .5

            # linear test
            self.reached_goal = False

            # square test
            self.reached_corner = [False, False, False, False]
            self.cc_square = [(0, 0), (1, 0), (1, 1), (0, 1)]
            self.c_square = [(0, 0), (1, 0), (1, -1), (0, -1)]
            self.corner_counter = 0

            # set up the logger output file
            self.filename = None

            self.navigation = Navigation(self.jerky)
Esempio n. 2
0
        def __init__(self):
            Tester.__init__(self, "Localization")

            # set up localization (including map)
            landmarks = {0, 1}
            landmark_positions = {0: (0, 0), 1: (1, 1)}
            landmark_orientations = {0: -pi / 2, 1: pi / 2}
            self.localization = Localization({}, {}, {}, landmarks,
                                             landmark_positions,
                                             landmark_orientations)

            self.csvtestname = "estimation"
Esempio n. 3
0
        def __init__(self):
            Tester.__init__(self, "NavLoc")

            # flag for a jerky stop
            self.jerky = False

            # I'm a bit concerned about robot safety if we don't slow things down,
            # but I'm also worried it won't be an accurate test if we change the speed
            self.walking_speed = 1  # if not self.jerky else .5

            # linear test
            self.reached_goal = False

            # square test
            self.reached_corner = [False, False, False, False]
            self.cc_square = [(0, 0), (1, 0), (1, 1), (0, 1)]
            self.c_square = [(0, 0), (1, 0), (1, -1), (0, -1)]
            self.corner_counter = 0

            # set up the logger output file
            self.test_name = "path"

            # set up points on map
            point_ids = MD2.points
            locations = MD2.locations
            neighbors = MD2.neighbors

            # set map location of the landmark
            landmarks = MD2.landmarks
            landmark_positions = MD2.landmark_pos
            landmark_orientations = MD2.landmark_orient

            self.navloc = NavLoc(point_ids,
                                 locations,
                                 neighbors,
                                 landmarks,
                                 landmark_positions,
                                 landmark_orientations,
                                 jerky=self.jerky,
                                 walking_speed=self.walking_speed)

            # set the destinations
            self.destination = [
                self.navloc.floorplan.graph['T'].location,
                self.navloc.floorplan.graph['R'].location
            ]
Esempio n. 4
0
 def __init__(self):
     Tester.__init__(self)
Esempio n. 5
0
 def __init__(self):
     # initalize test class
     Tester.__init__(self, "Logger")
Esempio n. 6
0
 def __init__(self):
     Tester.__init__(self, "Motion")
     
     # set up basic sensing
     self.sensors = Sensors()
     self.motion = Motion()
Esempio n. 7
0
 def __init__(self):
     Tester.__init__(self, "Sensors")
     self.sensors = Sensors()
Esempio n. 8
0
 def __init__(self, branch, hash):
     Tester.__init__(self, branch, traceMainScript, ())
     self.hash = hash
     self.imageDirectory = imageDir + self.branch + "_" + self.hash + "/"
Esempio n. 9
0
    def __init__(self,
                 deploy_prototxt,
                 model_file,
                 mean_file=None,
                 mean_value=None,
                 ratio_file=None,
                 label_file=None,
                 device_id=-1,
                 score_thred=0.0,
                 top_k=-1,
                 ratio=-1.0,
                 image_size=256,
                 raw_scale=255.0,
                 gray=False):
        """
        初始化
        """
        Tester.__init__(self)

        self.score_thred = score_thred
        self.top_k = top_k
        self.ratio = ratio
        self.gray = gray

        self.ratios = None
        if ratio_file is not None and os.path.exists(ratio_file):
            self.ratios = dict()
            for i, line in enumerate(open(ratio_file)):
                items = line.strip(" \0\t\r\n").split(";")
                self.ratios[i] = float(items[1])

        self.labels = None
        if label_file is not None:
            self.labels = open(label_file).readlines()
            self.labels = filter(lambda x: len(x.split(";")) == 2, self.labels)
            self.labels = map(lambda x: x.strip().decode("utf-8"), self.labels)

        if device_id < 0:
            caffe.set_mode_cpu()
        else:
            caffe.set_mode_gpu()
            caffe.set_device(device_id)

        mean = None
        # mean: num, channels, height, width
        if mean_file and os.path.exists(mean_file):
            mean_suffix = os.path.splitext(mean_file)[1]
            if mean_suffix == ".binaryproto":
                binary_data = open(mean_file, "rb").read()
                proto_data = caffe.io.caffe_pb2.BlobProto.FromString(
                    binary_data)
                mean = caffe.io.blobproto_to_array(proto_data)
            elif mean_suffix == ".npy":
                mean = np.load(mean_file)
        elif mean_value is not None:
            mean = np.tile(np.array(mean_value),
                           (1, image_size, image_size, 1))
            mean = mean.transpose((0, 3, 1, 2))

        if mean is not None and mean.ndim == 4:
            mean = mean[0]
        assert mean is None or mean.ndim == 3

        self.detector = caffe.Detector(deploy_prototxt, model_file, \
                                       image_dims=(image_size, image_size), mean=mean, \
                                       raw_scale=raw_scale, channel_swap=(2, 1, 0) if not self.gray else None)

        # thread lock
        self.mutex = threading.Lock()

        # init over
        self.is_init = True
Esempio n. 10
0
 def __init__(self):
     Tester.__init__(self, "SafeMotion")
     
     # set up basic sensing
     self.motion = SafeMotion(safety_level=1)