diff --git a/docs/Docs/auton_selector.md b/docs/Docs/auton_selector.md index fdf3e040..8585db91 100644 --- a/docs/Docs/auton_selector.md +++ b/docs/Docs/auton_selector.md @@ -84,7 +84,7 @@ void initialize() { ## add_autons(); -Adds autonomous routines to the autonomous selector. Uses `ez::print_to_screen()` to display to the brain. +Adds autonomous routines to the autonomous selector. Uses `ez::screen_print()` to display to the brain. **Prototype** ```cpp void add_autons(std::vector autons); diff --git a/docs/Docs/pid.md b/docs/Docs/pid.md index dd53fdb8..08dd763a 100644 --- a/docs/Docs/pid.md +++ b/docs/Docs/pid.md @@ -193,10 +193,10 @@ void opcontrol() { # Exit Conditions ## No Motor -Outputs one of the `exit_output` states. This exit condition checks `small_error`, `big_error` and `velocity` if they are enabled. +Outputs one of the `e_exit_output` states. This exit condition checks `small_error`, `big_error` and `velocity` if they are enabled. **Prototype** ```cpp -ez::exit_output exit_condition(bool print = false); +ez::e_exit_output exit_condition(bool print = false); ``` **Example** @@ -229,10 +229,10 @@ void autonomous() { ## One Motor -Outputs one of the `exit_output` states. This exit condition checks `small_error`, `big_error`, `velocity` and `mA` if they are enabled. +Outputs one of the `e_exit_output` states. This exit condition checks `small_error`, `big_error`, `velocity` and `mA` if they are enabled. **Prototype** ```cpp -ez::exit_output exit_condition(pros::Motor sensor, bool print = false); +ez::e_exit_output exit_condition(pros::Motor sensor, bool print = false); ``` **Example** @@ -265,10 +265,10 @@ void autonomous() { ## Multiple Motors -Outputs one of the `exit_output` states. This exit condition checks `small_error`, `big_error`, `velocity` and `mA` if they are enabled. When any of the motors trip `mA`, it returns `mA_EXIT`. +Outputs one of the `e_exit_output` states. This exit condition checks `small_error`, `big_error`, `velocity` and `mA` if they are enabled. When any of the motors trip `mA`, it returns `mA_EXIT`. **Prototype** ```cpp -ez::exit_output exit_condition(std::vector sensor, bool print = false); +ez::e_exit_output exit_condition(std::vector sensor, bool print = false); ``` **Example** diff --git a/docs/Docs/util.md b/docs/Docs/util.md index 8ec457a7..559cf335 100644 --- a/docs/Docs/util.md +++ b/docs/Docs/util.md @@ -44,13 +44,13 @@ void opcontrol() { --- -## print_to_screen() +## screen_print() Prints to the LLEMU. This function handles text that's too long for a line by finding the last word and starting it on a new line, and takes `\n` to set a new line. `text` input string. `line` starting line. **Prototype** ```cpp -void print_to_screen(, std::string text, int line) +void screen_print(, std::string text, int line) ``` **Example 1** @@ -59,7 +59,7 @@ hello, this is line 0 this is line 1 ```cpp void initialize() { - ez::print_to_screen("hello, this is line 0\nthis is line 1"); + ez::screen_print("hello, this is line 0\nthis is line 1"); } ``` @@ -70,7 +70,7 @@ hello ```cpp void initialize() { std::string 32char = 01234567890123456789012345678901; - ez::print_to_screen(32char + "hello"); + ez::screen_print(32char + "hello"); } ``` @@ -78,17 +78,17 @@ void initialize() { --- -## print_ez_template() +## ez_template_print() Prints our branding on your terimnal :D. **Prototype** ```cpp -void print_ez_template(); +void ez_template_print(); ``` **Example** ```cpp void initialize() { - print_ez_template(); + ez_template_print(); } ``` @@ -96,18 +96,18 @@ void initialize() { --- -## sgn() -Returns the sgn of the input. Returns 1 if positive, -1 if negative, and 0 if 0. +## sign() +Returns the sign of the input. Returns 1 if positive, -1 if negative, and 0 if 0. **Prototype** ```cpp -double sgn(double input); +double sign(double input); ``` **Example** ```cpp void opcontrol() { while (true) { - printf("Sgn of Controller: %i \n", sgn(master.get_analog(ANALOG_LEFT_Y))); + printf("Sign of Controller: %i \n", sign(master.get_analog(ANALOG_LEFT_Y))); pros::delay(ez::util::DELAY_TIME); } @@ -118,11 +118,11 @@ void opcontrol() { --- -## clip_num() +## clamp_number() Checks if `input` is within range of `max` and `min`. If it's out, this returns `max` or `min` respectively. **Prototype** ```cpp -double clip_num(double input, double max, double min); +double clamp_number(double input, double max, double min); ``` **Example** @@ -133,7 +133,7 @@ void opcontrol() { // When the joystick is between 100 and 127 // (or -100 and -127) this will print 100 (or -100). - printf("Clipped Controller: %i \n", clip_num(joy, 100, -100)); + printf("Clipped Controller: %i \n", clamp_number(joy, 100, -100)); } } ``` diff --git a/docs/Tutorials/pid.md b/docs/Tutorials/pid.md index 6fca181d..53c9e101 100644 --- a/docs/Tutorials/pid.md +++ b/docs/Tutorials/pid.md @@ -34,7 +34,7 @@ PID liftPID{0.45, 0, 0, 0, "Lift"}; void lift_auto(double target) { liftPID.set_target(target); - ez::exit_output exit = ez::RUNNING; + ez::e_exit_output exit = ez::RUNNING; while (liftPID.exit_condition({l_lift, r_lift}, true) == ez::RUNNING) { double output = liftPID.compute(l_lift.get_position()); set_lift(output); diff --git a/include/EZ-Template/PID.hpp b/include/EZ-Template/PID.hpp index 6af283b0..80d7e1ae 100644 --- a/include/EZ-Template/PID.hpp +++ b/include/EZ-Template/PID.hpp @@ -27,8 +27,8 @@ class PID { * kD * \param p_start_i * error value that i starts within - * \param name - * std::string of name that prints + * \param name + * std::string of name that prints */ PID(double p, double i = 0, double d = 0, double start_i = 0, std::string name = ""); @@ -131,7 +131,7 @@ class PID { * \param print = false * if true, prints when complete. */ - ez::exit_output exit_condition(bool print = false); + ez::e_exit_output exit_condition(bool print = false); /** * Iterative exit condition for PID. @@ -141,7 +141,7 @@ class PID { * \param print = false * if true, prints when complete. */ - ez::exit_output exit_condition(pros::Motor sensor, bool print = false); + ez::e_exit_output exit_condition(pros::Motor sensor, bool print = false); /** * Iterative exit condition for PID. @@ -151,10 +151,10 @@ class PID { * \param print = false * if true, prints when complete. */ - ez::exit_output exit_condition(std::vector sensor, bool print = false); + ez::e_exit_output exit_condition(std::vector sensor, bool print = false); /** - * Sets the name of the PID that prints during exit conditions. + * Sets the name of the PID that prints during exit conditions. * * \param name * a string that is the name you want to print @@ -162,7 +162,7 @@ class PID { void set_name(std::string name); /** - * PID variables. + * PID variables. */ double output; double cur; @@ -180,5 +180,5 @@ class PID { void reset_timers(); std::string name; bool is_name = false; - void print_exit(ez::exit_output exit_type); + void print_exit(ez::e_exit_output exit_type); }; diff --git a/include/EZ-Template/util.hpp b/include/EZ-Template/util.hpp index 7cfc0ce2..e7f3b5d9 100644 --- a/include/EZ-Template/util.hpp +++ b/include/EZ-Template/util.hpp @@ -22,7 +22,7 @@ namespace ez { /** * Prints our branding all over your pros terminal */ -void print_ez_template(); +void ez_template_print(); /** * Prints to the brain screen in one string. Splits input between lines with @@ -33,7 +33,7 @@ void print_ez_template(); * @param line * Starting line to print on, defaults to 0 */ -void print_to_screen(std::string text, int line = 0); +void screen_print(std::string text, int line = 0); ///// // @@ -56,12 +56,12 @@ enum e_swing { LEFT_SWING = 0, /** * Enum for PID::exit_condition outputs. */ -enum exit_output { RUNNING = 1, - SMALL_EXIT = 2, - BIG_EXIT = 3, - VELOCITY_EXIT = 4, - mA_EXIT = 5, - ERROR_NO_CONSTANTS = 6 }; +enum e_exit_output { RUNNING = 1, + SMALL_EXIT = 2, + BIG_EXIT = 3, + VELOCITY_EXIT = 4, + mA_EXIT = 5, + ERROR_NO_CONSTANTS = 6 }; /** * Enum for split and single stick arcade. @@ -74,7 +74,7 @@ enum e_mode { DISABLE = 0, /** * Outputs string for exit_condition enum. */ -std::string exit_to_string(exit_output input); +std::string exit_to_string(e_exit_output input); namespace util { extern bool AUTON_RAN; @@ -82,17 +82,17 @@ extern bool AUTON_RAN; /** * Returns 1 if input is positive and -1 if input is negative */ -int sgn(double input); +int sign(double input); /** * Returns true if the input is < 0 */ -bool is_reversed(double input); +bool reversed_active(double input); /** * Returns input restricted to min-max threshold */ -double clip_num(double input, double max, double min); +double clamp_number(double input, double max, double min); /** * Is the SD card plugged in? diff --git a/src/EZ-Template/PID.cpp b/src/EZ-Template/PID.cpp index bcecb293..5b4dcec0 100644 --- a/src/EZ-Template/PID.cpp +++ b/src/EZ-Template/PID.cpp @@ -62,7 +62,7 @@ double PID::compute(double current) { if (fabs(error) < constants.start_i) integral += error; - if (util::sgn(error) != util::sgn(prev_error)) + if (util::sign(error) != util::sign(prev_error)) integral = 0; } @@ -86,7 +86,7 @@ void PID::set_name(std::string p_name) { is_name = name == "" ? false : true; } -void PID::print_exit(ez::exit_output exit_type) { +void PID::print_exit(ez::e_exit_output exit_type) { std::cout << " "; if (is_name) std::cout << name << " PID " << exit_to_string(exit_type) << " Exit.\n"; @@ -94,7 +94,7 @@ void PID::print_exit(ez::exit_output exit_type) { std::cout << exit_to_string(exit_type) << " Exit.\n"; } -exit_output PID::exit_condition(bool print) { +e_exit_output PID::exit_condition(bool print) { // If this function is called while all exit constants are 0, print an error if (!(exit.small_error && exit.small_exit_time && exit.big_error && exit.big_exit_time && exit.velocity_exit_time && exit.mA_timeout)) { print_exit(ERROR_NO_CONSTANTS); @@ -148,7 +148,7 @@ exit_output PID::exit_condition(bool print) { return RUNNING; } -exit_output PID::exit_condition(pros::Motor sensor, bool print) { +e_exit_output PID::exit_condition(pros::Motor sensor, bool print) { // If the motors are pulling too many mA, the code will timeout and set interfered to true. if (exit.mA_timeout != 0) { // Check if this condition is enabled if (sensor.is_over_current()) { @@ -166,7 +166,7 @@ exit_output PID::exit_condition(pros::Motor sensor, bool print) { return exit_condition(print); } -exit_output PID::exit_condition(std::vector sensor, bool print) { +e_exit_output PID::exit_condition(std::vector sensor, bool print) { // If the motors are pulling too many mA, the code will timeout and set interfered to true. if (exit.mA_timeout != 0) { // Check if this condition is enabled for (auto i : sensor) { diff --git a/src/EZ-Template/auton_selector.cpp b/src/EZ-Template/auton_selector.cpp index aa11204f..78b16aac 100644 --- a/src/EZ-Template/auton_selector.cpp +++ b/src/EZ-Template/auton_selector.cpp @@ -23,7 +23,7 @@ void AutonSelector::print_selected_auton() { if (auton_count == 0) return; for (int i = 0; i < 8; i++) pros::lcd::clear_line(i); - ez::print_to_screen("Page " + std::to_string(current_auton_page + 1) + "\n" + Autons[current_auton_page].Name); + ez::screen_print("Page " + std::to_string(current_auton_page + 1) + "\n" + Autons[current_auton_page].Name); } void AutonSelector::call_selected_auton() { diff --git a/src/EZ-Template/drive/drive.cpp b/src/EZ-Template/drive/drive.cpp index 84ed6b33..79c99685 100644 --- a/src/EZ-Template/drive/drive.cpp +++ b/src/EZ-Template/drive/drive.cpp @@ -27,11 +27,11 @@ Drive::Drive(std::vector left_motor_ports, std::vector right_motor_por // Set ports to a global vector for (auto i : left_motor_ports) { - pros::Motor temp(abs(i), util::is_reversed(i)); + pros::Motor temp(abs(i), util::reversed_active(i)); left_motors.push_back(temp); } for (auto i : right_motor_ports) { - pros::Motor temp(abs(i), util::is_reversed(i)); + pros::Motor temp(abs(i), util::reversed_active(i)); right_motors.push_back(temp); } @@ -49,8 +49,8 @@ Drive::Drive(std::vector left_motor_ports, std::vector right_motor_por int imu_port, double wheel_diameter, double ticks, double ratio, std::vector left_tracker_ports, std::vector right_tracker_ports) : imu(imu_port), - left_tracker(abs(left_tracker_ports[0]), abs(left_tracker_ports[1]), util::is_reversed(left_tracker_ports[0])), - right_tracker(abs(right_tracker_ports[0]), abs(right_tracker_ports[1]), util::is_reversed(right_tracker_ports[0])), + left_tracker(abs(left_tracker_ports[0]), abs(left_tracker_ports[1]), util::reversed_active(left_tracker_ports[0])), + right_tracker(abs(right_tracker_ports[0]), abs(right_tracker_ports[1]), util::reversed_active(right_tracker_ports[0])), left_rotation(-1), right_rotation(-1), ez_auto([this] { this->ez_auto_task(); }) { @@ -58,11 +58,11 @@ Drive::Drive(std::vector left_motor_ports, std::vector right_motor_por // Set ports to a global vector for (auto i : left_motor_ports) { - pros::Motor temp(abs(i), util::is_reversed(i)); + pros::Motor temp(abs(i), util::reversed_active(i)); left_motors.push_back(temp); } for (auto i : right_motor_ports) { - pros::Motor temp(abs(i), util::is_reversed(i)); + pros::Motor temp(abs(i), util::reversed_active(i)); right_motors.push_back(temp); } @@ -80,8 +80,8 @@ Drive::Drive(std::vector left_motor_ports, std::vector right_motor_por int imu_port, double wheel_diameter, double ticks, double ratio, std::vector left_tracker_ports, std::vector right_tracker_ports, int expander_smart_port) : imu(imu_port), - left_tracker({expander_smart_port, abs(left_tracker_ports[0]), abs(left_tracker_ports[1])}, util::is_reversed(left_tracker_ports[0])), - right_tracker({expander_smart_port, abs(right_tracker_ports[0]), abs(right_tracker_ports[1])}, util::is_reversed(right_tracker_ports[0])), + left_tracker({expander_smart_port, abs(left_tracker_ports[0]), abs(left_tracker_ports[1])}, util::reversed_active(left_tracker_ports[0])), + right_tracker({expander_smart_port, abs(right_tracker_ports[0]), abs(right_tracker_ports[1])}, util::reversed_active(right_tracker_ports[0])), left_rotation(-1), right_rotation(-1), ez_auto([this] { this->ez_auto_task(); }) { @@ -89,11 +89,11 @@ Drive::Drive(std::vector left_motor_ports, std::vector right_motor_por // Set ports to a global vector for (auto i : left_motor_ports) { - pros::Motor temp(abs(i), util::is_reversed(i)); + pros::Motor temp(abs(i), util::reversed_active(i)); left_motors.push_back(temp); } for (auto i : right_motor_ports) { - pros::Motor temp(abs(i), util::is_reversed(i)); + pros::Motor temp(abs(i), util::reversed_active(i)); right_motors.push_back(temp); } @@ -117,16 +117,16 @@ Drive::Drive(std::vector left_motor_ports, std::vector right_motor_por right_rotation(abs(right_rotation_port)), ez_auto([this] { this->ez_auto_task(); }) { is_tracker = DRIVE_ROTATION; - left_rotation.set_reversed(util::is_reversed(left_rotation_port)); - right_rotation.set_reversed(util::is_reversed(right_rotation_port)); + left_rotation.set_reversed(util::reversed_active(left_rotation_port)); + right_rotation.set_reversed(util::reversed_active(right_rotation_port)); // Set ports to a global vector for (auto i : left_motor_ports) { - pros::Motor temp(abs(i), util::is_reversed(i)); + pros::Motor temp(abs(i), util::reversed_active(i)); left_motors.push_back(temp); } for (auto i : right_motor_ports) { - pros::Motor temp(abs(i), util::is_reversed(i)); + pros::Motor temp(abs(i), util::reversed_active(i)); right_motors.push_back(temp); } diff --git a/src/EZ-Template/drive/exit_conditions.cpp b/src/EZ-Template/drive/exit_conditions.cpp index 1a22d24d..c7f12dab 100644 --- a/src/EZ-Template/drive/exit_conditions.cpp +++ b/src/EZ-Template/drive/exit_conditions.cpp @@ -27,8 +27,8 @@ void Drive::wait_drive() { pros::delay(util::DELAY_TIME); if (mode == DRIVE) { - exit_output left_exit = RUNNING; - exit_output right_exit = RUNNING; + e_exit_output left_exit = RUNNING; + e_exit_output right_exit = RUNNING; while (left_exit == RUNNING || right_exit == RUNNING) { left_exit = left_exit != RUNNING ? left_exit : leftPID.exit_condition(left_motors[0]); right_exit = right_exit != RUNNING ? right_exit : rightPID.exit_condition(right_motors[0]); @@ -43,7 +43,7 @@ void Drive::wait_drive() { // Turn Exit else if (mode == TURN) { - exit_output turn_exit = RUNNING; + e_exit_output turn_exit = RUNNING; while (turn_exit == RUNNING) { turn_exit = turn_exit != RUNNING ? turn_exit : turnPID.exit_condition({left_motors[0], right_motors[0]}); pros::delay(util::DELAY_TIME); @@ -57,7 +57,7 @@ void Drive::wait_drive() { // Swing Exit else if (mode == SWING) { - exit_output swing_exit = RUNNING; + e_exit_output swing_exit = RUNNING; pros::Motor& sensor = current_swing == ez::LEFT_SWING ? left_motors[0] : right_motors[0]; while (swing_exit == RUNNING) { swing_exit = swing_exit != RUNNING ? swing_exit : swingPID.exit_condition(sensor); @@ -79,18 +79,18 @@ void Drive::wait_until_drive(double target) { int r_tar = r_start + target; int l_error = l_tar - left_sensor(); int r_error = r_tar - right_sensor(); - int l_sgn = util::sgn(l_error); - int r_sgn = util::sgn(r_error); + int l_sgn = util::sign(l_error); + int r_sgn = util::sign(r_error); - exit_output left_exit = RUNNING; - exit_output right_exit = RUNNING; + e_exit_output left_exit = RUNNING; + e_exit_output right_exit = RUNNING; while (true) { l_error = l_tar - left_sensor(); r_error = r_tar - right_sensor(); // Before robot has reached target, use the exit conditions to avoid getting stuck in this while loop - if (util::sgn(l_error) == l_sgn || util::sgn(r_error) == r_sgn) { + if (util::sign(l_error) == l_sgn || util::sign(r_error) == r_sgn) { if (left_exit == RUNNING || right_exit == RUNNING) { left_exit = left_exit != RUNNING ? left_exit : leftPID.exit_condition(left_motors[0]); right_exit = right_exit != RUNNING ? right_exit : rightPID.exit_condition(right_motors[0]); @@ -105,7 +105,7 @@ void Drive::wait_until_drive(double target) { } } // Once we've past target, return - else if (util::sgn(l_error) != l_sgn || util::sgn(r_error) != r_sgn) { + else if (util::sign(l_error) != l_sgn || util::sign(r_error) != r_sgn) { if (print_toggle) std::cout << " Drive Wait Until Exit.\n"; return; } @@ -135,10 +135,10 @@ void Drive::wait_until(double target) { else if (mode == TURN || mode == SWING) { // Calculate error between current and target (target needs to be an in between position) int g_error = target - get_gyro(); - int g_sgn = util::sgn(g_error); + int g_sgn = util::sign(g_error); - exit_output turn_exit = RUNNING; - exit_output swing_exit = RUNNING; + e_exit_output turn_exit = RUNNING; + e_exit_output swing_exit = RUNNING; pros::Motor& sensor = current_swing == ez::LEFT_SWING ? left_motors[0] : right_motors[0]; @@ -148,7 +148,7 @@ void Drive::wait_until(double target) { // If turning... if (mode == TURN) { // Before robot has reached target, use the exit conditions to avoid getting stuck in this while loop - if (util::sgn(g_error) == g_sgn) { + if (util::sign(g_error) == g_sgn) { if (turn_exit == RUNNING) { turn_exit = turn_exit != RUNNING ? turn_exit : turnPID.exit_condition({left_motors[0], right_motors[0]}); pros::delay(util::DELAY_TIME); @@ -162,7 +162,7 @@ void Drive::wait_until(double target) { } } // Once we've past target, return - else if (util::sgn(g_error) != g_sgn) { + else if (util::sign(g_error) != g_sgn) { if (print_toggle) std::cout << " Turn Wait Until Exit.\n"; return; } @@ -171,7 +171,7 @@ void Drive::wait_until(double target) { // If swinging... else { // Before robot has reached target, use the exit conditions to avoid getting stuck in this while loop - if (util::sgn(g_error) == g_sgn) { + if (util::sign(g_error) == g_sgn) { if (swing_exit == RUNNING) { swing_exit = swing_exit != RUNNING ? swing_exit : swingPID.exit_condition(sensor); pros::delay(util::DELAY_TIME); @@ -185,7 +185,7 @@ void Drive::wait_until(double target) { } } // Once we've past target, return - else if (util::sgn(g_error) != g_sgn) { + else if (util::sign(g_error) != g_sgn) { if (print_toggle) std::cout << " Swing Wait Until Exit.\n"; return; } diff --git a/src/EZ-Template/drive/pid_tasks.cpp b/src/EZ-Template/drive/pid_tasks.cpp index 59d90b50..2559b04f 100644 --- a/src/EZ-Template/drive/pid_tasks.cpp +++ b/src/EZ-Template/drive/pid_tasks.cpp @@ -45,8 +45,8 @@ void Drive::drive_pid_task() { double r_slew_out = slew_calculate(right_slew, right_sensor()); // Clip leftPID and rightPID to slew (if slew is disabled, it returns max_speed) - double l_drive_out = util::clip_num(leftPID.output, l_slew_out, -l_slew_out); - double r_drive_out = util::clip_num(rightPID.output, r_slew_out, -r_slew_out); + double l_drive_out = util::clamp_number(leftPID.output, l_slew_out, -l_slew_out); + double r_drive_out = util::clamp_number(rightPID.output, r_slew_out, -r_slew_out); // Toggle heading double gyro_out = heading_on ? headingPID.output : 0; @@ -66,12 +66,12 @@ void Drive::turn_pid_task() { turnPID.compute(get_gyro()); // Clip gyroPID to max speed - double gyro_out = util::clip_num(turnPID.output, max_speed, -max_speed); + double gyro_out = util::clamp_number(turnPID.output, max_speed, -max_speed); // Clip the speed of the turn when the robot is within StartI, only do this when target is larger then StartI if (turnPID.constants.ki != 0 && (fabs(turnPID.get_target()) > turnPID.constants.start_i && fabs(turnPID.error) < turnPID.constants.start_i)) { if (get_turn_min() != 0) - gyro_out = util::clip_num(gyro_out, get_turn_min(), -get_turn_min()); + gyro_out = util::clamp_number(gyro_out, get_turn_min(), -get_turn_min()); } // Set motors @@ -85,12 +85,12 @@ void Drive::swing_pid_task() { swingPID.compute(get_gyro()); // Clip swingPID to max speed - double swing_out = util::clip_num(swingPID.output, max_speed, -max_speed); + double swing_out = util::clamp_number(swingPID.output, max_speed, -max_speed); // Clip the speed of the turn when the robot is within StartI, only do this when target is larger then StartI if (swingPID.constants.ki != 0 && (fabs(swingPID.get_target()) > swingPID.constants.start_i && fabs(swingPID.error) < swingPID.constants.start_i)) { if (get_swing_min() != 0) - swing_out = util::clip_num(swing_out, get_swing_min(), -get_swing_min()); + swing_out = util::clamp_number(swing_out, get_swing_min(), -get_swing_min()); } if (drive_toggle) { diff --git a/src/EZ-Template/drive/set_pid.cpp b/src/EZ-Template/drive/set_pid.cpp index c155034e..639a8634 100644 --- a/src/EZ-Template/drive/set_pid.cpp +++ b/src/EZ-Template/drive/set_pid.cpp @@ -34,7 +34,7 @@ void Drive::set_heading_pid_constants(double p, double i, double d, double p_sta // Updates max speed void Drive::set_max_speed(int speed) { - max_speed = util::clip_num(abs(speed), 127, -127); + max_speed = util::clamp_number(abs(speed), 127, -127); } void Drive::reset_pid_targets() { @@ -125,7 +125,7 @@ void Drive::set_turn_pid(double target, int speed) { void Drive::set_relative_turn_pid(double target, int speed) { // Compute absolute target by adding to current heading double absolute_target = turnPID.get_target() + target; - + // Print targets if (print_toggle) printf("Turn Started... Target Value: %f\n", absolute_target); diff --git a/src/EZ-Template/drive/slew.cpp b/src/EZ-Template/drive/slew.cpp index 9159af08..f4f7bfeb 100644 --- a/src/EZ-Template/drive/slew.cpp +++ b/src/EZ-Template/drive/slew.cpp @@ -25,7 +25,7 @@ void Drive::slew_initialize(slew_ &input, bool slew_on, double max_speed, double input.enabled = slew_on; input.max_speed = max_speed; - input.sign = util::sgn(target - current); + input.sign = util::sign(target - current); input.x_intercept = start + ((SLEW_DISTANCE[backwards] * input.sign)); input.y_intercept = max_speed * input.sign; input.slope = ((input.sign * SLEW_MIN_POWER[backwards]) - input.y_intercept) / (input.x_intercept - 0 - start); // y2-y1 / x2-x1 @@ -39,11 +39,11 @@ double Drive::slew_calculate(slew_ &input, double current) { input.error = input.x_intercept - current; // When the sign of error flips, slew is completed - if (util::sgn(input.error) != input.sign) + if (util::sign(input.error) != input.sign) input.enabled = false; // Return y=mx+b - else if (util::sgn(input.error) == input.sign) + else if (util::sign(input.error) == input.sign) return ((input.slope * input.error) + input.y_intercept) * input.sign; } // When slew is completed, return max speed diff --git a/src/EZ-Template/util.cpp b/src/EZ-Template/util.cpp index dd3f30b9..2eea60ce 100644 --- a/src/EZ-Template/util.cpp +++ b/src/EZ-Template/util.cpp @@ -11,7 +11,7 @@ pros::Controller master(pros::E_CONTROLLER_MASTER); namespace ez { int mode = DISABLE; -void print_ez_template() { +void ez_template_print() { std::cout << R"( @@ -51,8 +51,8 @@ std::string get_rest_of_the_word(std::string text, int position) { } return word; } -//All iance\n\nWE WIN THESE!!!!! -void print_to_screen(std::string text, int line) { +// All iance\n\nWE WIN THESE!!!!! +void screen_print(std::string text, int line) { int CurrAutoLine = line; std::vector texts = {}; std::string temp = ""; @@ -64,9 +64,9 @@ void print_to_screen(std::string text, int line) { texts.push_back(temp); temp = text[i]; } else { - int size = last_word.length(); + int size = last_word.length(); - auto rest_of_word = get_rest_of_the_word(text, i); + auto rest_of_word = get_rest_of_the_word(text, i); temp.erase(temp.length() - size, size); texts.push_back(temp); last_word += rest_of_word; @@ -76,7 +76,6 @@ void print_to_screen(std::string text, int line) { texts.push_back(temp); break; } - } } if (i >= text.length() - 1) { @@ -103,7 +102,7 @@ void print_to_screen(std::string text, int line) { } } -std::string exit_to_string(exit_output input) { +std::string exit_to_string(e_exit_output input) { switch ((int)input) { case RUNNING: return "Running"; @@ -126,12 +125,12 @@ std::string exit_to_string(exit_output input) { namespace util { bool AUTON_RAN = true; -bool is_reversed(double input) { +bool reversed_active(double input) { if (input < 0) return true; return false; } -int sgn(double input) { +int sign(double input) { if (input > 0) return 1; else if (input < 0) @@ -139,7 +138,7 @@ int sgn(double input) { return 0; } -double clip_num(double input, double max, double min) { +double clamp_number(double input, double max, double min) { if (input > max) return max; else if (input < min) diff --git a/src/main.cpp b/src/main.cpp index 5534f3d0..50acddc2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,7 +52,7 @@ Drive chassis ( */ void initialize() { // Print our branding over your terminal :D - ez::print_ez_template(); + ez::ez_template_print(); pros::delay(500); // Stop the user from doing anything while legacy ports configure.