If you want a button to execute a command you should be doing this in the OI class.
See here for an example:
https://wpilib.screenstepslive.com/s...joystick-input
Basically:
- create a command for each of your actions (or one that takes in a parameter for the "speed" to pass on to the motors).
- In OI, you link the command to execute to a Joystick action on a button (e.g. WhenPressed, WhileHeld, etc.).
- the execute method of your command is just going to call in to the subsystem it requires and call the right setter method that ultimately calls someMotorName.set(speed).
To specifically address your code example, get rid of everything except "Robot.fuelFeederSubsystem.FeederOn();" in the execute method. Then add something like the following to the OI class:
Code:
Joystick myJoystick = new Joystick(0);
Button aButton = new JoystickButton(myJoystick, 5);
...
aButton.whileHeld(new TeleopFeederOn_Command());
Check the
Javadoc for Button to see understand what the different methods for button presses (whileHeld, whenPressed...) do.
The guides for command based programming on
screensteps live are pretty good. You could also use RobotBuilder to generate some example code to see what the "right" way to do it is. And there's also lots of
example code out there to pull from.