frc538 / 2020-infinite-recharge

Robot code for FRC Team 538.
0 stars 0 forks source link

Hook up the default command for driving. #6

Closed drewwhis closed 4 years ago

drewwhis commented 4 years ago

This depends on #5

drewwhis commented 4 years ago

When we create commands, there are a few steps we want to follow. These are slightly different for default commands, so we'll look at regular commands on a separate task (#14)

drewwhis commented 4 years ago

To set up a default command, we want to do that in the constructor of the RobotContainer. For this particular command, we want to make sure the driver control has been created, first.

  1. Create the driver controller. For example, private final Joystick mDriverOneController = new Joystick(0);.
  2. Reference the subsystem to set its default command. In this case, mDriveSubsystem.setDefaultCommand();.
  3. Inside the parentheses, we need to create the command. In this case, mDriveSubsystem.setDefaultCommand(new DriveCommand());.
  4. For the drive command to have access to the subsystem and the joystick, we need to pass those values in. In this case, mDriveSubsystem.setDefaultCommand(new DriveCommand(drive, joystick));.

A similar process would be followed for any other subsystem that needs a default command. The default command runs when no other command is using the subsystem.

One key for a default command vs. other commands is that the default command's isFinished should always return false.

drewwhis commented 4 years ago

Breanna and Maison knocked this out on Saturday.