Implementation


Usage

Battleaid offers TunedJoystick to make using deadzones and response curves intuitive with minimal performance overhead.

1// create a controller like normal
2CommandXboxController controller = new CommandXboxController(0);
3
4// then use the same controller handle
5TunedJoystick tunedJoystick = new TunedJoystick(controller.getHID())
6            .useResponseCurve(ResponseCurve.SOFT)
7            .setDeadzone(0.1d);

Then, you can use the object to retrieve the joystick values:

 8// these values are tuned
 9tunedJoystick.getRightX();
10tunedJoystick.getRightY();
11tunedJoystick.getLeftX();
12tunedJoystick.getLeftY();

Notes

I.

TunedJoystick was created with the intention to be used for drivetrain joysticks, so the only ResponseCurves are exponential.

Enum

Curve

ResponseCurve.LINEAR

🟥 \(x^1\)

ResponseCurve.VERYSOFT

🟩 \(x^{1.48}\)

ResponseCurve.SOFT

🟪 \(x^{1.64}\)

ResponseCurve.QUADRATIC

🟦 \(x^2\)

ResponseCurve.CUBIC

\(x^3\)

Response Curves

II.

The user can optionally change how often the values of the joystick are computed. For example:

1tunedJoystick.setPeriodMilliseconds(15);

The default CommandScheduler loop is 20ms. Setting the period longer will feel laggy but quicker periods might use more resources.