Quote:
Originally Posted by flamingtoaster
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.