support
support copied to clipboard
[Bug] XboxController sometimes gives RuntimeError when connecting with SPIKE
Describe the bug
Sometimes you have to restart the program to connect. Trying again always works, so this is probably something we can catch and resolve in the bluetooth_btstack driver.
To reproduce
Use the XboxController with one of the SPIKE hubs, and get a RuntimeError sometimes.
Experiencing the same. Was iterating on a project an kept having to toggle bluetooth on/off for the macbook, hub and controller to get the error to go away. But now even that as stopped working. Refreshing the chrome tab doesn't seem to help either. I haven't yet restarted the machine completely but this seems like an issue.
from pybricks.iodevices import XboxController
from pybricks.parameters import Direction, Port
from pybricks.pupdevices import Motor
from pybricks.robotics import DriveBase
# Set up all devices.
left_wheel = Motor(Port.A, Direction.COUNTERCLOCKWISE)
right_wheel = Motor(Port.B, Direction.CLOCKWISE)
robot = DriveBase(left_wheel, right_wheel, 56, 128)
controller = XboxController()
# The main program starts here.
while True:
if controller.triggers()[1] > 0 or controller.triggers()[0] > 0:
robot.drive(10 * controller.triggers()[1] - 10 * controller.triggers()[0], controller.joystick_left()[0])
else:
robot.stop()
Error
Traceback (most recent call last):
File "setup_demo.py", line 11, in <module>
RuntimeError: Unknown error