The 2026 Spectrum robot codebase is organized into three distinct layers that work together to keep hardware concerns, robot-specific configuration, and high-level behavior cleanly separated. Understanding these layers makes it straightforward to add new mechanisms, tune existing behavior, or trace a control flow from a button press all the way to a motor command.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/spectrum3847/2026-Spectrum/llms.txt
Use this file to discover all available pages before exploring further.
Three-layer architecture
Layer 1: SpectrumLib
SpectrumLib is a collection of reusable base classes that any Spectrum robot can use without modification. The most important pieces are:SpectrumRobot— extends WPILib’sTimedRobot. It maintains a list of all registeredSpectrumSubsysteminstances and callssetupDefaultCommand()andsetupStates()on each one when the robot transitions between modes.SpectrumSubsystem— a thin interface on top of WPILib’sSubsystemthat requires implementors to declaresetupStates()andsetupDefaultCommand().Mechanism— an abstract class that wraps a CTRE TalonFX leader motor plus optional permanent follower motors. It provides cached sensor reads, standard control mode helpers (Motion Magic, velocity, voltage, torque current), and trigger factories for position and velocity thresholds.Rio— reads the RoboRIO serial number at startup and returns the matchingRioenum constant, which the robot uses to select the correct hardware configuration class.CachedDouble— aDoubleSupplierwrapper that computes its value at most once per scheduler loop iteration, avoiding redundant CAN reads when the same sensor is consulted by multiple triggers.
Layer 2: Robot subsystems
Robot.java is the single source of truth for every live subsystem instance. All subsystem fields are public static and are constructed in the Robot constructor in a deliberate order, with a short CAN initialization delay between each mechanism:
Robot.Config class, whose fields are overridden by the appropriate robot-specific config class (FM2026, PM2026, etc.) before any subsystem is constructed:
| File | Role |
|---|---|
FuelIntake.java | Hardware wiring, sensor reads, command factories |
FuelIntake.Config | Inner config class — CAN IDs, PID gains, limits |
FuelIntakeStates.java | Named commands and trigger bindings for this subsystem |
Layer 3: Coordination
High-level robot behavior lives in three classes that communicate through the WPILib command scheduler:State— a Java enum that names every possible robot-level mode (IDLE,INTAKE_FUEL,TRACK_TARGET,LAUNCH_WITH_SQUEEZE,UNJAM, etc.).Coordinator— contains a singleapplyRobotState(State state)method. Each case in itsswitchstatement sends exactly one command to each relevant subsystem simultaneously.RobotStates— binds gamepad triggers, autonomous event markers, and zone triggers toapplyState()/clearState()calls that drive the coordinator.
pilot.RT), the following chain executes:
How modes interact
Robot.java calls resetCommandsAndButtons() at the start of disabled and teleop modes. This method cancels all running commands, clears all button bindings, then re-runs setupStates() on every registered SpectrumSubsystem and calls RobotStates.setupStates() to re-bind every trigger. This ensures clean state transitions between match phases without leftover commands or stale bindings.
Robot states
How the State enum, RobotStates triggers, and Coordinator fan out commands to subsystems.
Subsystems and mechanisms
SpectrumSubsystem, the Mechanism base class, CachedDouble, and trigger factories.
Multi-robot configs
How Rio ID-based config selection loads different hardware parameters per robot.
