Confused about how Command Based works

I’m building my first command based robot and I have the code to make it drive with arcademode and spin with the push of a button.
I understand how the spin works - the button triggers an event- but how does the arcade mode work?

I don’t have it set in any teleop commands in or anything so I’m confused as to how the commands get called… Should I have somthing like that in teleop?

I have been doing this off a new tutorial.

I guess I’m just wondering how commands get called in Command Based and how my Arcade one is supposed to be called. This will help me in the future when creating new ones…


My code

Each subsystem can declare a default command that is run any time another command is not running. This is most useful for drive commands, as you mentioned, because you typically always want your robot to be able to drive when nothing else is happening. For more details, read through the screensteps article about default commands.

OK then what calls the subsystem??

When you construct the subsystem, it is registered with the Scheduler object (source). The Scheduler object is what actually calls all commands, and manages things like required subsystems and default commands. In, you’ll notice that the auto-generated code contains Scheduler.getInstance().run(); in most of the init and periodic methods. Without this statement, none of the commands would be able to run, as it is within that statement that the Scheduler will manage and run each of the running commands. This includes calling execute() on all running commands, checking for finished commands with isFinished(), starting new commands by calling init(), ensuring that only one command requiring each subsystem is running, and starting the default command if none other from that subsystem is running.

If you haven’t already, read through all of the documentation in the screensteps documentation. It explains the basics of how command based programming works. You can also read through the source code and learn more about how it works underneath your code.

I guess I didn’t read your initial question very well. As a quick guide for starting commands:

// creating a default command
// code goes in a subsystem
public void initDefaultCommand() {
    setDefaultCommand(new Drive());

// attaching a command to button actions
// code goes in
Joystick mainStick = new Joystick(0);
Button buttonOne = new JoystickButton(mainStick, 1);
Button buttonTwo = new JoystickButton(mainStick, 2);
Button buttonThree = new JoystickButton(mainStick, 3);
Button buttonFour = new JoystickButton(mainStick, 4);
Button buttonFive = new JoystickButton(mainStick, 5);

public OI() {
    buttonOne.whileHeld(new Spin());
    buttonTwo.whenReleased(new LowerArm());
    buttonThree.toggleWhenPressed(new Climb());

    Command liftArm = new LiftArm(); // I'm not sure if this is necessary, but it seems like the best practice

// starting commands manually, typically for auto
// probably goes in
Command auto = new AutonomousCommand();

public void autonomousInit() {

We’re having similar struggles. This video helped a ton!

Thanks man, that helped alot, especially the website

Funny enough I was using the videos to make my program but I was just curious as to how the program flow went… Just wondering, was the code he provided enough to drive or do I need to add some kind of wait() thig. I’m wondering because I know motors have that polling thing which I’m not too sure how to work with