Skip to content

About

Java-based FRC robot control system for the 2026 competition season, targeting the WPILib framework with command-based architecture

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Example Robot Code – 2026 Season

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.

Overview

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.

Architecture

  • AdvantageKit logging — every subsystem talks to its hardware through an IO interface with a readInputs(...) 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 .wpilog file instead of read from real hardware.

  • IO / Hardware / Sim split per subsystem — each subsystem (drive, shooter, intake, feeder, vision) has:

    • XxxIO — the interface + @AutoLog inputs class
    • XxxIOHardware — talks to the real motor controllers/sensors
    • XxxIOSim — 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 each XxxIOSim class for what it actually does and doesn't model)

    RobotContainer picks XxxIOHardware or XxxIOSim based on RobotBase.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 SwerveModule class. Instead it uses CTRE's Tuner X code generator output: generated/TunerConstants.java (CAN IDs, gear ratios, PID gains, module offsets) and subsystems/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. DriveSubsystem updates it every loop; VisionSubsystem reads 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 of DriveSubsystem getting passed around everywhere.

  • commands/ vs factories/ — commands with their own state machine (timers, internal booleans, multi-stage behavior) live in commands/ as their own class, e.g. AlignShootCommand. Everything else — bindings that are just a couple of subsystem method calls wrapped in Commands.runOnce/Commands.startEnd/etc. — lives in factories/ as static methods, so RobotContainer.configureBindings() stays a short, readable list of "this button does that."

Project layout

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)

Subsystems

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

Controls

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)

Vendor dependencies

  • AdvantageKit — logging/replay framework
  • Phoenix6 — CTRE motor controllers + the generated swerve API
  • PathplannerLib — autonomous path following
  • WPILibNewCommands — command-based framework

Building and running

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

Status

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.

License

MIT — see LICENSE. Includes files derived from WPILib, licensed separately under BSD 3-Clause — see WPILib-License.md.


-by Deipedra

About

Java-based FRC robot control system for the 2026 competition season, targeting the WPILib framework with command-based architecture

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages