We’re having trouble programming buttons to our commands. Our drive train is working perfectly and have made a few commands and subsystems but when we go and press the button such as (A) which should activate the command “ConveyorBall()” nothing happens.
If anyone could take a look at our GitHub and give us some help that’d be amazing!
Why the custom XboxController? I assume it’s legacy code. WPILib provides an XboxController class already. Also, your toggle* methods don’t appear to actually do anything other than set a local boolean value.
You shouldn’t create local instances of your Commands. They’re intended to be short-lived objects, and their lifespan should be determined by the JoystickButton method (whileHeld, whenPressed, etc) you’re passing it into.
As for your actual issue, @eddieD is partially correct. Since you’re using the “old” command-based format, that method is individually listed in disabledPeriodic, autonomousPeriodic and teleopPeriodic, though robotPeriodic should work fine as well.
I’m very new to programming and was having trouble using the WPILib Xbox Class so I am using Team 4944’s Skeleton program to help me get started. Any ideas to make anything work smoother I’m up to hearing!
I am pretty sure if you just copy that code and put it in your Robot.java it will fix your issue.
However, @Fletch1373 is correct, you should consider switching to using the WPILib XboxController. There is a bunch of documentation on using that. If you have specific questions about using it let me know.
Trying to convert it over to the new wpilib XboxController but can’t find any help online with creating buttons in my OI. All I can find is JoystickButton
From what I’m seeing online it’s telling me to set it up like this.
public XboxController driver, operator;
public Button aButton;
public OI() {
// Controllers
this.driver = new XboxController(0);
this.operator = new XboxController(1);
// Commands
// A -- TEXT HERE (Driver)
aButton = new Button(1);
aButton.whileHeld(new ConveyorBall());