Skip to content

Refactor swerve drive, add unit tests, and merge latest main - #8

Closed
Ernie3 wants to merge 18 commits into
mainfrom
cursor/swerve-drive-refactor-mr-256b
Closed

Ernie3 wants to merge 18 commits into
mainfrom
cursor/swerve-drive-refactor-mr-256b

Conversation

@Ernie3

@Ernie3 Ernie3 commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Refactors swerve drivetrain code for clarity and testability: DriveCommands, extracted kinematics/dynamics/optimization, FieldConstants, and HID teleop helpers. Includes merge of latest main. No intentional change to wired teleop, PathPlanner autos, or Limelight odometry — D15 regression still required before merge.

Head: cursor/swerve-drive-refactor-mr-256b (cloud-agent branch; same work stream as refactor/swerve-drive-and-tests)

What changed

  • SwerveDrive / SwerveModule: hardware and control loops; Supplier<Rotation2d> for gyro heading (production: () -> kNavx.getRotation2d() in RobotContainer)
  • DriveCommands: teleop, go slow, defense hold-heading, practice reset, stop, lock (moved out of the subsystem)
  • DemonCommandXboxController + HIDUtils: shared stick deadband/cubic scaling (replaces SwerveTeleopInputs)
  • Tests: expanded unit/sim suite (SwerveDriveTest, DriveCommands integration, motion/optimization/dynamics); SwerveDriveTestFixture + resetBetweenTests(); JUnit random method order (MethodOrderer$Random)
  • Docs/rules: Arrange–Act–Assert in frc-unit-tests.mdc; AGENTS.md points at test and cloud setup
  • Cloud install: PathPlanner + Elastic on agent Desktop via .cursor/cloud-install.sh (roboRIO deploy unchanged)
  • CI: mavenCentral() in settings.gradle for Gradle plugin resolution

Driver / auto impact

Behavior-preserving for what is wired today: default field-relative teleop, go-slow, defense heading hold, practice reset (1.016 m, 4.0 m), boot odometry seed, PathPlanner AutoBuilder, named command STOPSwerve, Limelight pose fusion. Unused swerve-only helpers removed (not referenced from RobotContainer or deploy autos).

Test plan

  • ./gradlew test / ./gradlew build (GitHub CI)
  • Deploy to D15
  • Teleop: drive, go-slow, defense hold-heading, reset heading
  • Auto on cart: at least one PathPlanner auto; confirm STOPSwerve if your routines use it
  • Optional (cloud Desktop): ./gradlew simulateJava, elastic / pathplanner after environment build
Open in Web Open in Cursor 

Ernie3 and others added 3 commits October 18, 2026 22:44
Split commands from SwerveDrive, extract dynamics and module optimization, and add pure and simulation unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
@Ernie3 Ernie3 added the refactor Improvements without affecting existing end user behavior label Oct 19, 2026
cursoragent and others added 9 commits October 19, 2026 13:20
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Expand frc-unit-tests.mdc with AAA conventions; mention in AGENTS.md.
Add section comments across HID, drive, and constants tests.

Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Break RobotContainer static init cycle with Supplier<Rotation2d>.
Skip PathPlanner in tests; add SwerveDriveTest and sim test helpers.

Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Add SwerveDriveTestFixture (shared sim instance), 13 subsystem tests,
6 command integration tests, HAL init guard, and test ordering fixes.

Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Module positions, vision heading std devs, goSlow scaling contract,
DriverStation sim alliance sign; strengthen goSlow unit test.

Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Remove per-class fixture teardown that broke other classes, drop duplicate
CommandScheduler registration, reset shared sim state between methods, recreate
Xbox sim controllers after DriverStation reset, and enable random test order in CI.

Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
@cursor cursor Bot changed the title Refactor swerve drive, add unit tests, and merge latest main Refactor swerve drive, extract DriveCommands, expand unit tests Oct 19, 2026
cursoragent and others added 2 commits October 19, 2026 21:56
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
@cursor cursor Bot changed the title Refactor swerve drive, extract DriveCommands, expand unit tests Refactor swerve drive, add unit tests, and merge latest main Oct 19, 2026
cursoragent and others added 3 commits October 20, 2026 00:27
Kinematic module angles from toSwerveModuleStates were fed into the pose
estimator each tick, which can jump during path rotation and unlike main
(which uses measured pivot encoders) caused erratic Field2d heading in
auto. Desktop simulateJava now integrates robot-relative chassis speeds
with transformBy instead.

Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
PathPlanner needs non-zero getChassisSpeeds() and pose that tracks the path.
Kinematic sim reported zero module speeds and open-loop pose integration
desynced from trajectory rotation targets. Auto now uses module physics
odometry like main; teleop keeps chassis-speed integration. Sim gyro uses
simulationHeading instead of NavX; skip vision fusion in simulateJava.

Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
Restore drive and RobotContainer to e3b3d1d before the two recent
simulateJava pose-integration commits that were pushed prematurely.

Co-authored-by: ernestgwilsoniii <ernestgwilsoniii@gmail.com>
@Ernie3 Ernie3 closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Improvements without affecting existing end user behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants