Command-based Java robot code for a swerve-drive robot with shooter, hopper, intake, AprilTag vision, PathPlanner autos, Elastic telemetry, and desktop simulation.
- Drive: four MAXSwerve modules, SparkFlex drive motors, SparkMax steering motors, and a Pigeon 2 gyro.
- Shooter: two SparkFlex NEO Vortex motors (CAN 13 leader, CAN 14 follower) with closed-loop flywheel speed control.
- Hopper: one SparkMax feeder motor (CAN 12).
- Intake: roller motor (CAN 11) and lift motor (CAN 10).
- Vision: three PhotonVision cameras that fuse valid AprilTag estimates into drivetrain pose estimation.
- Left stick: field-relative translation
- Right-stick X: rotation when hub tracking is disabled
- Right stick press: X-stance
- Right bumper: enable hub tracking
- Left bumper: disable hub tracking
- Start: zero gyro heading
- Back (disabled, wheels straight forward): save swerve module offsets
- A: launch at the selected RPM once the shooter reaches speed
- B: eject intake, hopper, and shooter
- Right trigger: run intake roller
- Left bumper: outtake roller
- X / Y: deploy / retract intake lift
- Right bumper: spin shooter only
- D-pad left / up / right: close / medium / distance shooter presets
- Back (disabled, intake physically retracted): zero the intake lift encoder
PathPlanner assets live in src/main/deploy/pathplanner. The Elastic chooser exposes only the vetted competition autos; edit COMPETITION_AUTO_NAMES in RobotContainer when approving a new routine. The PathPlanner named commands are:
DeployIntake,RetractIntake,StartIntake,StopIntakeSpinUpShooter,Shoot,StopShooter
Timed autonomous shooting uses PathPlanner deadline groups so a shot is stopped cleanly when its wait duration ends.
Every event marker must contain a named-command payload. A marker name alone is only an EventTrigger; this project intentionally uses direct named commands in the path files.
Before enabling the robot:
- With the robot disabled, point all four swerve wheels straight forward and press driver Back once. The offsets are saved persistently on the roboRIO.
- With the robot disabled, physically retract the intake lift and press operator Back once. Automatic lift motion is blocked until this is done on real hardware.
- Confirm
Drive/Module Offsets CalibratedandIntake/Lift Calibratedin Elastic.
The 2026 hub status on the dashboard follows Driver Station Game Data and match-time shifts. It is informational; shooter controls remain under operator control.
The current PathPlanner mass and moment of inertia are derived from the drivetrain's 54 kg, rectangular bumper model. Re-measure those values after significant robot changes and update both the constants and PathPlanner settings together.
Use the WPILib 2026 toolchain with Java 17.
# macOS / Linux
chmod +x gradlew
./gradlew build
./gradlew deploy
./gradlew simulateJava
# Windows
gradlew.bat buildThe team number is configured in .wpilib/wpilib_preferences.json.
Constants.java: drivetrain geometry, CAN IDs, operator ports, and field targetsShooterConstants.java: flywheel gains, presets, and distance-to-RPM tableHopperConstants.java: feeder gains and speedIntakeConstants.java: intake/lift voltages and lift positionsVisionConstants.java: camera names, transforms, and validation thresholdssrc/main/deploy/pathplanner/settings.json: PathPlanner physical model; keep its module locations, gearing, motor type, speed limit, mass, and MOI aligned with the real robot
Validate all mechanism limits, camera transforms, and shot presets on the real robot before competition use.