-
Notifications
You must be signed in to change notification settings - Fork 6
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
-
Navigate to RobotContainer.java
-
Create a new, private final variable of type Command. This will store our autonomous.
private final Command lowBalance
-
Set the command to a new instance of a pre-existing command.
private final Command lowBalance = new SetElevatorTargetCommand(Constants.bottomElevatorTargetPosition, true, elevator);
-
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
-
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<>()
-
Create a method inside RobotContainer.java called addAutoChoicesToGui, like so:
private void addAutoChoicesToGui()
-
For the default autonomous option, inside addAutoChoicesToGui, do:
autoChooser.setDefaultOption("Default Name", defaultAutonomous);
-
For each other autonomous option, do the following:
autoChooser.addOption("Autonomous Name", autonomousCommand);
-
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.
-
Lastly, add the following method to RobotContainer.java:
public Command getAutonomousCommand() { return autoChooser.getSelected(); }
Configuring an auto
You will need to register all the commands in Autonomous.java in public void registerNamedCommands(), then you can register them with
NamedCommands.registerCommand("Ex: Intake", new IntakeCommand(Intake, anything else you want to run with the intake));Then you need to use registerAutosAsNamedCommands(), somewhat like this:
private void registerAutosAsNamedCommands()
{
for (String auto : AutoBuilder.getAllAutoNames())
NamedCommands.registerCommand("Auto " + auto, getPathPlannerAuto(auto));
}After that you need to get pathplanner with the auto you need to use a method with the command pathFindThenFollowPath() command like this:
protected static Command followPath(final String PathName)
{
final PathPlannerPath path = PathPlannerPath.fromPathFile(PathName);
return AutoBuilder.pathfindThenFollowPath(path, SwerveConstants.PathConstraints);
}You may also need to get the pathplanner auto and you can use something like this:
protected static Command getPathPlannerAuto(final String PathName)
{
return new PathPlannerAuto(PathName);
}And finally you need to build the auto command using something like this
public abstract Optional<Command> buildAutoCommand();This is an officially licensed product of Team 4026. Decatur Robotics 2024 is not sponsored by any other Team, and is not responsible for any damages caused by using this product or trusting the programming team, which is by far the least most trustworthy team(Shadow owen money gang, we love coding the robot). By using this product, you are consenting to your information, and thus your identity to be stolen and first-born child taken.
- Editing Documentation & Markdown Syntax
- Code Team to-do List
- Code Standards
- Common Library Structure
- Interfaces
- General Setup
- Branching System
- How to Create Pull Requests
- How to Switch Branches
- Code Reviews
- Reverting Commits
- Singleton Pattern
- Software Installations
- Necessary IntelliJ Plugins
- Vendordeps
- Setting Up New Projects
- Autoformatter Set Up
- Showbot Requirements
- Autonomous
- Calling a Command Based on a Button Press
- CAN
- Clearing Sticky Faults
- Current Limits
- PID Config and Usage
- Robot.java, TeleopInit, DisabledInit
- RoboRio Ports
- SetDefaultCommand
- Wait for Time
- SlewRateLimiter
- LEDs
- InstantCommand
- PhotonVision
- Apriltags
- Camera Display on Shuffleboard
- Object Detection
- Raspberry Pi
- Network Tables
- List of Network Tables (2023)
Up to date as of SJ2, end of 2023 season