User Control
Drive Modes​
opcontrol_tank()​
Sets the chassis to controller joysticks using tank control.
Run in usercontrol.
This passes the controller through the curve functions, but is disabled by default.
Use opcontrol_curve_buttons_toggle() to enable it.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_tank();
pros::delay(ez::util::DELAY_TIME);
}
}
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 curve functions, but is disabled by default.
Use opcontrol_curve_buttons_toggle() to enable it.
stick_type
ez::SINGLE or ez::SPLIT control
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_arcade_standard(ez::SPIT); // For split arcade
// chassis.opcontrol_arcade_standard(ez::SINGLE); // For single arcade
pros::delay(ez::util::DELAY_TIME);
}
}
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 curve functions, but is disabled by default.
Use opcontrol_curve_buttons_toggle() to enable it.
stick_type
ez::SINGLE or ez::SPLIT control
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_arcade_flipped(ez::SPIT); // For split arcade
// chassis.opcontrol_arcade_flipped(ez::SINGLE); // For single arcade
pros::delay(ez::util::DELAY_TIME);
}
}
void opcontrol_arcade_flipped(e_type stick_type);
Joystick Curves​
opcontrol_curve_sd_initialize()​
Initializes left and right curves with the SD card, recommended to run in initialize().
- Prototype
- Example
void initialize() {
chassis.opcontrol_curve_sd_initialize();
}
void opcontrol_curve_sd_initialize();
opcontrol_curve_default_sets()​
Sets the default joystick curves.
left
left default curve
right
right default curve
- Prototype
- Example
void initialize() {
chassis.opcontrol_curve_default_sets(2, 2);
}
void opcontrol_curve_default_set(double left, double right);
opcontrol_curve_buttons_toggle()​
Enables/disables modifying the joystick input curves with the controller.
toggle
true enables, false disables
- Prototype
- Example
void initialize() {
chassis.opcontrol_curve_buttons_toggle(true);
}
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.
- Prototype
- Example
void initialize() {
printf("Enabled? %i\n", chassis.opcontrol_curve_buttons_toggle_get()); // Returns false
chassis.opcontrol_curve_buttons_toggle(true);
printf("Enabled? %i\n", chassis.opcontrol_curve_buttons_toggle_get()); // Returns true
}
bool opcontrol_curve_buttons_toggle_get();
opcontrol_curve_buttons_left_set()​
Sets buttons for modifying the left joystick curve.
decrease
a pros button enumerator
increase
a pros button enumerator
- Prototype
- Example
void initialize() {
chassis.opcontrol_curve_buttons_left_set(pros::E_CONTROLLER_DIGITAL_LEFT, pros::E_CONTROLLER_DIGITAL_RIGHT);
}
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.
decrease
a pros button enumerator
increase
a pros button enumerator
- Prototype
- Example
void initialize() {
chassis.opcontrol_curve_buttons_right_set(pros::E_CONTROLLER_DIGITAL_Y, pros::E_CONTROLLER_DIGITAL_A);
}
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
- Prototype
- Example
void opcontrol() {
while (true) {
int l_stick = opcontrol_curve_left(master.get_analog(ANALOG_LEFT_Y));
int r_stick = opcontrol_curve_left(master.get_analog(ANALOG_RIGHT_Y));
chassis.drive_set(l_stick, r_stick);
pros::delay(ez::util::DELAY_TIME);
}
}
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
- Prototype
- Example
void opcontrol() {
while (true) {
int l_stick = opcontrol_curve_left(master.get_analog(ANALOG_LEFT_Y));
int r_stick = opcontrol_curve_left(master.get_analog(ANALOG_RIGHT_Y));
chassis.drive_set(l_stick, r_stick);
pros::delay(ez::util::DELAY_TIME);
}
}
double opcontrol_curve_right(double x);
opcontrol_curve_buttons_iterate()​
Allows the user to modify the curve with the controller.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.opcontrol_joystick_threshold_opcontrol(master.get_analog(ANALOG_LEFT_Y), master.get_analog(ANALOG_RIGHT_Y));
chassis.opcontrol_curve_buttons_iterate();
pros::delay(ez::util::DELAY_TIME);
}
chassis.opcontrol_joystick_threshold_set(5);
}
void opcontrol_curve_buttons_iterate();
Joystick General​
opcontrol_joystick_threshold_set()​
Sets a new threshold for the joystick.
The joysticks wil not return a value if they are within this.
threshold
new threshold
- Prototype
- Example
void initialize() {
chassis.opcontrol_joystick_threshold_set(5);
}
void opcontrol_joystick_threshold_set(int threshold);
opcontrol_joystick_threshold_iterate()​
Runs the joystick control. Sets the left drive to l_stick
, and right drive to r_stick
. Runs active brake and joystick thresholds.
l_stick
left joystick value
r_stick
right joystick value
- Prototype
- Example
void opcontrol() {
chassis.opcontrol_joystick_threshold_set(5);
while (true) {
chassis.opcontrol_joystick_threshold_iterate(master.get_analog(ANALOG_LEFT_Y), master.get_analog(ANALOG_RIGHT_Y));
pros::delay(ez::util::DELAY_TIME);
}
}
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 you go max speed.
toggle
true enables, false disables
- Prototype
- Example
void opcontrol_joystick_practicemode_toggle(bool toggle);
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
// Toggle practice mode
if (master.get_digital_new_press(DIGITAL_L1)) {
chassis.opcontrol_joystick_practicemode_toggle(!chassis.opcontrol_joystick_practicemode_toggle_get());
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
opcontrol_joystick_practicemode_toggle_get()​
Gets current state of the toggle.
True is enabled, false is disabled.
- Prototype
- Example
ool opcontrol_joystick_practicemode_toggle_get();
void opcontrol() {
while (true) {
chassis.opcontrol_tank(); // Tank control
// Toggle practice mode
if (master.get_digital_new_press(DIGITAL_L1)) {
chassis.opcontrol_joystick_practicemode_toggle(!chassis.opcontrol_joystick_practicemode_toggle_get());
}
pros::delay(ez::util::DELAY_TIME); // This is used for timer calculations! Keep this ez::util::DELAY_TIME
}
}
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
- Prototype
- Example
void initialize() {
chassis.opcontrol_drive_activebrake_set(2.0);
}
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.
- Prototype
- Example
void initialize() {
chassis.opcontrol_drive_activebrake_set(0.1);
printf("kP is: %f\n", chassis.opcontrol_drive_activebrake_get);
}
double opcontrol_drive_activebrake_get();
opcontrol_drive_activebrake_constants_get()​
Returns all PID constants for active brake.
- Prototype
- Example
void initialize() {
chassis.opcontrol_drive_activebrake_set(0.1);
ez::PID::Constants consts = chassis.opcontrol_drive_activebrake_constants_get();
printf("kP is: %f\n", consts.kP);
}
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
- Prototype
- Example
void opcontrol() {
while (true) {
if (master.get_digital_new_press(DIGITAL_B))
chassis.opcontrol_drive_reverse_set(!chassis.opcontrol_drive_reverse_get());
chassis.opcontrol_tank();
pros::delay(10);
}
}
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.
- Prototype
- Example
void opcontrol() {
while (true) {
if (master.get_digital_new_press(DIGITAL_B))
chassis.opcontrol_drive_reverse_set(!chassis.opcontrol_drive_reverse_get());
chassis.opcontrol_tank();
pros::delay(10);
}
}
bool opcontrol_drive_reverse_get();