User Control
Drive Modes
tank()
Sets the drive to the left and right y axis.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.tank();
pros::delay(ez::util::DELAY_TIME);
}
}
void tank();
arcade_standard()
Sets the drive to standard arcade. Left stick is fwd/rev.
stick_type
is either ez::SPLIT
or ez::SINGLE
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.arcade_standard(ez::SPIT); // For split arcade
// chassis.arcade_standard(ez::SINGLE); // For single arcade
pros::delay(ez::util::DELAY_TIME);
}
}
void arcade_standard(e_type stick_type);
arcade_flipped()
Sets the drive to flipped arcade. Right stick is fwd/rev.
stick_type
is either ez::SPLIT
or ez::SINGLE
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.arcade_flipped(ez::SPIT); // For split arcade
// chassis.arcade_flipped(ez::SINGLE); // For single arcade
pros::delay(ez::util::DELAY_TIME);
}
}
void arcade_flipped(e_type stick_type);
Joystick Functions
initialize()
Runs init_curve_sd()
and imu_calibrate()
.
- Prototype
- Example
void initialize() {
chassis.initialize();
}
void Drive::initialize();
init_curve_sd()
Sets the left/right curve constants to what's on the SD card. If the SD card is empty, creates needed files.
- Prototype
- Example
void initialize() {
chassis.init_curve_sd();
}
void init_curve_sd();
set_curve_defaults()
Sets the left/right curve defaults and saves new values to the SD card.
left
left input curve
right
right input curve
- Prototype
- Example
void initialize() {
chassis.set_curve_defaults(2, 2);
}
void set_curve_default(double left, double right);
set_active_brake()
Active brake runs a P loop on the drive when joysticks are within their threshold.
kp
proportional constant for drive
- Prototype
- Example
void initialize() {
chassis.set_active_brake(0.1);
}
void set_active_brake(double kp);
toggle_modify_curve_with_controller()
Enables/disables buttons used for modifying the controller curve with the joystick.
toggle
true enables, false disables
- Prototype
- Example
void initialize() {
chassis.toggle_modify_curve_with_controller(true);
}
void toggle_modify_curve_with_controller(bool toggle);
set_left_curve_buttons()
Sets the buttons that are used to modify the left input curve. The example is the default.
decrease
a pros button
increase
a pros button
- Prototype
- Example
void initialize() {
chassis.set_left_curve_buttons (pros::E_CONTROLLER_DIGITAL_LEFT, pros::E_CONTROLLER_DIGITAL_RIGHT);
}
void set_left_curve_buttons(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);
set_right_curve_buttons()
Sets the buttons that are used to modify the right input curve. The example is the default.
decrease
a pros button
increase
a pros button
- Prototype
- Example
void initialize() {
chassis.set_right_curve_buttons(pros::E_CONTROLLER_DIGITAL_Y, pros::E_CONTROLLER_DIGITAL_A);
}
void set_right_curve_buttons(pros::controller_digital_e_t decrease, pros::controller_digital_e_t increase);
left_curve_function()
Returns the input times the curve here. tank()
, arcade_standard()
, and arcade_flipped()
all handle this for you. When tank is enabled, only this curve is used.
x
input value
- Prototype
- Example
void opcontrol() {
while (true) {
int l_stick = left_curve_function(master.get_analog(ANALOG_LEFT_Y));
int r_stick = left_curve_function(master.get_analog(ANALOG_RIGHT_Y));
chassis.set_tank(l_stick, r_stick);
pros::delay(ez::util::DELAY_TIME);
}
}
double left_curve_function(double x);
right_curve_function()
Returns the input times the curve here. tank()
, arcade_standard()
, and arcade_flipped()
all handle this for you.
x
input value
- Prototype
- Example
void opcontrol() {
while (true) {
int l_stick = left_curve_function(master.get_analog(ANALOG_LEFT_Y));
int r_stick = left_curve_function(master.get_analog(ANALOG_RIGHT_Y));
chassis.set_tank(l_stick, r_stick);
pros::delay(ez::util::DELAY_TIME);
}
}
double right_curve_function(double x);
set_joystick_threshold()
Threshold the joystick will return 0 within. This is useful because not all joysticks will return perfectly to 0 when let go.
threshold
an integer, recommended to be less then 5
- Prototype
- Example
void initialize() {
chassis.set_joystick_threshold(5);
}
void set_joystick_threshold(int threshold);
joy_thresh_opcontrol()
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() {
while (true) {
chassis.joy_thresh_opcontroL(master.get_analog(ANALOG_LEFT_Y), master.get_analog(ANALOG_RIGHT_Y));
pros::delay(ez::util::DELAY_TIME);
}
chassis.set_joystick_threshold(5);
}
void joy_thresh_opcontrol(int l_stick, int r_stick);
modify_curve_with_controller()
Allows the user to modify the curve with the controller.
- Prototype
- Example
void opcontrol() {
while (true) {
chassis.joy_thresh_opcontroL(master.get_analog(ANALOG_LEFT_Y), master.get_analog(ANALOG_RIGHT_Y));
chassis.modify_curve_with_controller();
pros::delay(ez::util::DELAY_TIME);
}
chassis.set_joystick_threshold(5);
}
void modify_curve_with_controller();