Team 254's 2023 FRC robot code for Breakdown. Breakdown'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-2023-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-2023-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
-
Talon Config Verification
The robot uses config verification when a configuration fails to apply for a Talon. New configurations are passed through a checker that re-attempts a failed configuration (determined through Phoenix Pro’s Status Code) several times to ensure that a new config is applied. This is used in any config update for talons, such as configuring drive motors or setting current limits for the laterator in limp mode.
-
Vision Pose Correction
The robot fuses odometry with vision updates to maintain an accurate pose for auto-align and autonomous mode. Vision updates include the timestamp, camera to target (calculated using the Pinhole Camera Model), and the April tag ID to calculate the vision field to robot distance and robot to tag distance. Faulty vision updates are rejected based on the robot’s distance from the tags and its velocity. Odometry drift is corrected by accepted vision updates with an Unscented Kalman Filter to estimate a true pose of the robot’s location.
-
Auto Align
The robot uses Vision Pose Correction and Motion Profiling to optimally move to the closest scoring position. The nearest alignment point for scoring is calculated using the vision-corrected robot pose. Three profile followers for x, y, and theta are created to optimally reach the target point within a deadband. Auto align includes two modes: one to align x, y, and theta, and the other to only align y and theta.
-
Limp Mode
The robot sets low current limits for the laterator when intaking from the feeder, and the ground intake when intaking cubes. These will compress like a spring upon contact with the feeder station and walls, allowing cycle times to be minimized and ensuring that the laterator and ground intake will not break easily.
-
Contains the robot's central functions and holds a class with all numerical constants used throughout the code (see
Constants.java
). For example, theRobot
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. -
Handles the execution of autonomous routines and contains the
actions
andmodes
packages. -
com.team254.frc2023.auto.actions
Contains all actions used during the autonomous period, which all share a common interface,
Action
(also in this package). Examples include driving paths, docking, and scoring game pieces. Actions interact with the subsystems, which in turn interact with the hardware. -
com.team254.frc2023.auto.modes
Contains all autonomous modes. Autonomous modes consist of a list of autonomous actions executed in a specific order.
-
com.team254.frc2023.controlboard
Contains code for the driver to use either joysticks or gamepad and the operator to use a gamepad. Also contains a wrapper class specifically for Xbox controllers (see XboxController.java).
-
Contains codes for loops, which are routines that run periodically on the robot, such as for calculating robot pose, processing vision feedback, or updating subsystems. All loops implement the
Loop
interface and are handled (started, stopped, added) by theLooper
class, which runs at 100 Hz. TheRobot
class has one main looper,mEnabledLooper
, that runs all loops when the robot is enabled. -
Contains the
TrajectoryGenerator
class which contains the trajectories that the robot drives during autonomous mode. EachTrajectory
is composed of a list ofWaypoint
objects and headings. -
Contains the
DriveMotionPlanner
class which controls the drivebase as it follows a trajectory during the autonomous period. -
Contains the
ShootingUtil
helper class which takes in the current target range and robot state and returns parameters for an ideal shot for both stationary and shooting on the move. -
Contains multiple classes representing LED states used in the
Superstructure
class. -
com.team254.frc2023.subsystems
Contains code for subsystems, which are consolidated into one central class per subsystem, all of which extend the
Subsystem
abstract class. Each subsystem uses state machines for control and is a singleton, meaning that there is only one instance of each. Subsystems also contain an enabled loop, a read periodic inputs method, and a write periodic outputs method, which are controlled by theSubystemManager
class. -
Contains classes used for the robot's path following and alternative teleoperated driver modes.
-
Contains a set of custom classes for motor controllers, color sensors, and solenoids for simplifying motor configuration, reducing CAN Bus usage, and checking motors.
-
Contains a set of classes that represent various geometric entities.
-
Contains classes used to construct an Unscented Kalman Filter for noise correction.
-
Contains all motion profiling code used for autonomous driving. Trapezoidal motion profiles are used for smooth acceleration and minimal slip.
-
Contains classes to represent physical states of a swerve drive, a swerve's effective wheelbase, and a DC motor.
-
Contains classes to generate and time parameterize splines for smooth autonomous paths.
-
Contains various drive controllers and classes used for forward and inverse kinematics.
-
Contains multiple classes used for representing and following
Trajectory
objects. -
com.team254.lib.trajectory.timing
Contains multiple classes for generating time-parameterized trajectories that obey physical robot constraints.
-
Contains a collection of assorted utilities classes used in the robot code. Check each file for more information.
-
Contains various classes that help with tracking and storing information about vision targets.
- k*** (i.e.
kDriveWheelbaseMeters
): Final constants, especially those found in theConstants.java
file - m*** (i.e.
mPathFollower
): Private instance variables