Working Mk3 swerve
Swerve for team 1710 has been a long and coming thing. In personally working on both SDS’s MK2’s and MK3’s from a programming perspective, I have found there to be far fewer resources when it comes to working examples. Something I found to be extremely useful, this summer when our team was trying to get our first swerve bot up and running, was SDS’s out-of-the-box MK2 code. This allowed us to test and troubleshoot our build, and electrical system right out of the gate. However, I have yet to find this kind of out-of-the-box code for SDS’s MK3 modules. This was entirely true until about a week ago when this post was made. Although much of the footwork was already done by the WPI library and @Zach_O, in testing we found that an important step was missed.
An important part in getting swerve to work is aligning the wheels and recording their individual offsets into the code so that they all point in the correct direction. By the nature of the mag encoders commonly used in the MK3 modules, it is unlikely that the magnets will be placed perfectly in the 0 position relative to the sensor. In short, you need to be able to calibrate each individual wheel. I made two other minor changes like using Kauali lab’s NavX as a gyroscope and allowing for mid-match recalibration of the gyroscope using the left-bumper.
So ta-da: here is the code
Check the readme for instructions and feel free to ask questions.
Much thanks to @Zach_O and the work he did that allowed us to complete the project so quickly.
Here are some pictures and videos of the bot!
For more on the design, build, and history of the project check out this