Hello everyone. Recently, my team made an exponential drive function for our robot’s drive base. It makes it easier to make small adjustments using the joysticks, while also allowing the robot to move at maximum power if necessary. I wanted to share it with the community.

First of all, let me explain what our drive base code looked like without exponential drive. There were two set____Drive functions that were used in the driver control section. For simplicity, I’ll only include the setLeftDrive function as the setRightDrive function is the same but with the right motors:

In the pictures above, the values coming from the joysticks are used as the percentages of power each side of the drive base gets. In other words, the percentage (of power) is dependent on the joystick values.

If we graph the relation between joystick values (which will be x-values) to percentage values (y-values), we get the following graph.

So when the joystick value is 20, the percentage is also 20 and so on for all the x-values between -100 and 100. But we want something that is not as sensitive. For that we need an exponential function that gives smaller y-values for any given x-value, unless the x-value is 100, in which case, the y-value is also 100 (or close to 100). I’ll skip the process used to find our exponential function (a lot of guess and check work), so here is our new graph with the exponential function (red):

The equation for this function is y = 1.2(1.043)^x - 1.2 + 0.2x. However, you may notice that only positive x-values are shown in the graph. That is because this function only works for positive values. In order to get negative percentages, we first need to turn the negative x-value (the joystick value) into a positive, then plug that into the exponential function, and then turn that answer into a negative. Hopefully the following graph will explain what I mean.

So now we have two functions for exponential drive (one for when the joystick value is 0 OR positive and one for when the joystick value is negative). When we plug these into the original setLeftDrive and setRightDrive functions from earlier, we get the following:

NOTE: We switched to a single-joystick code for the exponential drive and I suggest you do the same as it is very hard to drive with two joysticks.

I hope this guide was helpful. Feel free to ask questions or raise concerns.