Esempio n. 1
0
    def __init__(self):
        self.skeleton = glskeleton.GLSkeleton(draw_fn=self.draw,
                                              tick_fn=self.tick,
                                              event_fn=self.event)
        ##        self.control = IntegratedControl(speed=config.control_gain, smoothing=config.control_smoothing, mode=config.control_mode, scaling=config.control_smoothing)

        ##        self.barrier_descriptors = {}
        ##        f = open("barriers.yaml")
        ##        yaml_barrier_descriptors = yaml.load(f)

        ##        for barrier in yaml_barrier_descriptors:
        ##            name = barrier.keys()[0]
        ##            entry = barrier[name]
        ##            self.barrier_descriptors[name] = BarrierDescriptor(name,entry)
        ##        f.close()

        # connect to network ports
        self.receiver = NetworkReceive(config.control_port, "!dddd")
        self.control_receiver = NetworkReceive(config.event_port, "!d")
        self.fbk_port = NetworkSend(config.fbk_port, config.fbk_ip, "!c")

        ##        self.car = Snapable(snap=config.snappiness)

        self.load_images()

        self.background_width = self.background_image.get_width()
        edge = 0
        self.edge = edge

        self.active_mode = 1
        self.JS_value = 0
        self.lock_state = 1
        self.orthosis_angle = 0

        self.state = STATE_WAITING

        self.create_back_surface()
        self.skeleton.main_loop()
Esempio n. 2
0
    def __init__(self):
        self.skeleton = glskeleton.GLSkeleton(draw_fn=self.draw,
                                              tick_fn=self.tick,
                                              event_fn=self.event)
        self.control = IntegratedControl(speed=config.control_gain,
                                         smoothing=config.control_smoothing,
                                         mode=config.control_mode,
                                         scaling=config.control_smoothing)

        self.barrier_descriptors = {}
        f = open("barriersErrP.yaml")
        yaml_barrier_descriptors = yaml.load(f)

        for barrier in yaml_barrier_descriptors:
            name = barrier.keys()[0]
            entry = barrier[name]
            self.barrier_descriptors[name] = BarrierDescriptor(name, entry)
        f.close()

        # connect to network ports
        self.receiver = NetworkReceive(config.control_port, "!dddddd")
        self.control_receiver = NetworkReceive(config.event_port, "!d")
        self.fbk_port = NetworkSend(config.fbk_port, config.fbk_ip, "!c")

        self.car = Snapable(snap=config.snappiness)

        self.load_images()

        self.noise = 0

        self.tyre_level = 0
        self.played_score = 0
        self.skeleton.fps = 120
        self.lane_width = self.lane_image.get_width()
        self.nlanes = config.nlanes

        self.barriers = BarrierModel(self.nlanes)

        edge = (self.skeleton.w - self.nlanes * self.lane_width) / 2

        centers = [
            edge + self.lane_width / 2 + i * self.lane_width
            for i in range(self.nlanes)
        ]

        self.edge = edge
        self.car.set_centers(numpy.array(centers))

        self.control_value = 0
        self.position = 0
        self.control_mode = 0
        self.info = 0

        self.trialnumber = 0
        self.maxscore = 0

        self.scoring = False
        self.speed = 4
        self.time_to_reach_end = config.speed

        self.car_jump = 0
        self.car_swivel = 0
        self.fps = 60
        self.car_lane = 0
        self.score = 0
        self.score_deflection = 0
        self.state = STATE_WAITING

        self.create_back_surface()
        self.skeleton.main_loop()