Skip to content

[BUG]: CommandXboxController.getRightX() and CommandXboxController.getRightY() not working #84

@rayluo

Description

@rayluo

Problem description

This is a regression in robotpy 2025.

Operating System

Linux

Installed Python Packages

$ pip list
Package                  Version
------------------------ ----------
bcrypt                   4.2.1
cffi                     1.17.1
cryptography             44.0.0
flexcache                0.3
flexparser               0.4
iniconfig                2.0.0
packaging                23.2
paramiko                 3.5.0
Pint                     0.24.4
pip                      24.3.1
platformdirs             4.3.6
pluggy                   1.5.0
pycparser                2.22
pyfrc                    2025.0.0
PyNaCl                   1.5.0
pynetconsole             2.0.4
pyntcore                 2025.2.1.1
pytest                   8.3.4
pytest-reraise           2.1.2
robotpy                  2025.2.1.1
robotpy-cli              2024.0.0
robotpy-commands-v2      2025.1.1
robotpy-hal              2025.2.1.1
robotpy-halsim-gui       2025.2.1.1
robotpy-installer        2025.0.1
robotpy-wpilib-utilities 2025.0.0
robotpy-wpimath          2025.2.1.1
robotpy-wpinet           2025.2.1.1
robotpy-wpiutil          2025.2.1.1
robotpy-xrp              2025.2.1.1
tomli                    2.2.1
tomlkit                  0.13.2
typing_extensions        4.12.2
wpilib                   2025.2.1.1

Reproducible example code

from wpilib import TimedRobot
from commands2.button import CommandXboxController

class MyRobot(TimedRobot):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.c = CommandXboxController(0)

    def robotPeriodic(self):
        print(self.c.getLeftX(), self.c.getLeftY(), self.c.getRightX(), self.c.getRightY())
        return super().robotPeriodic()

In robotpy 2024, you can move either sticks up, down, left, right, and observe the corresponding getLeftX(), getLeftY(), getRightX(), getRightY() returning a float ranging from -1 to 1. All good.

But in robotpy 2025, only the left-hand stick provides expected readings, the right-hand stick's up-down movement results -1 to 1 being returned in getRightX(), while it should have been from getRightY() instead; and then the getRightY() always return -1.

At one point, I can reproduce this with two different models of Xbox controllers, which are an Xbox Series S/X controller and an Xbox One controller. So, it feels like a software issue.

UPDATE:
My Xbox Series S/X controller exhibits this issue, while my Xbox One controller works fine. Upon close inspection of the raw "Axis[?]" readings from the simulation UI, I noticed that the different Xbox controller's inputs were mapped to different orders IN MY ENVIRONMENT.

  • Xbox One controller: The Axis[0], Axis[1], ..., Axis[5] are mapped to Left stick horizontal movement, Left stick vertical movement, Left Trigger (throttle), Right Trigger (throttle), Right stick horizontal, Right stick vertical, respectively. And this config works flawlessly.
  • Xbox Series S/X controller: The Axis[0], Axis[1], Axis[2] are same as above, but Axis[3], Axis[4], Axis[5] somehow mapped to right horizontal, right vertical and right trigger. This caused them being interpreted incorrectly by the wpilib.

I chalk this up to perhaps a faulty driver in my environment. Documenting my journey for posterity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions