Skip to main content
Version: 4.0.0-beta.3

User Control

Drive Modes​

opcontrol_tank()​

Sets the chassis to controller joysticks using tank control.
Run in usercontrol.

This passes the controller through the joystick curves. A curve of 0 is no curve, which is the default. The controller buttons that change the curves are enabled by default, use opcontrol_curve_buttons_toggle(false) to turn them off.

void opcontrol_tank();

opcontrol_arcade_standard()​

Sets the chassis to controller joysticks using standard arcade control, where left stick is fwd/rev.
Run in usercontrol.

This passes the controller through the joystick curves. A curve of 0 is no curve, which is the default. The controller buttons that change the curves are enabled by default, use opcontrol_curve_buttons_toggle(false) to turn them off.

stick_type ez::SINGLE or ez::SPLIT control

void opcontrol_arcade_standard(e_type stick_type);

opcontrol_arcade_flipped()​

Sets the chassis to controller joysticks using flipped arcade control, where right stick is fwd/rev.
Run in usercontrol.

This passes the controller through the joystick curves. A curve of 0 is no curve, which is the default. The controller buttons that change the curves are enabled by default, use opcontrol_curve_buttons_toggle(false) to turn them off.

stick_type ez::SINGLE or ez::SPLIT control

void opcontrol_arcade_flipped(e_type stick_type);

opcontrol_arcade_curvature_standard()​

Sets the chassis to controller joysticks using standard curvature control, where left stick is fwd/rev.
Run in usercontrol.

Curvature is like arcade, but the turn stick sets the curvature of the arc the robot drives instead of how fast it turns. The robot follows the same arc at any speed, like a steering wheel. See Control Schemes for more on how it feels.

Because the turn is scaled by how fast you're driving, the robot would not be able to turn while stopped. opcontrol_curvature_point_turn_gain_set() controls how much the robot can turn on a point.

This passes the controller through the joystick curves. A curve of 0 is no curve, which is the default. The controller buttons that change the curves are enabled by default, use opcontrol_curve_buttons_toggle(false) to turn them off.

stick_type ez::SINGLE or ez::SPLIT control

void opcontrol_arcade_curvature_standard(e_type stick_type);

opcontrol_arcade_curvature_flipped()​

Sets the chassis to controller joysticks using flipped curvature control, where right stick is fwd/rev.
Run in usercontrol.

Curvature is like arcade, but the turn stick sets the curvature of the arc the robot drives instead of how fast it turns. The robot follows the same arc at any speed, like a steering wheel. See Control Schemes for more on how it feels.

Because the turn is scaled by how fast you're driving, the robot would not be able to turn while stopped. opcontrol_curvature_point_turn_gain_set() controls how much the robot can turn on a point.

This passes the controller through the joystick curves. A curve of 0 is no curve, which is the default. The controller buttons that change the curves are enabled by default, use opcontrol_curve_buttons_toggle(false) to turn them off.

stick_type ez::SINGLE or ez::SPLIT control

void opcontrol_arcade_curvature_flipped(e_type stick_type);

opcontrol_curvature_point_turn_gain_set()​

Sets how much the robot can turn when it is barely moving fwd/rev in curvature control.

Curvature scales the turn stick by how fast you're driving, so at 0 fwd/rev speed the robot could not turn at all. To fix this, the turn is scaled by whichever is larger; your fwd/rev speed (as a fraction of full speed) or this gain. There is no jump between the two, and no button is needed to turn on a point.

  • 0 is pure curvature, the robot cannot turn on a point
  • 1 is the same as arcade
  • Anything in between turns on a point at a reduced sensitivity, and becomes true curvature once your fwd/rev speed is above gain * 127

This is defaulted to 0.8. Values outside of 0 - 1 are clamped.

gain 0 - 1

void opcontrol_curvature_point_turn_gain_set(double gain);

opcontrol_curvature_point_turn_gain_get()​

Returns how much the robot can turn when it is barely moving fwd/rev in curvature control.

double opcontrol_curvature_point_turn_gain_get();

Joystick Curves​

opcontrol_curve_sd_initialize()​

Initializes left and right curves with the SD card, recommended to run in initialize().

