Skip to content

Autonomous

Lyndon Warren edited this page Nov 9, 2023 · 7 revisions

Autonomous

Autos are Commands that run during the first 15 seconds of a match. They consist of multiple commands run in a specific order, to tell the robot what to do exactly.

Creating an Autonomous

  1. Navigate to RobotContainer.java

  2. Create a new, private final variable of type Command. This will store our autonomous.

    private final Command lowBalance
  3. Set the command to a new instance of a pre-existing command.

    private final Command lowBalance = 
        new SetElevatorTargetCommand(Constants.bottomElevatorTargetPosition, 
    			true, elevator);
  4. Now you have a complete autonomous

Putting autonomous choices into shuffleboard for match selection

See Shuffleboard Logging for more information regarding Shuffleboard and how we log data

  1. Create a new variable of type SendableChooser, and set it equal to a new sendable chooser. This allows us to select different options in shuffleboard

    SendableChooser<Command> autoChooser = new SendableChooser<>()
  2. Create a method inside RobotContainer.java called addAutoChoicesToGui, like so:

    private void addAutoChoicesToGui()
  3. For the default autonomous option, inside addAutoChoicesToGui, do:

    autoChooser.setDefaultOption("Default Name", defaultAutonomous);
  4. For each other autonomous option, do the following:

    autoChooser.addOption("Autonomous Name", autonomousCommand);
  5. Then, at the end of addAutoChoicesToGui, do:

    shuffleboard.add(autoChooser);

    This does assume that shuffleboard is a ShuffleboardTab. ShuffleboardTab is the class that represents a tab on Shuffleboard.

  6. Lastly, add the following method to RobotContainer.java:

    public Command getAutonomousCommand() {
    	return autoChooser.getSelected();
    }

Clone this wiki locally