Team 254's 2024 FRC robot code for Vortex. Vortex's code is written in Java and is based off of WPILib's Java control system.
The code is divided into several packages, each responsible for a different aspect of the robot function. This README explains setup instructions, the function of each package, and some of the variable naming conventions used. Additional information about each specific class can be found in that class' Java file.
- Clone this repo
- Run
./gradlew
to download gradle and needed FRC/Vendor libraries - Run
./gradlew tasks
to see available options - Enjoy!
- Get the WPILib extension for easiest use from the VSCode Marketplace - Requires Java 11 or greater
- In
.vscode/settings.json
, set the User Setting,java.home
, to the correct directory pointing to your JDK 11 directory
- Run
./gradlew idea
- Open the
FRC-2024-Public.ipr
file with IntelliJ
- Run
./gradlew eclipse
- Open Eclipse and go to File > Open Projects from File System...
- Set the import source to the
FRC-2024-Public
folder then click finish
- Run
./gradlew deploy
to deploy to the robot in Terminal (*nix) or Powershell (Windows) - Run
./gradlew build
to build the code. Use the--info
flag for more details - Run
./gradlew test
to run all of the JUnit tests
- To simulate the robot run
./gradlew simulateJava
- You will need to configure your keyboard settings for 1 Xbox Controller.
- To set up 3d visualization in AdvantageScope, import the Advantage_Scope.json.
- If the JSON import does not work, you need to set up a 3D tab as follows:
- 3D Poses: Robot (components) : NT: "ComponentsPoseArray"
- 3D Poses: Robot : NT: "Drive/Viz/Pose3d"
- 3D Poses: Note : NT: "NoteVisualizer"
- If the JSON import does not work, you need to set up a 3D tab as follows:
-
Controller Modes
The robot uses controller modes to modify the controller's controls based on the modal control. The following modes are used:
- NOT_SPECIFIED - Allows for intaking and shooting against the subwoofer, used if any problem occurs during the match
- SPEAKER - Ground intake and aims at speaker at all times, adjusting both the turret and hood based on location
- HP - Source intake by raising the elevator, poops following the same logic as POOP mode
- POOP - Ground intake, poop pose generated based on obstacles and location
- Line-Drive - when close to poop point without stage in the way
- Shallow vs Deep Amp Lob Pass - changes location of lob pass based on controller input
- CLIMB - raises climb arms, stages amp and elevator for trap, then climbs
-
Branching Auto with Choreo
In autonomous, the robot uses Choreo and branching autos to customize each autonomous based on multiple selectors. At the midline, the robot decides between switching to another note if it did not pick up the current note, scoring the note and going to the next note, or initiating the last action. The following selectors are used before the match:
-
Starting Location - starting location of the robot, including Truss, Speaker, Source, SpeakerCorner, Amp
-
First Action - first action of the robot, including Three Close to Midline, One Close to Midline, Sprint to Midline, and Sprint to Midline No Preload
-
Priority Midline Sequence - sequence of midline notes to target in order, such as ABC, BAC, and EDC. A is the note closest to the Amp, and E is closest to the Source.
-
Last Action - last action of the robot, including Backoff, Score Preload, and Three Close
-
Blocked Notes - Midline notes that the robot should not branch off to - used if another robot in the alliance is targeting other notes
Choreo is used to create all our paths (Open .chor file in Choreo), including midline note-to-note branching, scoring, and first and last actions. Paths to midline notes are interrupted when the intake banner sensor is triggered.
-
-
AdvantageScope Simulation
We used AdvantageScope to simulate subsystem movements and test new software, especially autonomous paths, without the need for the robot. We also visualized logs and live robot telemetry, including note projectile simulation. We imported the robot 3D model with a fully articulating Turret, Hood, Amplifier, and Climber, along with accurate moments of inertia and gear ratios to accurately visualize robot actions.
We also used AdvantageKit to log all important data to replay after each match. This included vision estimates, robot state values, and subsystem values. This helped to isolate issues after the match, including localization and other robot malfunctions.
-
Auto-Aiming to Goal
Our robot auto-aligns the hood and turret to goal in both Poop mode and Speaker mode. In poop mode, we calculate the optimal hood and turret setpoints to reach the target poop pose, considering the constraints of the hood and the desired apex height. In speaker mode, we determine the note launch speed based on the distance from target, and use motion and lift compensation to accurately represent the note’s trajectory when the robot is in motion. We wait until all subsystems are on target for goal before releasing, including the shooter RPS, the turret position, and hood position.
-
Contains the robot's central functions and holds a class with all numerical constants used throughout the code (see
Constants.java
). For example, theRobotContainer
class controls all routines depending on the robot mode. In addition, theRobotState
class keeps track of the current position of the robot's various frames of reference. -
com.team254.frc2024.command_factories
Contains all command factories with methods that call groups of subsystem commands.
-
Contains all autonomous commands and other complex subsystem commands.
-
com.team254.frc2024.controlboard
Contains code for the driver to use either joysticks with operator gamepad or single gamepad. Also contains modal controls to switch between controller modes.
-
com.team254.frc2024.simulation
Contains code for simulated robot state, including the note state and robot position.
-
com.team254.frc2024.subsystems
Contains the code for all subsystems. Each subsystem extends
ServoMotorSubsystem
and includes an simulation and hardware interface for I/O operations. -
Contains auto utility class to generate autonomous trajectories and commands.
-
Contains forked CTRE swerve classes for custom drive configs.
-
Contains CAN device ID class, pairing device number and bus name.
-
Contains Limelight helpers class for reading from NetworkTables.
-
Contains all motion profiling code used for autonomous driving. Trapezoidal motion profiles are used for smooth acceleration and minimal slip.
-
Contains a thread loop for running a set of callbacks at a Hz driven by the update frequency of CTRE Status Signals.
-
Contains forked Pathplanner classes improve PID controller, velocity feedback, and acceleration feedforward.
-
Contains servo motor subsystem template to be extended by all subsystems.
-
Contains robot time.
-
Contains a collection of assorted utilities classes used in the robot code. Check each file for more information.
- k*** (i.e.
kDriveWheelbaseMeters
): Final constants, especially those found in theConstants.java
file