This is example/practice FRC robot code for the 2026 season, built around a swerve
drivetrain. It's not the real competition code for any specific team — the team number
in Constants.java (9999) is a placeholder. Think of it as a reference project for
trying out an architecture, not something pulled straight off a competition robot.
The robot has a swerve drivetrain, a 4-flywheel shooter with a feeder stage, a pivoting intake with its own roller, and a Limelight for vision-assisted aiming. All of it runs through AdvantageKit so every subsystem's inputs get logged and can be replayed later, and every subsystem works the same way whether it's driving real hardware or running in simulation.
-
AdvantageKit logging — every subsystem talks to its hardware through an
IOinterface with areadInputs(...)method and an@AutoLog-annotated inputs class.Logger.processInputs(...)runs once per subsystem per loop, so every input value is automatically logged and, in replay mode, can be fed back in from a.wpilogfile instead of read from real hardware. -
IO / Hardware / Sim split per subsystem — each subsystem (
drive,shooter,intake,feeder,vision) has:XxxIO— the interface +@AutoLoginputs classXxxIOHardware— talks to the real motor controllers/sensorsXxxIOSim— simulation behavior (for most subsystems here, this is a simple kinematic stand-in rather than a full physics model — see the comment at the top of eachXxxIOSimclass for what it actually does and doesn't model)
RobotContainerpicksXxxIOHardwareorXxxIOSimbased onRobotBase.isReal(), and nothing above the IO layer needs to know or care which one it's talking to. -
CTRE generated Swerve API — the drivetrain doesn't use a hand-rolled
SwerveModuleclass. Instead it uses CTRE's Tuner X code generator output:generated/TunerConstants.java(CAN IDs, gear ratios, PID gains, module offsets) andsubsystems/drive/CommandSwerveDrivetrain.java(the actual swerve drivetrain implementation, including odometry, vision fusion, and SysId routines). Both files are meant to be regenerated by Tuner X, not hand-edited. -
RobotState— a small singleton holding the current estimated pose.DriveSubsystemupdates it every loop;VisionSubsystemreads it to tell the Limelight the robot's current heading (needed for MegaTag2); anything else that ends up needing pose (autos, aim-while-move, whatever gets added later) can just pull from here instead ofDriveSubsystemgetting passed around everywhere. -
commands/vsfactories/— commands with their own state machine (timers, internal booleans, multi-stage behavior) live incommands/as their own class, e.g.AlignShootCommand. Everything else — bindings that are just a couple of subsystem method calls wrapped inCommands.runOnce/Commands.startEnd/etc. — lives infactories/as static methods, soRobotContainer.configureBindings()stays a short, readable list of "this button does that."
src/main/java/example/robot/
├── Constants.java team number + all per-subsystem constants
├── Main.java, Robot.java WPILib entry point / AdvantageKit setup
├── RobotContainer.java wires up subsystems + button bindings
├── RobotState.java shared pose singleton
├── controlboard/ Xbox controller bindings
├── commands/ multi-step / stateful commands
├── factories/ simple command compositions per subsystem
├── generated/TunerConstants.java CTRE Tuner X generated swerve config
├── lib/LimelightHelpers.java vendored Limelight NetworkTables helper
└── subsystems/
├── drive/ CommandSwerveDrivetrain + DriveIO/Hardware/Sim + DriveSubsystem
├── shooter/ 4 flywheels + feeder, IO/Hardware/Sim + ShooterSubsystem
├── intake/ pivot + roller + beam break, IO/Hardware/Sim + IntakeSubsystem
├── feeder/ open-loop roller stage, IO/Hardware/Sim + FeederSubsystem
└── vision/ Limelight MegaTag1/2, IO/Hardware/Sim + VisionSubsystem
src/test/java/example/robot/ pure-math unit tests (no HAL required)
| Subsystem | Hardware | Notes |
|---|---|---|
| Drive | CTRE swerve modules(MK5N), Pigeon 2 | Field/robot-centric driving, PathPlanner autos, vision pose fusion |
| Shooter | 4× Kraken X60 flywheel, 1× feeder motor | Velocity PID + feedforward, all 4 flywheels driven together |
| Intake | Kraken X60 pivot (position PID), Kraken X44 roller | Beam-break sensor for note detection, deploy/stow toggle |
| Feeder | 1× roller motor | Open-loop duty cycle, sits between intake and shooter |
| Vision | Limelight | MegaTag1 + MegaTag2 pose estimates, fused into the drive pose estimator with different trust levels |
Driver Xbox controller only, all bindings live in ControlBoard/RobotContainer:
| Input | Action |
|---|---|
| Left stick | Drive (field-relative X/Y) |
| Right stick X | Rotate |
| Y | Zero heading (reset "forward") |
| B | Toggle intake deploy/stow |
| Left trigger (held) | Run intake roller |
| Right trigger (held) | Vision-assisted aim + shoot (spins up shooter, feeds automatically once at speed, pulses the intake to feed extra notes) |
| Right bumper (held) | Manual shot (no vision aim, just spin up + feed) |
- AdvantageKit — logging/replay framework
- Phoenix6 — CTRE motor controllers + the generated swerve API
- PathplannerLib — autonomous path following
- WPILibNewCommands — command-based framework
Requires the 2026 WPILib toolchain (GradleRIO handles the rest).
./gradlew build # compile everything
./gradlew test # unit tests (pure math, no HAL required)
./gradlew simulateJava # run in WPILib sim
This is a work in progress — several constants (PID gains, gear ratios, setpoints) are
placeholders or guesses that still need to be tuned/verified on real hardware. See the
comments in Constants.java for specifics on which ones and why.
MIT — see LICENSE. Includes files derived from WPILib, licensed separately under BSD 3-Clause — see WPILib-License.md.
-by Deipedra