Skip to content

[Bug] Hub can freeze when connecting Xbox Controller #2533

@BertLindeman

Description

@BertLindeman

Describe the bug
A program with 3 car definitions hangs and powers-off (almost all times) if the xbox controller is OFF

To reproduce
Steps to reproduce the behavior:

  1. go to beta.pybricks.com
  2. Add or open the program below
  3. Connect the hub
  4. Keep the xbox controller OFF
  5. Run the program
  6. See the steer motor calibrate 3 times and then on the last turn spin at high speed. And the hub animations stops and soon the hub powers off.

If this does not crash the first time, then try first a run where the xbox does connect and retry with the xbox controller OFF.

Expected behavior
The program do the 3 steer calibrations and with the steer in zero position wait for the xbox to connect, or timeout.

Screenshots
Video showing a stop without power-off:

Image

extra info

  1. Problem not seen with V3.6.1 Pybricks MicroPython ci-release-86-v3.6.1 on 2025-03-11; SPIKE Prime Hub with STM32F413VG (Tried 10 times)
  2. Problem does occur on the current beta firmware and with firmware of primehub-firmware-build-4577-gitfcfdf4e0

test program
Python program to be able to look at #2532 due to 3 cars in one program.

from pybricks.hubs import InventorHub
from pybricks.iodevices import XboxController
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import Car, DriveBase
from pybricks.tools import wait, StopWatch

hub = InventorHub()
print(1)
frontR = Motor(Port.A)
print(2)
frontL = Motor(Port.B)
print(3)
middle = Motor(Port.C)
print(4)
backR = Motor(Port.D)
print(5)
backL = Motor(Port.F)
print(6)
steer = Motor(Port.E)

print(7)
carA = Car(steer, (frontR, frontL))
print(8)
carB = Car(steer, (middle))
print(9)
carC = Car(steer, (backL, backR))

print(10)
xbox = XboxController()

print(11)
print(f"xbox.joystick_left() {type(xbox.joystick_left())} {xbox.joystick_left()[1]}")

print(12)

while True:
    speed = xbox.joystick_left()[1]
    # print(f"speed {speed}")
    carC.drive_speed(speed)
    carC.steer(xbox.joystick_right()[0])
    wait(100)

The program has the prints to see where it crashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    hub: primehub/inventorhubIssues related to the LEGO SPIKE Prime hub and LEGO MINDSTORMS Robot Invetor hubsoftware: pybricks-micropythonIssues with Pybricks MicroPython firmware (or EV3 runtime)topic: remote controlIssues related to remotly controlling hubs

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions