Offseason Software
During this past offseason we worked on integrated 6328’s AdvantageKit in to our 2022 codebase. Using the IO structure of AdvantageKit also allowed for us to setup a drivetrain simulation quite quickly. It also has been a major help in debugging issues we had with our REV Radio Power Module and debugging our indexer logic. We’ve really loved using AdvantageKit and AdvantageScope and plan to continue to use it for this season.
Swerve
Our development for Swerve has mostly been done through the simulation, as we haven’t received our swerve modules yet. The code was inspired by 364’s Base Falcon Swerve, but adapted it to NEOs and has also updated it to fit the AdvantageKit framework. Because we are using SparkMAXes there is currently a ~112 ms delay on velocity measurements, which can cause difficulty for precise control. As of right now, we are planning on using the newest SparkMAX update that will let us reduce the delay on velocity measurements.
You can check out the code here: GitHub - pittsfordrobotics/REVSwerve2023: Development on new REV swerve modules
We also kept the new AdvantageKit structure that we adopted during the summer allowing us to set up a simulation structure from 6328, using flywheel simulators to simulate a swerve module.
Second Order Kinematics
While testing in the simulation, we found that the robot would skew when rotating and translating at the same time. This effect can be seen in the video below.
A solution that we decided we wanted to try out was second order kinematics. A paper that was released a while ago detailed the math that would be needed to perform these second order kinematics. We also had some help from Rembrandts in this thread. The results are quite good, as you can see below.
This is done through a custom class we created called BetterSwerveModuleState, which adds second order kinematics to the WPI SwerveKinematics. This classes uses the math from the paper to determine an omega value that we can use in addition to a feedforward value to eliminate skew when rotating and translating. We also made a BetterSwerveModuleState, which extends upon the WPI SwerveModuleState and adds an omega value that we can use to return an omega value.
If anyone has any questions, feel free to leave them below.
-Michael