wpilib.ds: Joystick Button on port 0 not available

Hello folks, I’m pretty new to Command Based Programming in RobotPy, and I’m trying to create a simple robot with a few subsystems and commands that run on joystick input. The problem I have is that once I try to get the button object of the joystick, wpilib driverstation raises a warning that it cannot find the specific button.

from wpilib.joystick import Joystick
from wpilib.buttons.joystickbutton import JoystickButton
from commands.grippers_exhaust import GrippersExhaust

def getJoystick():

    joystick = Joystick(0)

    trigger = JoystickButton(joystick, Joystick.ButtonType.kTrigger)

    return joystick

Now once I run the code, in the simulator, simple run or deploy it to the robot (so it is not a simulator issue or such) wpilib displays this error in the console:

WARNING : wpilib.ds           : Joystick Button 1 on port 0 not available, check if controller is plugged in

Now the weird part is that using any commands to get information about buttons on the joystick are fine and work - I’ve already checked that the joystick is on port 0 - and things such as the axis, or getRawButton() work - so the program does recognize the buttons, it’s just that when I try to use that button like an object - such as the trigger.whenPressed() function, it will simply not work. But if I put the trigger.get() function in a loop for example, it will still print ‘True’ once the button is pressed. This is so weird and I can’t seem to find any way to fix this.

I’ve searched the internet for a similar issue but found no solutions, or most of them were - ‘Check if the joystick is connected to port 0’, which it is.

I’ll be glad if anyone here encountered the same issue when programming, or can give me an alternative, as I don’t want to just write a Button Trigger myself, as it can be tedious and unstable alike.

Looks like you found a weird race condition. Filed a bug on github at https://github.com/robotpy/robotpy-wpilib/issues/473

In my testing, it seems that the warning only occurs once at startup, right? If so, it’s safe to ignore it for now. We’ll make sure that it gets fixed for 2019 though.

Yeah, seems like it really doesn’t affect the functionality of the robot once the robotInit() is over - and from what I’ve also seen it does appear only once or maybe a few times for several buttons - but only on startup. Thanks :slight_smile: