Search lessons

Suggested searches

Browse

Reading Team 1257's 2025 robot code

This walkthrough refers to 2025-Robot at commit 944e460, whose repository contains component-specific license files. GitHub identifies an AdvantageKit license as GPL-3.0; no single top-level LICENSE for all team code was found. We link to the code rather than copying it into this training site. A commit is a snapshot, not proof of what ran at a particular event.

Baseline: build.gradle specifies GradleRIO 2025.3.1 and Java 17. The pinned vendor files list AdvantageKit 4.1.2, REVLib 2025.0.3, Phoenix 6 25.3.1, PathPlanner 2025.2.6, and PhotonLib v2025.2.1. These are historical versions, not a recommendation for a new project.

Follow one cycle

  1. In Robot.java, the constructor configures logging and creates RobotContainer; robotPeriodic() runs the command scheduler. The scheduler is the recurring point where commands and subsystem periodic methods get time.
  2. RobotContainer.java chooses real, simulated, or replay-oriented IO implementations according to mode. For example, the real elevator uses ElevatorIOSparkMax; simulation uses ElevatorIOSim. The same subsystem can therefore consume inputs from different implementations.
  3. In Elevator.java, periodic() updates and logs inputs. setPID() bounds the requested goal using constants, and runPID() checks position, velocity and a limit switch before calling the IO controller. Read conditions carefully: software checks are not a substitute for physical safety design.
  4. In ElevatorIOSparkMax.java, setSetpoint() sets and resets the profiled controller. goToSetpoint() combines PID and feedforward, clamps the sum to ±12 V, and calls setVoltage(); the latter logs desired voltage. Find the encoder conversion and motor configuration before interpreting any measurement.

Try it: Starting with runPID(), trace the calls until voltage reaches the motor. Which values are measured, which are requested, and which are calculated? Draw three columns and put each variable in one. Notice that Elevator.periodic() calls processInputs twice in this snapshot; observe the code rather than assuming the duplicate is intentional.

Drive and autonomous

Drive.java configures PathPlanner's AutoBuilder, updates drive and gyro inputs in periodic(), records setpoints, and includes pose estimation and vision measurement handling. runVelocity() converts chassis motion requests into module setpoints. Compare requested setpoints with measured states before diagnosing tracking.

The container constructs a dashboard chooser and a custom chooser, but getAutonomousCommand() actually returns customAutoChooser.getAutoCommand() in this revision. Read CustomAutoChooser.java and the deployed PathPlanner assets together. The existence of a path does not prove it was selected or executed.

AdvantageScope example comparing four measured and setpoint swerve module vectors in red and blue

WPILib's separate AdvantageScope example displays measured module states in red and optimized setpoints in blue. It is an illustration of the comparison, not a log from this 2025 Team 1257 snapshot. Confirm module order, units and coordinate frame in your own data. WPILib swerve kinematics, FIRST and WPILib contributors, CC BY 4.0.

Logging and replay

Robot.java records build metadata. In real mode it configures a WPILOG writer at /media/sda1/ and an NT4 publisher; simulation writes to sim_logs/; replay reads a selected log and writes a suffixed output. The checked-in sim_logs directory is labeled simulation, not a match recording. To understand actual recorded data, use the separate 2024 log exercise. Verify the selected mode, hardware, storage, and current team procedure before a test.