Me and my team are trying to have our robot use MK2 swerve drive and we need help with updated programs for the drive train can anyone help out.
I had your same problem at the start of the season. I never figured out how to upgrade the SDS Template Code, but it may be easier than I know. What worked best for me was just writing it from scratch based off of the WPI template, which you can find at allwpilib/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/swervebot at main · wpilibsuite/allwpilib · GitHub. My code can be found at https://github.com/Team4028/wpiScratchSwerve/blob/MK2Chassis/src/main/java/frc/robot/subsystems/SwerveModule.java. Fair warning, this is not as clean as SDS’s stuff, as it was not built as a template, but you should be able to figure it out with a little bit of work. I would personally suggest trying to figure out the architecture yourself before looking at my code, since it helped me tremendously to go through the process of figuring out that system.
Additionally, the way I turn each individual module to a specific angle is the same as SDS’s original MK2 code, but it is not optimal, as it is generally thought that it is better to only use the absolute encoders to zero the internal encoders of the angle motors on startup and then use the NEO/Falcon’s internal PID functions to turn to a specific angle. What I have should work just as well as the original template code, however.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.