Team-OKC-Robotics / FRC-2022-CPP

a c++ port of our FRC-2022 code as training in C++
Other
0 stars 2 forks source link

Create a SwerveModule class #32

Open danielbrownmsm opened 1 year ago

danielbrownmsm commented 1 year ago

Summary Initially in issue #11 (Add Swerve Drive Support), I didn't think we needed a SwerveModule class, as we could go without it, and I didn't really feel like writing one/know what would be in one. Coding further into it though, especially using the WPILib swerve drive support and following the example code, a lot of repetitive and not-very-fun-to-read code could be simplified using a SwerveModule class. The class should have getters and setters for all the WPILib swerve odometry and kinematics stuff (SwerveModuleState, SwerveModulePosition, etc), PID controllers for turn and steer, parameter loading support, and sensible default values.

Unsure whether to write a specific unit test for the SwerveModule class, as that seems like it would get tested in the SwerveDrive subsystem tests anyways. Might be worth it though.

Work Required

Verification

jkleiber commented 1 year ago

Just as a note, its probably easier to write unit tests for the SwerveModule class than the entire subsystem, and imo would be quite valuable since subsystems are harder to test (due to some functions being real time)