Joystick Curves
Why?
Typically, moving the joystick halfway means the robot goes half speed. With an input curve, pushing the joystick halfway may only move the robot at 1/4 power. This means more of the joystick movement goes to lower speeds and gives you more control of the robot.
This is fully driver preference. Some drivers will really like curves, some drivers hate them. I loved them when I started using them, but as I got more used to driving fast robots I would turn them down or off completely. Because of this, EZ-Template supports easily adjusting curves live through the controller.
What's the Equation?
EZ-Template uses this curve that 5225A used during In the Zone. The x-axis is the joystick input and the y-axis is the motor output.
Using the Joystick Curves
You can use controller buttons to modify these curves live. What the buttons do depends on which drive style you're using. Here's a list of all of them.
Drive Type | Left/Right Buttons | Y/A Buttons |
---|---|---|
tank | left drive curve | right drive curve |
left split arcade | fwd/rev curve | turn curve |
right split arcade | turn curve | fwd/rev curve |
left single arcade | fwd/rev curve | turn curve |
right single arcade | turn curve | fwd/rev curve |
The higher the number, the more of the joystick will control lower speeds. Drive around and play with these values until you find something you like.
Saving Your Values
You've found values you're happy with! There are two ways of saving them:
- hard code them
- use an SD card
Hard Coding
In main.cpp
you'll find chassis.opcontrol_curve_default_set();
in initialize()
. This function takes 2 variables. One for the left stick and one for the right stick (this is the same as the chart above).
- Tank
- Arcade
void initialize() {
// . . .
chassis.opcontrol_curve_default_set(2.1); // Delete this line if you're using an SD card
// . . .
}
void initialize() {
// . . .
chassis.opcontrol_curve_default_set(2.1, 4.3); // Delete this line if you're using an SD card
// . . .
}
SD Card
If you have an SD card installed, you'll actually want to delete this line of code. This will override what the SD card has saved. And that's all you'll have to do! When you adjust the numbers live they will automatically save to the SD card and hold for the next time you turn the robot on.
void initialize() {
// . . .
// chassis.opcontrol_curve_default_set(2.1); // Delete this line if you're using an SD card
// . . .
}
Disabling Modifying Curves Through the Controller
You can disable modifying curves through the controller by calling chassis.opcontrol_curve_buttons_toggle(false);
. This does not turn off the curve, only the ability to modify them live.
- Tank
- Arcade
void initialize() {
// . . .
chassis.opcontrol_curve_buttons_toggle(false); // Disable modifying curves through the controller
chassis.opcontrol_curve_default_set(2.1); // Delete this line if you're using an SD card
// . . .
}
void initialize() {
// . . .
chassis.opcontrol_curve_buttons_toggle(false); // Disable modifying curves through the controller
chassis.opcontrol_curve_default_set(2.1, 4.3); // Delete this line if you're using an SD card
// . . .
}