New Command Base - ConfigureButtonBindings does not work

When using the New Command Base, I was able to set up a simple Arcade Drive using the WPILIB. However, when trying to call any commands that were mapped to a button under ConfigureButtonBindings, it simply does not work. The code complies and deploys without errors, but once being operated with the XBOX Controller, the buttons simply do not perform the command. Any thoughts? The XBOX Controller does work because the robot is able to drive after defining the defaultCommand(), but any other Commands are not being performed when the correct button is pressed.

Are you calling the configureButtonBindings() method in the constructor of the RobotContainer?

I believe so:

Both occurrences have been c++. I wonder if this is a bug in Java too.

Can you please post your ConfigureButtonBindings function?


I can upload the entirety of the Project to github if that would better allow you to help troubleshoot

Please upload it if you have that capability.

Doing so now, will post a link shortly

Sorry for the delay: https://github.com/HuGGhes5/InfiniteRecharge2020

Welp, this appears to be a major bug in the C++ command library; our test coverage only handles the Trigger class because we don’t presently have test stubs for our joystick classes.

Unfortunately, since the mutable lambda passed to the CommandScheduler from Trigger captures *this, it slices the class and thus the virtual method defined by the subclasses of Trigger is discarded. I’m writing a fix now which passes the subclass conditions back to the base class as a functor instead, which should be robust to this.

Surprised none of the beta teams caught this :frowning:

A functional WPILib C++ (beta4) wasn’t releasd until midway through December. All test tasks where supposed to be completed before Dec. We wanted to hammer away at testing the new command based but the timing of the release prevented this from happening.

Beta 1 and 2 crashed
Beta 3 dead locked.

Is there any attention being given to this issue? I was only able to find one other post on the forum having this issue which makes me think it is not well-known. I would like to be able to use C++ without having to implement a work-around.

Will you be posting your workaround? Until it is fixed within WPILib, I would like a fix to the issue.

He isn’t working around it but fixing it internally. It’ll be fixed in the next WPILib release.

A temporary workaround is to just pass a lambda returning the button state to an ordinary Button class.

Can you provide an example?

frc2::Button([&driver_controller] { return driver_controller.GetRawButton(1); })

Thank you for the example, I had to change &driver_controller to “this”. I’m not exactly sure why, but it is able to function now when changed.

frc2::Button([this] { return driver_controller.GetRawButton(1); })

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.