Project Conventions¶
- WPILib Command-Based Java project.
- Coordinate frame: WPILib standard. +X forward, +Y left, +θ counterclockwise (viewed from above).
- Module order: front-left, front-right, back-left, back-right. Keep this order everywhere.
- Constants live in
Constants.java, grouped by subsystem. - Log values to NetworkTables (for AdvantageScope / Glass) from the start: desired vs. actual module states, chassis speeds, pose.
Coordinate frame¶
+X (forward)
^
|
FL ● | ● FR
|
+Y <----------+ (robot center)
(left) |
|
BL ● | ● BR
Positive rotation is counterclockwise when viewed from above.
Project structure (grows lab by lab)¶
Constants.java // ratios, dimensions, offsets, gains (Lab 0 on)
subsystems/
SwerveModule.java // one module, through ModuleIO (Lab 0 on)
SwerveSubsystem.java // 4 modules, kinematics, gyro, odometry (Lab 0 on)
sim/ // GIVEN: the simulated robot
ModuleIO.java, GyroIO.java // hardware-abstraction interfaces
ModuleIOSim.java, GyroIOSim.java // simulated hardware
SimWorld.java // physics + true pose
ModuleIOSparkMax.java // real hardware (Lab 11)
lib/
Tunable.java // live dashboard knobs and toggles (Lab 0)
MyModuleOptimizer.java // students (Lab 4)
MyKinematics.java // students (Lab 5)
MyFieldRelative.java // students (Lab 7)
MyOdometry.java // students (Lab 8)
src/test/java/... // JUnit tests comparing ours vs WPILib
Dashboard keys: Tune/... for knobs and toggles (Tune/Sim/... for the simulator's), Swerve/... for logged values, Sim/... for the simulator's ground truth.
Units¶
Use SI units internally: meters, radians, m/s, rad/s, seconds. Name variables with units when ambiguous (angleRadians, velocityMetersPerSecond).