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 | curve for both sticks | nothing (tank only has one 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.
Curves are kept between 0 and 20, and 0 is no curve. Holding a curve button stops at 20. At 20, a stick at three quarters is already driving the wheels at only about 13%, and higher numbers get flatter still, so there's nothing useful up there. A value outside of that range, from opcontrol_curve_default_set() or from the SD card, is changed to the nearest end of it.
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. For arcade these are the Left/Right buttons curve and the Y/A buttons curve from the chart above. Tank only has one curve, used by both sticks, so it only needs the first.
- 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
// . . .
}