Help with Swerve Drive Programming??

Our team wants to try out swerve drive before season starts, that way we have another drive system to use for the 2012 game if needed. Any help with the coding?

Two resources: Ether’s paper on omnidirectional drive trains here and to use polar coordinates while keeping things a simple as possible.

If it would help i could post my code for swerve drive…

Problems you may face are:

It is field centric so you need a gyro (you may be able to rewrite i can help you)
we used window motors (dont know what you plan on doing)

I will gladly help you. Im Matt from team 228 Gus robotics i have been programming for 2 1/2 years now and am getting pretty good at it.

Here is our swerve bot from 2010:

the thing that makes this robot special is the field centric controls no matter the orientation of the robot forwards is always forwards. you may want to try it,
But do let me know if you would like my help

I apologize if I’m looking at this wrong way, but it seems rather simple from my understanding.


Of course you’ll need to do some adjusting for the servos and a the twist, but I think that’s all that needs to be done.

Assuming “servos” are the steering motors, it looks like you are pointing all the wheels in the same direction. Here on CD that’s usually referred to Crab drive, not swerve.

With the motors, it looks like you are trying to do skid-steer.

So, it looks like Crab Drive with skid steering.

Of course you’ll need to do some adjusting for the servos and a the twist, but I think that’s all that needs to be done.

The problem of figuring out the theoretically correct speed and steering angle for each of the 4 wheels for any given desired vehicle motion is called “inverse kinematics”. The derivation of the formulas for this is interesting but not beyond the reach of high school mathematics. The formulas themselves are straightforward.

If you could make each wheel instantaneously go to its theoretically correct speed and steering angle, swerve would be simple. But there are dynamics involved. It takes time to steer the wheel and change its speed. During this transition time, the vehicle may do unexpected and/or undesired things.

So the real problem in implementing a competent swerve drive is how to control each wheel to obtain predictable operation and acceptable response to driver commands. There are threads (and technical papers) discussing this problem.



wow, didn’t think about that. yikes, makes it so much harder than it sounds.
Thanks for info! Definitely gonna look into it now

Hey ProgrammerMatt, can you help my team with the swerve drive too? we really want to be able to make that kind of drive but we haven’t been able to because the coding is too complicated for us. If you can help us, please email me at [email protected]
Thank you!

You should post more details about your particular problem here. Would be nice if you could show us what you have so far too.