Hello, my team would like to implement joystick scaling so that we can have more fine tune control over our robot at lower speeds. Is there an existing library that we can use or do teams work out the math by hand? Thanks for any info!
The WPILib drivetrain classes have a squaring option to increase fine control. There’s not a generic implementation but you could copy the one line of math to apply it yourself. allwpilib/DifferentialDrive.java at main · wpilibsuite/allwpilib · GitHub
We have had good luck simply cubing the joystick value. This preserves sign, allows full 1 to -1 output, and provides a good bump to low-speed resolution.
I would advise using Peter’s solution. In year’s past we used to implement arcade and curvature drive methods in our own drivetrain.
Once we got wind of the DifferentialDrive static methods for computing the wheel speeds we have used them exclusively and it makes it stupid simple. Those methods also take care of clamping for -1 <-> 1 for you if needed.
They also give you the boolean input of whether or not you should be scaling the values (via the squared function. We use curvature drive, but if you used tank drive or arcade drive, you can scale the input controls using those same methods. Here’s what our driving code looks like (at least this far into the season).
The robot I drive uses a 2-stage gearbox that I can manually shift between high and low gear, giving me that precision driving. If you want to programmatically do this, what I would recommend doing is have some member variable for the constant, and in your teleop drive method (or whatever you use) add a conditional at the very end that’s something like “if input is below x percent, multiply the turning input by Y percent”. I’m sure there’s some fancy class or method you can call in WPIlib but that is how I’d perform that task.
We’ve looked at all the joystick transformations here and many more and even created a simple table lookup with multiple curves - one (or more) for each driver (now readily available in WPILib).
Our conclusions from over the years:
- each driver has their own preferences.
- the “square” or “cube” suffice.
- last season our driver (likely winner of aggressive driver of the year) managed to usually stay within his allowed 5 point penalties with the unprocessed raw linear joystick values. (Who needs finesses if trying to run circles around StrykeForce? Fast, erratic is best.) (Caveat - target alignment was essentially always camera automatic.)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.