def on_start(sim): global table table = sensiball.Table(device='/dev/cu.usbmodem1411') time.sleep(5) table.add_handler(handler) print('calibtrating...') table.calibrate()
def on_start(sim): global table table = sensiball.Table('/dev/cu.usbmodem1411') table_dict[table] = None table.add_handler(table_inout)
import sensiball import time import sys class Handler(object): def handle_positions(self, positions): ratio = round(float(positions[0]) / float(positions[1]) * 100) if ratio > 100: ratio = 100 elif ratio < 0: ratio = 0 sys.stdout.write('\r' + '-' * (100 - ratio) + '█' + '-' * ratio) handler = Handler() table = sensiball.Table(device='/dev/cu.usbmodem1421') table.add_handler(handler) while True: for i in range(0, 1): table.set_speeds((60, 0, 0, 0, 0, 0, 0, 0)) time.sleep(0.001) for i in range(0, 1): table.set_speeds((-60, 0, 0, 0, 0, 0, 0, 0)) time.sleep(0.001)
maximum_pulses, # defender rotation pulses, # midfield translation maximum_pulses, # midfield translation pulses, # midfield rotation maximum_pulses, # midfield rotation pulses, # forward translation maximum_pulses, # forward translation pulses, # forward rotation maximum_pulses, # forward rotation ) For translations, `pulses == 0` means the shaft reached the inner limit, and `pulses == maximum_pulses - 1` means it reached the outer one. For rotations, `maximum_pulses` is always `980`. `pulses == 0` means vertical (default player position). """ print(positions) table = sensiball.Table(device='/dev/cu.usbmodemFA131') handler = Handler() table.add_handler(handler) time.sleep(2) table.set_speeds((120, 120, 0, 0, 0, 0, 0, 0)) time.sleep(1) table.set_speeds((-120, -120, 0, 0, 0, 0, 0, 0)) time.sleep(1) table.set_speeds((0, 0, 0, 0, 0, 0, 0, 0)) table.calibrate() table.close()