This year my team is using a swirve drive on the robot. I am a first year programmer and doi not know how to program this. I know I need to make a custom drive, has anyone done this in the past and have any ideas on how to get this to work?
There are two major components to controlling swerve drives.
1.) Wheel Angle: First you need to calculate the desired wheel angle, this will depend on exactly how you are going to control it but most likely you will have to take the X and Y values and use trig to calculate the desired angle (Tan=Opposite/Adjacent). You will also need to calculate the current angle, for this you will need some kind of sensor (likely a potentiometer). Once you have the desired and actual angles you can use a PID loop (there are functions written for this in both labview and C++) to adjust the angle. There are whitepapers here on CD that describe the process of tuning PID loops.
2.) Wheel Speed, this can be calculated more directly. You can calculate the desired speed from the X and Y components of the joystick (Pythagorean Theorem) and you can map that to wheel speed.
This is the simplest way to do swerve drive and it doesn’t take into account turning. To give you more guidance we really need to know what you are using to control the bot and how the swerve drive is set up. Anytime you are looking to program something that is complicated it is important to break it into smaller functions and attack each independently.
If you have more questions feel free to post them.
Side thought: If your team doesn’t have a programmer that has at least a basic understanding of using Encoders or Potentiometers, and an understanding of how a swerve drive operates, perhaps your team should be doing something simpler, like Mecanum or Tank, and leave experimenting with Swerve until the offseason when you don’t have the pressure of build season to deal with.
Most swerve drives i’ve seen fit into one of a couple categories:
All wheels steer together all the time (the 4 pods are chained together), and all wheels drive at the same speed (one drive pack, transmitted down to the wheels) (requires minimum of 2 motors)
Wheels steer in pairs (Front/Back pair, or Left/Right pair), and all wheels drive at the same speed (requires minimum of 3 motors)
All Wheels steer together, but each wheel has an independent motor for drive speed (requires minimum of 5 motors)
Wheels steer in pairs, each wheels speed is independent (requires minimum of 6 motors)
All wheels steer independently, and have independent speed (requires 8 motors)
They all need to be programmed differently.
1075’s drivetrains have been as follows:
2003: Central Steerable Belt, 4 motors, and undriven trailing wheels, like a tricycle
2004: 4x14" bicycle tires, rear tires articulated by the arm, such that when hanging from the bar, instead of pulling the robot up, we simply lifted the wheels off the ground.
2005: 1075 did not compete
2006: Swerve with steered pairs, and a single drive pack driving all wheels at the same speed. Replaced in the off-season with the first incarnation of our track-drive (tank style) [each side had 3x2.5" CIMs inside the belt]
2007: 2nd incarnation of our track drive. replaced with the 3rd incarnation in the off-season [2xCIMs per side, inside the belt, Gen2 Shifter built in at 2nd incarnation]
2008: 4th incarnation of our track drive [2xCIMs + Gen2 Shifter] replaced by our 6wd drop center, with the same mounts in the off-season
2009: Swerve steered in pairs, independent wheel speeds
2010: DSSwerve, (essentially the same as our 2009 swerve, with improvements, and an extra set of wheels on the top of the robot.)
All of the drive units from 2006-offseason up to 2008-offseason are interchangeable and can be put on any one of those robots. They shared a mounting mechanism, and wiring style.