A value in left_curve.txt or right_curve.txt that is outside of 0 to 20 is changed to the nearest end of that range, and the terminal prints what it was changed to. If a file can't be read as a number, the current curve is kept.

void opcontrol_curve_sd_initialize();

opcontrol_curve_default_set()​

Sets the default joystick curves. Curves are kept between 0 and 20, a value outside of that is changed to the nearest end. 0 is no curve.

left left default curve
right right default curve, defaults to 0

void opcontrol_curve_default_set(double left, double right = 0);

opcontrol_curve_buttons_toggle()​

Enables/disables modifying the joystick input curves with the controller.

toggle true enables, false disables

void opcontrol_curve_buttons_toggle(bool toggle);

opcontrol_curve_buttons_toggle_get()​

Gets the current state of the toggle. Enables/disables modifying the joystick input curves with the controller.

True enabled, false disabled.

bool opcontrol_curve_buttons_toggle_get();

opcontrol_curve_buttons_left_set()​

Sets buttons for modifying the left joystick curve. The curve stops at 0 and at 20 when you hold the buttons.

decrease a pros button enumerator
increase a pros button enumerator

void opcontrol_curve_buttons_left_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);

opcontrol_curve_buttons_right_set()​

Sets buttons for modifying the right joystick curve. The curve stops at 0 and at 20 when you hold the buttons.

decrease a pros button enumerator
increase a pros button enumerator

void opcontrol_curve_buttons_right_set(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);

opcontrol_curve_left()​

Outputs a curve from 5225A In the Zone.

This gives more control over the robot at lower speeds.

x joystick input

double opcontrol_curve_left(double x);

opcontrol_curve_right()​

Outputs a curve from 5225A In the Zone.

This gives more control over the robot at lower speeds.

x joystick input

double opcontrol_curve_right(double x);

opcontrol_curve_buttons_iterate()​

Allows the user to modify the curve with the controller.

void opcontrol_curve_buttons_iterate();

Joystick General​

opcontrol_joystick_threshold_set()​

Sets a new threshold for the joystick.

The joysticks will not return a value if they are within this.

threshold new threshold

void opcontrol_joystick_threshold_set(int threshold);

opcontrol_joystick_threshold_iterate()​

Runs the joystick control. Sets the left drive to l_stick and the right drive to r_stick, and runs active brake when both are 0. This applies practice mode, opcontrol_drive_reverse_set() and the opcontrol max speed. It does not apply opcontrol_joystick_threshold_set(), the opcontrol_ drive functions apply that before calling this.

l_stick left drive input, -127 to 127
r_stick right drive input, -127 to 127

void opcontrol_joystick_threshold_iterate(int l_stick, int r_stick);

opcontrol_joystick_practicemode_toggle()​

Practice mode for driver practice that shuts off the drive if either side of the drive is asked to go faster than 120 (out of 127). In arcade this is checked after the forward and turn sticks are combined.

toggle true enables, false disables

void opcontrol_joystick_practicemode_toggle(bool toggle);

opcontrol_joystick_practicemode_toggle_get()​

Gets current state of the toggle.

True is enabled, false is disabled.

bool opcontrol_joystick_practicemode_toggle_get();

Active Brake​

opcontrol_drive_activebrake_set()​

Runs a PID loop on the drive when the joysticks are released.

kp proportional term
ki integral term
kd derivative term
start_i error threshold to start integral

void opcontrol_drive_activebrake_set(double kp, double ki = 0.0, double kd = 0.0, double start_i = 0.0);

opcontrol_drive_activebrake_get()​

Returns kP of active brake.

double opcontrol_drive_activebrake_get();

opcontrol_drive_activebrake_constants_get()​

Returns all PID constants for active brake.

PID::Constants opcontrol_drive_activebrake_constants_get();

Reversing Drive​

opcontrol_drive_reverse_set()​

Reversal for drivetrain in opcontrol that flips the left and right side and the direction of the drive.

toggle true if you want your drivetrain reversed and false if you do not

void opcontrol_drive_reverse_set(bool toggle);

opcontrol_drive_reverse_get()​

Returns true if the drive is currently reversed, and false if it isn't.

bool opcontrol_drive_reverse_get();