} swift = SwiftAPI(filters={'hwid': 'USB VID:PID=2341:0042'}) # swift2 = SwiftAPI(filters={'hwid': 'USB VID:PID=2341:0042'}) # swift3 = SwiftAPI(filters={'hwid': 'USB VID:PID=2341:0042'}) swift.waiting_ready() device_info = swift.get_device_info() print(swift.port, device_info) firmware_version = device_info['firmware_version'] if firmware_version and not firmware_version.startswith(('0.', '1.', '2.', '3.')): swift.set_speed_factor(0.00001) swift.set_servo_detach() input('A4') swift.set_servo_attach() pos = swift.get_position() print(pos); bias = 23; swift.reset(speed=10000000); seqs = ["F", "G", "E", "A", "D", "G", "C", "C"] # seqs = ["C", "C", "D", "D", "E", "E", "D", "D"] count = 0; while True: count = count + 1 seq = seqs[count % len(seqs)]
api test: attach and detach """ swift = SwiftAPI(filters={'hwid': 'USB VID:PID=2341:0042'}) swift.waiting_ready() print(swift.set_servo_detach(servo_id=SERVO_BOTTOM)) time.sleep(2) print(swift.set_servo_detach(servo_id=SERVO_LEFT)) time.sleep(2) print(swift.set_servo_detach(servo_id=SERVO_RIGHT)) time.sleep(2) print(swift.set_servo_detach(servo_id=SERVO_HAND)) time.sleep(2) print(swift.set_servo_attach(servo_id=SERVO_BOTTOM)) time.sleep(2) print(swift.set_servo_attach(servo_id=SERVO_LEFT)) time.sleep(2) print(swift.set_servo_attach(servo_id=SERVO_RIGHT)) time.sleep(2) print(swift.set_servo_attach(servo_id=SERVO_HAND)) print(swift.set_servo_detach()) time.sleep(5) print(swift.set_servo_attach()) time.sleep(2) swift.disconnect()