Making a command the default command for the 2020 Wpilib

So my team is switching over from timed based code to command based code, and we have set up the subsystem for the drive train and made a drive command class, but we can’t figure out how to make the drive command the default command for the drive train subsystem.

In the new command-based system, you don’t need to set a default command for a subsystem. You can schedule the command in

If you need to set a default command use this
CommandScheduler.getInstance().setDefaultCommand(exampleSubsystem, exampleCommand);

I don’t know where you’re getting this idea - the function of default commands has not changed substantially between the old command-based framework and the new one. They’re still useful for exactly the same sorts of things as they were before.

I’d highly recommend going through some example code of the new framework to see how some of the past year’s robots have been implemented in the new framework.

The Gearsbot Example is nice and thorough with multiple subsystems, commands bound to buttons, scheduling default commands, etc.

1 Like

We are setting it in robot init. Working well.

  public void robotInit() {

    RobotMap.init(); // initializes Robot Map - stores constants


    driveTrain = new DriveTrain();
    shifter = new Shifter();

    oi = new OI();

    driveTrain.setDefaultCommand(new OpenLoopDrive());
    shifter.setDefaultCommand(new AutoShift());


Note that in the the new framework subsystems instantiation should happen in

Thanks I got it working.

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