We need Swerve Code

TLDR: Please give us basic swerve drive code for the hardware below.

I’m the controls mentor for our team. Still getting up to speed on the improvements made while I was at college. We were looking at getting into swerve so over this summer we bought the parts. They finally arrived a few weeks ago (many were on back order). We have finished a very basic bot that should in theory work, and a programmer from a local team came to give us some code to get us working. Which is why we hadn’t spent too much time looking into the coding side.

There was a miscommunication. He assumed that since we were using Krakens that everything would be CTR and he would just be showing us how to us TunerX. We didn’t buy CANCoders as we have a long history of students breaking them. We are looking to buy them now if need be but really really want a system that we can begin testing and letting student learn how to drive swerve.

So as I’m trying to read guides and program swerve another mentor suggested I ask for the code here.

Please if your code happens to be the same or could be quickly made. Send us swerve drive code that could function for the below hardware.

Swerve Modules: SDS MK4n (with hex encoder shaft)

Motors: Kraken X60 (drive and steer)

Encoders: REV Throughbore Hex encoders

IMU: Pigeon 2.0

Other electronics: CANivore, REV PDH, RoboRio 2.0

1 Like

YAGSL is probably the best thing for you guys if you still want to try writing you own code. This does almost everything for you. I’m not sure how many people will go and write your code for you, but there’s probably someone.

4 Likes

After doing a tiny bit more research, you can probably use GitHub - BroncBotz3481/YAGSL-Example: Yet Another General Swerve Library Example Project which is the base YAGSL-Example. To switch to the motors you need you can generate new configs with YAGSL Tuning Webpage.

This would probably work.

3 Likes

I want to second the recommendation for YAGSL.
We did an off-season project to convert from tank to swerve and though we’d gotten other swerve code (I think originally from Rev) to work, YAGSL was much easier and had path planning integrated already.

Save yourself many hours of headaches by following the configuration guide rather than randomly flipping inverts and guessing at constants. We spent a couple lab sessions poking at the black box and only after exhausting ourselves did we slow down and read the fine manual, which resulted in working swerve within an hour of starting that process.

2 Likes

For your current hardware setup, YAGSL is what I would recommend.

But since your motors are CTRE, it would also be fairly reasonable to invest another 300 dollars to switch to CanCoders instead, then you can use the CTRE swerve generator.

2 Likes

I second this! Our swerve Library would be your best bet until you can get your hands on some CanCoders. Even with CanCoders, you can still use YAGSL but it will never be as polished as the CTRE swerve generator.

If you have any questions head over to our discord channel linked here as we are super responsive there and will be able to help you out.

2 Likes