In search of an idiots guide to swerve drive

Rookie team 7477 here! As our season has come to an end, we decided to tackle swerve drive (ambitiously). We have the andymark swerve modules and have them on a chassis so now all we need to do is program, but I have no idea where to start. I have gone through powerpoints and I understand all the math behind the drivetrain and how it works, but I just have no clue how to program it and I can’t find any updated example code or helpful resources. Please help! If you could give me tips, links, example code, or an email so that i could contact you, that would be awesome! We are using java!

3 Likes

First of all good luck with your foray into swerve! Linked below is 2767’s java swerve code. I am sure there are other swerve teams with public code as well if you look around. I believe the code below is from last year and they will be publishing their new code soon, but don’t quote me on that.

The details of the code will also vary depending on the type of turning encoder you have, did you purchase the absolute encoder add-on for the modules?

1 Like

No we did not! Is that something we should do? I am very new to all of this!

I would highly reconsider doing a swerve in your first offseason. What other drivetrains have you don’t before? If you’ve only used the kop chassis I would start with a wcd over the off-season and not use a swerve. Swerves are very expensive and super time consuming and if you don’t plan on using it during the season(which you shouldn’t) I would recommend trying to make a wcd or an off-season bot.

7 Likes

Back in 2011, Ether published a great whitepaper on the derivations for calculating wheel angles for swerve modules. I would highly recommend going through it to make the calculations less of a black box of programming.

1 Like

A lot of people over estimate the difficulty of swerve. They already have the COTS swerve modules and I think they could easily put it on a comp bot.

1 Like

We have built an off-season t shirt cannon with a basic 4 wheel tank drive and we did west coast drive on a welded aluminum chassis for our competition robot! We never touched the KOP Chassis. Unfortunately I do not have much of a choice in doing swerve drive as my teacher is very committed to getting it to work… so here i am! :slight_smile:

Let me tell you a story about a team…
For two years they have tried a swerve
And for two years they haven’t moved at their first competition.
Be warned.
Although theirs wasn’t cots.

2 Likes

You still have all the problems with an increase in complexity or the code not working properly which is something a lot of teams have struggled with. Also the cots swerve modules are really expensive and I think saving up for more equipment would be a better decision for rookie teams in general.

More than a few PNW teams tried this, with the help of 2910. All had varying levels of success, but none id consider enough reason to push swerve to any team outside of 2910s sphere as most of them said that their help specifically was valuable for getting everything working.

2557 specifically took till worlds to get theirs really working.

That’s great that u got a wcd drive working your first season and it kinda sucks that your teacher really wants it to work. I would look at the swerve module Aren Hill made a while ago along with 2910’s double NEO swerve. If you decide to go custom I would recommend posting it here first so people can give you feedback.

We already have the COTS Andymark swerve modules ready to on a square chassis! Just have to get the program to work!

None of the links are working :frowning:

The download links or the link to the thread itself? The downloads work for me, so if that’s not working I can just PM them to you

the download links! If you could PM them that would be great

It’s the offseason…let them do what they want. Doing something difficult and failing is still extremely valuable, even if it doesn’t end up on an on-season robot. I’m sure they realized it is expensive when they bought the modules already…which they can afford…because they bought them.

15 Likes

1640 has some very good documentation about theirs on their website

I can share the exact java code that our team uses for the andymark swerve modules. You will need to have an absolute encoder though so you can track the rotation movement.

Here is the code we use, Its from a different team cause they can do it a lot better than we can.

They already own the modules. Also, I don’t think it makes sense to tell a team not to do swerve in the off-season. Off-season is exactly the time when you should try new things and be willing to do swerve.

To the OP, I’ve never done swerve, but I’ve heard it’s really helpful to have absolute encoders geared 1:1 to with the turning shaft, as someone above recommended. Absolute so you can tell the position of the wheels after a power cycle and 1:1 so you can tell the position only from encoder readings.

1 Like