Thread: Swerve Drive
View Single Post
  #7   Spotlight this post!  
Unread 15-01-2010, 18:12
Guopeter Guopeter is offline
Registered User
AKA: Pie
FRC #0296 (Northern Knights)
Team Role: College Student
 
Join Date: Mar 2008
Rookie Year: 2008
Location: Guelph, Ontario
Posts: 21
Guopeter is just really niceGuopeter is just really niceGuopeter is just really niceGuopeter is just really nice
Re: Swerve Drive

Quote:
Originally Posted by DuskProgrammer View Post
Thanks for the quick replies.

I was wondering if I would need to get sensors if we use swerve drive. If so, what kind of sensors do I need?

Also, it would be nice if one of the teams that use swerve drive could provide a sample of the drive code. It would be helpful in showing me how to implant it and saving me time. Otherwise, I'll probably end up writing code that doesn't work as well and not having much time to improve it.
Hi there,
I was the programmer for team 2609 last year and I coded the their swerve drive system that worked very well.

Programming could be simple, if you can understand the main concepts. It's NOT that scary.

The goal of the program is to keep all four wheels in the same orientation. The programming depends on how you link the swerve modules.

There are three ways to link:
1. Use two chains to link the four modules into two systems (left and right)
2. Same as 1, but add a third chain to link the two systems (left and right) to "synchronize" them
3. Use no chains (have the four modules individually driven by a motor)

With BeaverworX last year, we used Method 1; TWO quadrature encoders were used, one for the left side, one for the right side.

1. Set the "setpoint" for the encoders as the "Axis-X" of the joystick
2. Do some math to find a conversion factor so that at the left-most (or the right-most) value of Axis-X becomes the setpoint for a 90 degree turn to the left (or to the right, if you're using right-most value from x-axis)

The math is this:
Conversion factor = (Leftmost value of X-Axis) / (Number of pulses per 1 revolution/4)

*watch the brackets
*the conversion factor is an absolute value
*make sure at the original position, all wheels point straight ahead (not angled), at this point, the encoder reading is set to 0.
*The values of X-Axis should be from -128 to +128 or a range of numbers from negative to positive. If not, convert it so it is, this makes programming smooooooooooooooooooooooother

SETPOINT = (Value of Axis-X) / Conversion Factor

3. Once you have a setpoint, use that number as the SETPOINT for your PID motor control to turn the module.

4. Tune your PID constants

Now, if you want to control the wheel rotation speed as well as well its swerve using one joystick with two axes (x and y), it is possible (2609 used last year). The algorithm is a bit more complicated in which I wont get into if it's not something you'd like to have.

I hope you're using Labview. You can create some panels to make the tuning part fairly easier.

First time programming this could take around 5~10 hours, including tuning.

Good luck,
Pie Man
__________________
-Northern Knights 296
-Beaverworx 2609

Last edited by Guopeter : 15-01-2010 at 18:22.