# crab drive control scheme

I’ve got some code sketched out to do crab drive but i’m wondering how to control it. I was hoping to get some input on how other teams have set up the controls for their crab drives, any help would be nice.

The easiest way is to implement P or PID control of the steering, here’s some psuedo-code for Proportional §:

``````error = setpoint - process_variable
output = error * gain
``````

Nice and easy. You can increase the gain until it goes as fast as possible without overshooting/oscillating.

If you need finer control of PID (Proportional Integral Derivative) you can use the NI PID toolkit in LabVIEW, but P will probably be good enough for swerve steering.

If you have independent control of each wheel, you can calculate the optimum wheel angle when turning. Assuming you dont, you still turn like a skid-steer. When translating sideways, use the “front” and “back” motors as “left” and “right” for turning.

Edit: Forgot about user interface.

There are a few common ways to do this:

1. Gaming controls: Map the translation angle to the angle of the right joystick and the speed to the magnitude of the right joystick. Map the rotation to the X axis of the left joystick. Use Arcade Drive based on whatever wheels are currently left and right. This is generally combined with a gamepad type controller, and will be very familiar with drivers who are also gamers. These are generally the most common.

2. We have also used “tank-hybrid” when the driver was heavily trained in skid-steer driving. We mapped the speed to the Y axis of the two joysticks, just like tank, and the translation angle to the average of the X. The driver liked this, and it worked, although it did not allow us to utilize the power of four wheel independent steering.

the back end i wasn’t worried about but you answered my question on the ui perfectly, Thanks