def get_move(serial, move_num): time.sleep(0.02) move = psmove.PSMove(move_num) time.sleep(0.05) if move.get_serial() != serial: for move_num in range(psmove.count_connected()): move = psmove.PSMove(move_num) if move.get_serial() == serial: return move return None else: return move
def __init__(self, id): self.id = id print "JostlePlayer(%d) inited" % id self.move = psmove.PSMove(id) if (not self.move.has_calibration()): raise Exception("No calibration for controller %d" % id) self.reset()
def __init__(self, id): QObject.__init__(self) self.id = id self.move = psmove.PSMove(id) self.sensor_values = [] self.current_sensor_position = (0, 0, 0) self.last_pumping_value = 0 self.last_pump_action = 0
def check_for_new_moves(self): self.enable_bt_scanning(True) #need to start tracking of new moves in here if psmove.count_connected() != self.move_count: self.moves = [ psmove.PSMove(x) for x in range(psmove.count_connected()) ] self.move_count = len(self.moves)
def color_proc(q, ): moves = [psmove.PSMove(x) for x in range(psmove.count_connected())] while True: while not q.empty(): colors = q.get() for move, color in zip(moves, colors): move.set_leds(*color) move.update_leds() sleep(.25)
def __init__(self): self._move = psmove.PSMove() self._fade_to = (0, 0, 0) self._color = (0, 0, 0) self._thread = threading.Thread(target=self._fade_thread_proc) self._thread.setDaemon(True) self._thread.start()
def __init__(self, command_queue=Queue(), status_manager=Manager()): if not os.path.isfile('joustconfig.ini'): self.create_settings() else: config = configparser.ConfigParser() config.read("joustconfig.ini") self.audio_toggle = config.getboolean("GENERAL", "audio") self.sensitivity = int(config['GENERAL']['sensitivity']) self.instructions = config.getboolean("GENERAL", "instructions") self.con_games = [] for i in range(len(common.game_mode_names)): mode = common.game_mode_names[i] if config.getboolean("CONGAMES", mode): self.con_games.append(i) if self.con_games == []: self.con_games = [0] self.enforce_minimum = True self.move_can_be_admin = True self.move_count = psmove.count_connected() self.dead_count = Value('i', 0) self.moves = [ psmove.PSMove(x) for x in range(psmove.count_connected()) ] self.admin_move = None #move controllers that have been taken out of play self.out_moves = {} self.random_added = [] self.rand_game_list = [] self.show_battery = Value('i', 0) self.tracked_moves = {} self.force_color = {} self.paired_moves = [] self.move_opts = {} self.teams = {} self.game_mode = common.Games.Random.value self.old_game_mode = common.Games.Random.value self.pair = pair.Pair() self.command_queue = command_queue self.status_manager = status_manager self.status_ns = status_manager.Namespace() self.status_ns.status_dict = dict() self.command_from_web = '' self.i = 0 #load audio now so it converts before the game begins self.choose_new_music()
def __init__(self): self.move = psmove.PSMove() self.timeout = 3.0 self.curr_time = 0.0 self.sleep_time = 0.1 self.sensors = { 'a': 'Accelerometer', 'g': 'Gyroscope', 'm': 'Magnetometer' } self.axes = ['x', 'y', 'z'] self.bar_size = 255 self.extents = { 'a': (-4000, 4000), 'g': (-6000, 6000), 'm': (-360, 360), } self.debug = False self.raw_values = { sensor: {axis: 0 for axis in self.axes} for sensor in self.sensors.keys() } self.translated_values = dict(self.raw_values) self.selected_sensor = 'a' self.show_sensors = True self.move_pressed = False self.trigger_pressed = False self.trigger_value = 0 self.button_mappings = { 'Move': psmove.Btn_MOVE, 'Triangle': psmove.Btn_TRIANGLE, 'Circle': psmove.Btn_CIRCLE, 'Cross': psmove.Btn_CROSS, 'Square': psmove.Btn_SQUARE, 'Select': psmove.Btn_SELECT, 'Start': psmove.Btn_START, } self.button_values = {b: False for b in self.button_mappings.keys()} if self.move.connection_type == psmove.Conn_Bluetooth: print('bluetooth') elif self.move.connection_type == psmove.Conn_USB: print('usb') else: print('unknown') if self.move.connection_type != psmove.Conn_Bluetooth: print('Please connect controller via Bluetooth') sys.exit(1) self.specs = self.load_specs()
def __init__(self): self.command_queue = Queue() self.joust_manager = Manager() self.ns = self.joust_manager.Namespace() self.web_proc = Process(target=webui.start_web, args=(self.command_queue, self.ns)) self.web_proc.start() self.ns.status = dict() self.ns.settings = dict() self.ns.battery_status = dict() self.command_from_web = '' self.initialize_settings() self.update_settings_file() #defined outside of ns.settings as it's a purely dev option self.experimental = False self.move_count = psmove.count_connected() self.dead_count = Value('i', 0) self.moves = [ psmove.PSMove(x) for x in range(psmove.count_connected()) ] self.admin_move = None #move controllers that have been taken out of play self.out_moves = {} self.random_added = [] self.rand_game_list = [] self.show_battery = Value('i', 0) #only allow one move to be paired at a time self.pair_one_move = True self.tracked_moves = {} self.force_color = {} self.paired_moves = [] self.move_opts = {} self.teams = {} self.game_mode = common.Games.Random self.old_game_mode = common.Games.Random self.pair = pair.Pair() self.i = 0 #load audio now so it converts before the game begins self.choose_new_music()
def __init__(self, parent=None): QWidget.__init__(self, parent) self.max = -1 self.move = psmove.PSMove() self.setStyleSheet("background-color:transparent;") self._angle = 0.0 self._margins = 10 self._pointText = { 0: "N", 45: "NE", 90: "E", 135: "SE", 180: "S", 225: "SW", 270: "W", 315: "NW" }
def __init__(self): self.move_count = psmove.count_connected() self.moves = [ psmove.PSMove(x) for x in range(psmove.count_connected()) ] self.out_moves = {} #may need to make it a dict of a list? self.random_added = [] self.rand_game_list = list(range(GAME_MODES)) self.rand_game_list.remove(common.Games.JoustTeams.value) self.rand_game_list.remove(common.Games.Random.value) self.rand_game_list.remove(common.Games.Commander.value) self.tracked_moves = {} self.paired_moves = [] self.move_opts = {} self.teams = {} self.game_mode = common.Games.JoustFFA.value self.pair = pair.Pair() self.game_loop()
def __init__(self): self.move_count = psmove.count_connected() self.moves = [psmove.PSMove(x) for x in range(psmove.count_connected())] self.admin_move = None #move controllers that have been taken out of play self.out_moves = {} self.random_added = [] self.rand_game_list = [] self.sensitivity = Sensitivity.mid.value self.instructions = True self.show_battery = Value('i', 0) self.tracked_moves = {} self.force_color = {} self.paired_moves = [] self.move_opts = {} self.teams = {} self.con_games = [common.Games.JoustFFA.value] self.game_mode = common.Games.Random.value self.old_game_mode = common.Games.Random.value self.pair = pair.Pair() self.game_loop()
def track_controller(serial, num_try, opts): move = psmove.PSMove(num_try) if move.get_serial() != serial: for move_num in range(psmove.count_connected()): move = psmove.PSMove(move_num) if move.get_serial() == serial: break time.sleep(0.01) move.set_leds(200, 200, 200) move.update_leds() time.sleep(0.01) move_last_value = None vibrate = False vibration_time = time.time() + 1 flash_lights = True flash_lights_timer = 0 change_arr = [0, 0, 0] while True: if move.poll(): ax, ay, az = move.get_accelerometer_frame(psmove.Frame_SecondHalf) total = sum([ax, ay, az]) if move_last_value is not None: change_real = abs(move_last_value - total) change_arr[0] = change_arr[1] change_arr[1] = change_arr[2] change_arr[2] = change_real change = (change_arr[0] + change_arr[1] + change_arr[2]) / 3 # Dead #TODO: should probably only change this # when the state changes (i.e. human death) if opts[0] == 0: warning = human_warning threshold = human_max if opts[0] == 1: warning = zombie_warning threshold = zombie_max if change > threshold: move.set_leds(255, 0, 0) move.set_rumble(100) opts[3] = 0 # Warn elif change > warning and not vibrate: move.set_leds(20, 50, 100) vibrate = True vibration_time = time.time() + 0.5 move.update_leds() #if we are dead if opts[3] == 0: vibrate = False move.set_leds(255, 0, 0) move.update_leds() move.set_rumble(70) #regular colors else: #need gun selection color in here #if human if opts[0] == 1: move.set_leds(20, 139, 16) move.set_rumble(0) #move.update_leds() #not holding button if (move.get_buttons() == 0 and move.get_trigger() < 10): opts[2] = 0 #human update if opts[0] == 0: #128, 16 ,32 button = move.get_buttons() #pistol # middle button to show bullet count (0-5) if opts[4] == 5: move.set_leds(255, 0, 255) if opts[4] == 4: move.set_leds(0, 0, 255) if opts[4] == 3: move.set_leds(0, 0, 255) if opts[4] == 2: move.set_leds(0, 0, 255) if opts[4] == 1: move.set_leds(0, 0, 255) if opts[4] == 0: move.set_leds(100, 100, 100) #not holding button, selected pistol, has bullets, and presses trigger if (opts[2] == 0 and opts[4] > 0 and opts[4] < 5 and move.get_trigger() > 100): opts[2] = 1 opts[1] = 2 opts[4] = opts[4] - 1 #molotov elif (opts[2] == 0 and opts[4] >= 5 and move.get_trigger() > 100): opts[2] = 1 opts[1] = 4 opts[4] = 0 if vibrate: flash_lights_timer += 1 if flash_lights_timer > 7: flash_lights_timer = 0 flash_lights = not flash_lights if flash_lights: move.set_leds(50, 0, 0) if time.time() < vibration_time - 0.22: move.set_rumble(70) else: move.set_rumble(0) if time.time() > vibration_time: vibrate = False #else: # move.set_leds(*team_colors[team.value]) move.update_leds() move_last_value = total
def track_controller(serial, num_try, opts): move = psmove.PSMove(num_try) if move.get_serial() != serial: for move_num in range(psmove.count_connected()): move = psmove.PSMove(move_num) if move.get_serial() == serial: break time.sleep(0.01) move.set_leds(200,200,200) move.update_leds() time.sleep(0.01) move_last_value = None while True: if move.poll(): ax, ay, az = move.get_accelerometer_frame(psmove.Frame_SecondHalf) total = sum([ax, ay, az]) if move_last_value is not None: change = abs(move_last_value - total) # Dead #TODO: should probably only change this # when the state changes (i.e. human death) if opts[0] == 0: warning = human_warning threshold = human_max if opts[0] == 1: warning = zombie_warning threshold = zombie_max if opts[0] == 2: warning = speed_zombie_warning threshold = speed_zombie_max if opts[0] == 3: warning = hulk_zombie_warning threshold = hulk_zombie_max if change > threshold: move.set_leds(255,0,0) move.set_rumble(100) opts[3] = 0 # Warn elif change > warning: move.set_leds(20,50,100) move.set_rumble(110) move.update_leds() #if we are dead if opts[3] == 0: move.set_leds(255,0,0) move.update_leds() move.set_rumble(70) #regular colors else: #need gun selection color in here #if human if opts[0] == 0 and opts[2] == 0: pass # if opts[5] == 0: # move.set_leds(200,200,200) # elif opts[5] == 1: # move.set_leds(50,50,200) # elif opts[5] == 2: # move.set_leds(150,40,255) # elif opts[5] == 3: # move.set_leds(220,220,40) elif opts[0] == 1: move.set_leds(20,139,16) #elif opts[0] == 2: # move.set_leds(255,165,0) #elif opts[0] == 3: # move.set_leds(72,209,204) move.set_rumble(0) #move.update_leds() #not holding button if (move.get_buttons() == 0 and move.get_trigger() < 10): opts[2] = 0 #human update if opts[0] == 0: #128, 16 ,32 button = move.get_buttons() #pistol #if (opts[2] == 0 and button == 16): #holding button #opts[2] = 1 #if has shotgun, cycle weapons #if opts[6] == 2: # opts[5] = (opts[5] + 1) % 3 # if opts[5] == 0: # opts[5] = 1 #if has shotgun/molotov cycle weapons #elif opts[6] == 4: # opts[5] = (opts[5] + 1) % 4 # if opts[5] == 0: # opts[5] = 1 #update colors: #if opts[5] == 0: # move.set_leds(200,200,200) #elif opts[5] == 1: # move.set_leds(50,50,200) #elif opts[5] == 2: # move.set_leds(150,40,255) #elif opts[5] == 3: # move.set_leds(220,220,40) # middle button to show bullet count (0-5) ##if (button == 524288 or button == 1572864): #if (button == 524288 or button == 1572864): if opts[4] == 5: move.set_leds(255,0,255) if opts[4] == 4: move.set_leds(0,0,255) if opts[4] == 3: move.set_leds(0,0,255) if opts[4] == 2: move.set_leds(0,0,255) if opts[4] == 1: move.set_leds(0,0,255) if opts[4] == 0: move.set_leds(100,100,100) #not holding button, selected pistol, has bullets, and presses trigger if (opts[2] == 0 and opts[4] > 0 and opts[4] < 5 and move.get_trigger() > 100): opts[2] = 1 opts[1] = 2 opts[4] = opts[4] - 1 #same but with shotgun #elif(opts[2] == 0 and opts[5] == 2 and opts[4] >= 2 and move.get_trigger() > 100): # opts[2] = 1 # opts[1] = 3 # opts[4] = opts[4] - 2 #molotov elif(opts[2] == 0 and opts[4] >= 5 and move.get_trigger() > 100): opts[2] = 1 opts[1] = 4 opts[4] = 0 move.update_leds() move_last_value = total
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'build')) import time import psmove if psmove.count_connected() < 2: print('This examples requires at least 2 controllers.') sys.exit(1) a = psmove.PSMove(0) b = psmove.PSMove(1) i = 0 while True: if i % 12 in (1, 3, 5): a.set_leds(255, 0, 0) elif i % 12 in (7, 9, 11): b.set_leds(0, 0, 255) else: a.set_leds(0, 0, 0) b.set_leds(0, 0, 0) a.update_leds() b.update_leds() time.sleep(.05)
pause_time = time.time() + sleep while time.time() < pause_time: for othermove in moves: othermove.poll() othermove.set_rumble(rumble) othermove.set_leds(*leds) othermove.update_leds() paired_controllers = [] controllers_alive = {} usb_paired_controllers = [] while True: start = False while True: moves = [psmove.PSMove(x) for x in range(psmove.count_connected())] for move in moves: if move.this == None: print "Move initialisation failed, reinitialising" moves = [] break # If a controller is plugged in over USB, pair it and turn it white if move.connection_type == psmove.Conn_USB: #make sure the serial is not None. this might happen if you pull the usb while still in this loop if move.get_serial( ) not in usb_paired_controllers and move.get_serial() != None: move.pair() usb_paired_controllers.append(move.get_serial()) print move.get_serial() + " Connected" move.set_leds(255, 255, 255)
import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'build')) import time import psmove count = psmove.count_connected() print('Connected controllers:', count) colors = [ (255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (0, 255, 255), (255, 0, 255), (255, 255, 255), (255, 128, 255), (255, 128, 128), ] moves = [(m.get_serial(), m) for m in (psmove.PSMove(i) for i in range(count))] for i, (serial, move) in enumerate(sorted(moves)): move.set_leds(*colors[i%len(colors)]) print('Move:', serial) move.update_leds()
return (y, int(x)) # Run mk-index.py to create the file serials.txt, which contains an ordered # list of controllers' serial numbers (btaddr) serial_to_idx = dict(list(map(mapidx, open('serials.txt').read().splitlines()))) count = psmove.count_connected() print('Connected controllers:', count) print('Serials:', len(serial_to_idx)) assert count == len(serial_to_idx) moves = [ move for idx, move in sorted([(serial_to_idx[m.get_serial()], m) for m in (psmove.PSMove(i) for i in range(count))]) ] for move in moves: move.intensity = 0. i = 0 while True: for idx, move in enumerate(moves): move.intensity *= random.uniform(.7, .9) if (i % len(moves)) == idx: move.intensity = 1. move.set_leds(0, int(255 * move.intensity), int(255 * move.intensity)) move.update_leds() i += 1
def __init__(self): self.command_queue = Queue() self.joust_manager = Manager() self.ns = self.joust_manager.Namespace() self.web_proc = Process(target=webui.start_web, args=(self.command_queue, self.ns)) self.web_proc.start() self.ns.status = dict() self.ns.settings = dict() self.ns.battery_status = dict() self.command_from_web = '' self.initialize_settings() self.update_settings_file() #check for update if platform == "linux" or platform == "linux2": self.big_update = update.check_for_update( self.ns.settings['menu_voice']) self.git_hash = update.run_command("git rev-parse HEAD")[:7] #defined outside of ns.settings as it's a purely dev option self.experimental = False self.move_count = psmove.count_connected() self.dead_count = Value('i', 0) self.moves = [ psmove.PSMove(x) for x in range(psmove.count_connected()) ] self.admin_move = None #move controllers that have been taken out of play self.out_moves = {} self.random_added = [] self.rand_game_list = [] self.show_battery = Value('i', 0) #only allow one move to be paired at a time self.pair_one_move = True self.tracked_moves = {} self.force_color = {} self.paired_moves = [] self.move_opts = {} self.teams = {} self.game_mode = common.Games[self.ns.settings['current_game']] self.old_game_mode = self.game_mode self.pair = pair.Pair() self.menu = Value('i', 1) self.controller_game_mode = Value('i', 1) self.restart = Value('i', 0) self.controller_teams = {} self.controller_colors = {} self.dead_moves = {} self.music_speed = Value('d', 0) self.werewolf_reveal = Value('i', 2) self.show_team_colors = Value('i', 0) self.red_on_kill = Value('i', 0) self.zombie_opts = {} self.commander_intro = Value('i', 1) self.commander_move_opts = {} self.commander_powers = [Value('d', 0.0), Value('d', 0.0)] self.commander_overdrive = [Value('i', 0), Value('i', 0)] self.five_controller_opts = {} self.swapper_team_colors = Array('i', [0] * 6) self.fight_club_colors = {} self.invincible_moves = {} self.num_teams = Value('i', 1) self.bomb_color = Array('i', [0] * 3) self.game_start = Value('i', 0) self.false_colors = {} self.was_faked = {} self.rumble = {} self.kill_controller_proc = {} self.controller_sensitivity = Array('d', [0] * 10) self.dead_invince = Value('b', False) self.i = 0 #load audio now so it converts before the game begins self.menu_music = Music("menu") self.joust_music = Music("joust") self.zombie_music = Music("zombie") self.commander_music = Music("commander") self.choose_new_music()
levels = [0, 0, 0, 0] midi = mido.open_output('IAC Driver Bus 1') ser = None for port in list_ports.comports(): if 'usbmodem' in port.device: ser = serial.Serial(port.device, 115200) if ser == None: print("\nCOULD NOT FIND SERIAL\n") dmx = pyenttec.select_port() controller = None if psmove.count_connected() > 0: controller = psmove.PSMove(0) debugChannel = 0 lastModeSwitchTime = 0 def pressureToValue(pressure): normalized = (pressure - MIN_PRESSURE) / (MAX_PRESSURE - MIN_PRESSURE) normalized = min(1, max(0, normalized)) return normalized * 127 def setHigherLevel(channel, value): if value > levels[channel]: setLevel(channel, value)
def to_glfloat(l): return (GLfloat * len(l))(*l) def read_matrix(m): return [m.at(i) for i in range(4 * 4)] near_plane = 1.0 far_plane = 100.0 fusion = psmove.PSMoveFusion(tracker, near_plane, far_plane) projection_matrix = read_matrix(fusion.get_projection_matrix()) moves = [psmove.PSMove(i) for i in range(psmove.count_connected())] for move in moves: move.enable_orientation(True) move.reset_orientation() class Texture: def __init__(self): self.id = glGenTextures(1) self.bind() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) self.unbind()
def __init__(self, do_device_discovery=True): # TODO: Should be OS dependant self.SF = sensorFusion() self.inputdevice = PyGameReader() self.pointerDevice = psmove.PSMove() self.PointerYaw = 0 self.kalmanPitch = KalmanFilter() self.kalmanRoll = KalmanFilter() self.viscousModeThrust = 67 self._emergency_landing = False self.auto = False self._min_thrust = 0 self._max_thrust = 0 self._maxAltitude = 0 self.currentAltitude = 0 self.minAltitude = 0 self._thrust_slew_rate = 0 self._thrust_slew_enabled = False self._thrust_slew_limit = 0 self._emergency_stop = False self._has_pressure_sensor = False self._canSwitch = True self._old_thrust = 0 self._old_alt_hold = False self._old_flip_type = -1 self._flip_time_start = -float("inf") self._trim_roll = Config().get("trim_roll") self._trim_pitch = Config().get("trim_pitch") self._trim_yaw = 0.0 if (Config().get("flightmode") is "Normal"): self._max_yaw_rate = Config().get("normal_max_yaw") self._max_rp_angle = Config().get("normal_max_rp") # Values are stored at %, so use the functions to set the values self.set_thrust_limits(Config().get("normal_min_thrust"), Config().get("normal_max_thrust")) self.set_thrust_slew_limiting(Config().get("normal_slew_rate"), Config().get("normal_slew_limit")) else: self._max_yaw_rate = Config().get("max_yaw") self._max_rp_angle = Config().get("max_rp") # Values are stored at %, so use the functions to set the values self.set_thrust_limits(Config().get("min_thrust"), Config().get("max_thrust")) self.set_thrust_slew_limiting(Config().get("slew_rate"), Config().get("slew_limit")) self._dev_blacklist = None if (len(Config().get("input_device_blacklist")) > 0): self._dev_blacklist = re.compile( Config().get("input_device_blacklist")) logger.info("Using device blacklist [{}]".format( Config().get("input_device_blacklist"))) self._available_devices = {} # TODO: The polling interval should be set from config file self._read_timer = PeriodicTimer(0.01, self.read_input) if do_device_discovery: self._discovery_timer = PeriodicTimer(1.0, self._do_device_discovery) self._discovery_timer.start() # Check if user config exists, otherwise copy files if not os.path.exists(ConfigManager().configs_dir): logger.info("No user config found, copying dist files") os.makedirs(ConfigManager().configs_dir) for f in glob.glob(sys.path[0] + "/cfclient/configs/input/[A-Za-z]*.json"): dest = os.path.join(ConfigManager().configs_dir, os.path.basename(f)) if not os.path.isfile(dest): logger.debug("Copying %s", f) shutil.copy2(f, ConfigManager().configs_dir) ConfigManager().get_list_of_configs() self.input_updated = Caller() self.rp_trim_updated = Caller() self.emergency_stop_updated = Caller() self.switch_mode_updated = Caller() self.device_discovery = Caller() self.device_error = Caller() self.althold_updated = Caller() self.auto_input_updated = Caller() self.pointer_input_updated = Caller()
import sys import os import time sys.path.insert(0, '/home/pi/psmoveapi/build/') import psmove import pair pairObj = pair.Pair() exit = False while not exit: connected = psmove.count_connected() input("Connect Moves via USB and press Enter.\nOr disconnect all USB Moves and press Enter to quit.") print("Moves connected: %d" % connected) moves = [psmove.PSMove(x) for x in range(connected)] exit = True for move in moves: print("Move %s connected via %s" % (move.get_serial(), ['Bluetooth','USB'][move.connection_type])) move.poll() print("Temperature is %d" % move.get_temperature()) if move.connection_type == psmove.Conn_USB: pairObj.pair_move(move) move.set_leds(100,100,100) exit = False move.update_leds()
# note that that tap_key does support a way of repeating keystrokes with a interval time between each # k.tap_key('l',n=2,interval=5) # and you can send a string if needed too # k.type_string('o World!') # k.tap_key('1') # k.tap_key('a') # k.tap_key(k.windows_l_key) # x, y = m.position() # m.move(x+300, y) nb = psmove.psmove_count_connected() print("Nb moves connected : " + str(nb)) move = psmove.PSMove() tracker = psmove.PSMoveTracker() tracker.set_mirror(True) # Calibrate the controller with the tracker result = -1 while result != psmove.Tracker_CALIBRATED: print 'Trying to calibrate...' result = tracker.enable(move) auto_update_leds = tracker.get_auto_update_leds(move) print 'Auto-update LEDs is', ('enabled' if auto_update_leds else 'disabled')
# POSSIBILITY OF SUCH DAMAGE. # import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'build')) import time import psmove if psmove.count_connected() < 2: print('This examples requires at least 2 controllers.') sys.exit(1) a = psmove.PSMove(0) b = psmove.PSMove(1) moves = [psmove.PSMove(x) for x in range(psmove.count_connected())] i = 0 while True: for move in moves: move.set_leds(0, 0, 0) if i % 12 in (1, 3, 5): for x in range(0, len(moves), 2): moves[x].set_leds(255, 0, 0) elif i % 12 in (7, 9, 11): for x in range(1, len(moves), 2): moves[x].set_leds(0, 0, 255)