Swerve Drive Programming

My team really wants to try out swerve drive and mechanically we are capable of doing it but as a relatively amateur programmer I am not really too sure where to even begin programming swerve drive. I have done plenty of Tank and Mecanum drive trains using WPI’s robot drive class but obviously they do not have a version for Swerve. So if anyone has any resources, tips, tricks, and general starting locations for Swerve please share with not only me but also anyone else looking for help. :smiley: Thanks for any responses and have a Great Day!

There’s lots of good technical papers around on chief to look into it.

But I’m sure if you want, you could start with posting some psuedo code on here and get good feed back. I can get you started with some very basic suggestions. (I have mentored a programming team to develop swerve code in the past, so there are some pitfalls you’d come across if you don’t think it through).

Take your joystick (x,y) value
convert to (r, theta)
speed = r
rotate wheels until angle = theta

This white paper by Ether talks about how to program a swerve drive in detail.

I translated this math into Java code - more info is available in that thread.

1 Like

You can check out the codefor my team’s off-season swerve

Thanks Everybody for your help these resources are crazy helpful