From 577152075fdb911fb55818530510dc97efaeb61f Mon Sep 17 00:00:00 2001 From: Michael Ben-Zvi Date: Sun, 23 Oct 2022 23:09:20 -0700 Subject: [PATCH] changed names for PID.hpp EZ-Robotics#65 --- docs/Docs/auton_functions.md | 10 ++-- docs/Docs/pid.md | 48 +++++++++--------- docs/Tutorials/pid.md | 8 +-- include/EZ-Template/PID.hpp | 28 +++++------ src/EZ-Template/PID.cpp | 60 +++++++++++------------ src/EZ-Template/drive/exit_conditions.cpp | 8 +-- src/EZ-Template/drive/pid_tasks.cpp | 4 +- src/EZ-Template/drive/set_pid.cpp | 54 ++++++++++---------- 8 files changed, 110 insertions(+), 110 deletions(-) diff --git a/docs/Docs/auton_functions.md b/docs/Docs/auton_functions.md index 4991247c..78150753 100644 --- a/docs/Docs/auton_functions.md +++ b/docs/Docs/auton_functions.md @@ -348,7 +348,7 @@ void initialize() { --- -## set_exit_condition() +## exit_condition_set() Sets the exit condition constants. This uses the exit conditions from the PID class. Below is the defaults. `type` either `chassis.turn_exit`, `chassis.swing_exit`, or `chassis.drive_exit` `p_small_exit_time` time, in ms, before exiting `p_small_error` @@ -359,16 +359,16 @@ Sets the exit condition constants. This uses the exit conditions from the PID cl `p_mA_timeout` time, in ms, for `is_over_current` to be true **Prototype** ```cpp -void set_exit_condition(exit_condition_ &type, int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout); +void exit_condition_set(exit_condition_ &type, int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout); ``` **Example** ```cpp void initialize() { - chassis.set_exit_condition(chassis.turn_exit, 100, 3, 500, 7, 500, 500); - chassis.set_exit_condition(chassis.swing_exit, 100, 3, 500, 7, 500, 500); - chassis.set_exit_condition(chassis.drive_exit, 80, 50, 300, 150, 500, 500); + chassis.exit_condition_set(chassis.turn_exit, 100, 3, 500, 7, 500, 500); + chassis.exit_condition_set(chassis.swing_exit, 100, 3, 500, 7, 500, 500); + chassis.exit_condition_set(chassis.drive_exit, 80, 50, 300, 150, 500, 500); } ``` diff --git a/docs/Docs/pid.md b/docs/Docs/pid.md index 08dd763a..323305a9 100644 --- a/docs/Docs/pid.md +++ b/docs/Docs/pid.md @@ -55,7 +55,7 @@ PID liftPID{1, 0.003, 4, 100, "Lift"}; # Functions -## set_constants() +## constants_set() Sets PID constants. `p` kP `i` kI @@ -63,14 +63,14 @@ Sets PID constants. `p_start_i` i will start when error is within this **Prototype** ```cpp -void set_constants(double p, double i = 0, double d = 0, double p_start_i = 0); +void constants_set(double p, double i = 0, double d = 0, double p_start_i = 0); ``` **Example** ```cpp PID liftPID; void initialize() { - liftPID.set_constants(1, 0, 4); + liftPID.constants_set(1, 0, 4); } ``` @@ -80,11 +80,11 @@ void initialize() { -## set_target() +## target_set() Sets PID target. **Prototype** ```cpp -void set_target(double input); +void target_set(double input); ``` **Example** @@ -94,10 +94,10 @@ pros::Motor lift_motor(1); void opcontrol() { while (true) { if (master.get_digital(DIGITAL_L1)) { - liftPID.set_target(500); + liftPID.target_set(500); } else if (master.get_digital(DIGITAL_L2)) { - liftPID.set_target(0); + liftPID.target_set(0); } lift_motor = liftPID.compute(lift_motor.get_position()); @@ -111,7 +111,7 @@ void opcontrol() { -## set_exit_condition() +## exit_condition_set() Sets the exit condition constants. To disable one of the conditions, set the constants relating to it to `0`. `p_small_exit_time` time, in ms, before exiting `p_small_error` `p_small_error` small error threshold @@ -121,7 +121,7 @@ Sets the exit condition constants. To disable one of the conditions, set the co `p_mA_timeout` time, in ms, for `is_over_current` to be true **Prototype** ```cpp -void set_exit_condition(int p_small_exit_time, double p_small_error, int p_big_exit_time = 0, double p_big_error = 0, int p_velocity_exit_time = 0, int p_mA_timeout = 0); +void exit_condition_set(int p_small_exit_time, double p_small_error, int p_big_exit_time = 0, double p_big_error = 0, int p_velocity_exit_time = 0, int p_mA_timeout = 0); ``` @@ -129,7 +129,7 @@ void set_exit_condition(int p_small_exit_time, double p_small_error, int p_big_e ```cpp PID liftPID{1, 0.003, 4, 100, "Lift"}; void initialize() { - liftPID.set_exit_condition(100, 3, 500, 7, 500, 500); + liftPID.exit_condition_set(100, 3, 500, 7, 500, 500); } ``` @@ -139,18 +139,18 @@ void initialize() { -## set_name() +## name_set() A string that prints when exit conditions are met. When you have multiple mechanisms using exit conditions and you're debugging, seeing which exit condition is doing what can be useful. **Prototype** ```cpp -void set_name(std::string name); +void name_set(std::string name); ``` **Example** ```cpp PID liftPID{1, 0.003, 4, 100}; void initialize() { - liftPID.set_name("Lift"); + liftPID.name_set("Lift"); } ``` @@ -173,10 +173,10 @@ pros::Motor lift_motor(1); void opcontrol() { while (true) { if (master.get_digital(DIGITAL_L1)) { - liftPID.set_target(500); + liftPID.target_set(500); } else if (master.get_digital(DIGITAL_L2)) { - liftPID.set_target(0); + liftPID.target_set(0); } lift_motor = liftPID.compute(lift_motor.get_position()); @@ -205,17 +205,17 @@ PID liftPID{1, 0.003, 4, 100, "Lift"}; pros::Motor lift_motor(1); void initialize() { - liftPID.set_exit_condition(100, 3, 500, 7, 500, 500); + liftPID.exit_condition_set(100, 3, 500, 7, 500, 500); } void autonomous() { - liftPID.set_target(500); + liftPID.target_set(500); while (liftPID.exit_condition(true) == ez::RUNNING) { lift_motor = liftPID.compute(lift_motor.get_position()); pros::delay(ez::util::DELAY_TIME); } - liftPID.set_target(0); + liftPID.target_set(0); while (liftPID.exit_condition(true) == ez::RUNNING) { lift_motor = liftPID.compute(lift_motor.get_position()); pros::delay(ez::util::DELAY_TIME); @@ -241,17 +241,17 @@ PID liftPID{1, 0.003, 4, 100, "Lift"}; pros::Motor lift_motor(1); void initialize() { - liftPID.set_exit_condition(100, 3, 500, 7, 500, 500); + liftPID.exit_condition_set(100, 3, 500, 7, 500, 500); } void autonomous() { - liftPID.set_target(500); + liftPID.target_set(500); while (liftPID.exit_condition(lift_motor, true) == ez::RUNNING) { lift_motor = liftPID.compute(lift_motor.get_position()); pros::delay(ez::util::DELAY_TIME); } - liftPID.set_target(0); + liftPID.target_set(0); while (liftPID.exit_condition(lift_motor, true) == ez::RUNNING) { lift_motor = liftPID.compute(lift_motor.get_position()); pros::delay(ez::util::DELAY_TIME); @@ -283,17 +283,17 @@ void set_lift(int input) { } void initialize() { - liftPID.set_exit_condition(100, 3, 500, 7, 500, 500); + liftPID.exit_condition_set(100, 3, 500, 7, 500, 500); } void autonomous() { - liftPID.set_target(500); + liftPID.target_set(500); while (liftPID.exit_condition({r_lift_motor, l_lift_motor}, true) == ez::RUNNING) { set_lift(liftPID.compute(lift_motor.get_position())); pros::delay(ez::util::DELAY_TIME); } - liftPID.set_target(0); + liftPID.target_set(0); while (liftPID.exit_condition({r_lift_motor, l_lift_motor}, true) == ez::RUNNING) { set_lift(liftPID.compute(lift_motor.get_position())); pros::delay(ez::util::DELAY_TIME); diff --git a/docs/Tutorials/pid.md b/docs/Tutorials/pid.md index 53c9e101..33437c28 100644 --- a/docs/Tutorials/pid.md +++ b/docs/Tutorials/pid.md @@ -33,7 +33,7 @@ PID liftPID{0.45, 0, 0, 0, "Lift"}; void lift_auto(double target) { - liftPID.set_target(target); + liftPID.target_set(target); 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()); @@ -44,7 +44,7 @@ void lift_auto(double target) { } void initialize() { - liftPID.set_exit_condition(80, 50, 300, 150, 500, 500); + liftPID.exit_condition_set(80, 50, 300, 150, 500, 500); } void autonomous() { @@ -54,10 +54,10 @@ void autonomous() { void opcontrol() { while (true) { if (master.get_digital(DIGITAL_L1)) { - liftPID.set_target(500); + liftPID.target_set(500); } else if (master.get_digital(DIGITAL_L2)) { - liftPID.set_target(0); + liftPID.target_set(0); } set_lift(liftPID.compute(l_lift.get_position())); diff --git a/include/EZ-Template/PID.hpp b/include/EZ-Template/PID.hpp index 80d7e1ae..a344002b 100644 --- a/include/EZ-Template/PID.hpp +++ b/include/EZ-Template/PID.hpp @@ -44,12 +44,12 @@ class PID { * \param p_start_i * error value that i starts within */ - void set_constants(double p, double i = 0, double d = 0, double p_start_i = 0); + void constants_set(double p, double i = 0, double d = 0, double p_start_i = 0); /** * Struct for constants. */ - struct Constants { + struct constants_ { double kp; double ki; double kd; @@ -82,7 +82,7 @@ class PID { * \param p_velocity_exit_time * Sets velocity_exit_time. Timer will start when velocity is 0. */ - void set_exit_condition(int p_small_exit_time, double p_small_error, int p_big_exit_time = 0, double p_big_error = 0, int p_velocity_exit_time = 0, int p_mA_timeout = 0); + void exit_condition_set(int p_small_exit_time, double p_small_error, int p_big_exit_time = 0, double p_big_error = 0, int p_velocity_exit_time = 0, int p_mA_timeout = 0); /** * Sets target. @@ -90,7 +90,7 @@ class PID { * \param target * Target for PID. */ - void set_target(double input); + void target_set(double input); /** * Computes PID. @@ -103,22 +103,22 @@ class PID { /** * Returns target value. */ - double get_target(); + double target_get(); /** * Returns constants. */ - Constants get_constants(); + constants_ constants_get(); /** * Resets all variables to 0. This does not reset constants. */ - void reset_variables(); + void variables_reset(); /** - * Constants + * constants_ */ - Constants constants; + constants_ constants; /** * Exit @@ -159,7 +159,7 @@ class PID { * \param name * a string that is the name you want to print */ - void set_name(std::string name); + void name_set(std::string name); /** * PID variables. @@ -168,17 +168,17 @@ class PID { double cur; double error; double target; - double prev_error; + double error_prev; double integral; double derivative; long time; - long prev_time; + long time_prev; private: int i = 0, j = 0, k = 0, l = 0; bool is_mA = false; - void reset_timers(); + void timers_reset(); std::string name; bool is_name = false; - void print_exit(ez::e_exit_output exit_type); + void exit_print(ez::e_exit_output exit_type); }; diff --git a/src/EZ-Template/PID.cpp b/src/EZ-Template/PID.cpp index 5b4dcec0..4b1eed17 100644 --- a/src/EZ-Template/PID.cpp +++ b/src/EZ-Template/PID.cpp @@ -9,32 +9,32 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. using namespace ez; -void PID::reset_variables() { +void PID::variables_reset() { output = 0; target = 0; error = 0; - prev_error = 0; + error_prev = 0; integral = 0; time = 0; - prev_time = 0; + time_prev = 0; } PID::PID() { - reset_variables(); - set_constants(0, 0, 0, 0); + variables_reset(); + constants_set(0, 0, 0, 0); } -PID::Constants PID::get_constants() { return constants; } +PID::constants_ PID::constants_get() { return constants; } // PID constructor with constants PID::PID(double p, double i, double d, double start_i, std::string name) { - reset_variables(); - set_constants(p, i, d, start_i); - set_name(name); + variables_reset(); + constants_set(p, i, d, start_i); + name_set(name); } // Set PID constants -void PID::set_constants(double p, double i, double d, double p_start_i) { +void PID::constants_set(double p, double i, double d, double p_start_i) { constants.kp = p; constants.ki = i; constants.kd = d; @@ -42,7 +42,7 @@ void PID::set_constants(double p, double i, double d, double p_start_i) { } // Set exit condition timeouts -void PID::set_exit_condition(int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout) { +void PID::exit_condition_set(int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout) { exit.small_exit_time = p_small_exit_time; exit.small_error = p_small_error; exit.big_exit_time = p_big_exit_time; @@ -51,29 +51,29 @@ void PID::set_exit_condition(int p_small_exit_time, double p_small_error, int p_ exit.mA_timeout = p_mA_timeout; } -void PID::set_target(double input) { target = input; } -double PID::get_target() { return target; } +void PID::target_set(double input) { target = input; } +double PID::target_get() { return target; } double PID::compute(double current) { error = target - current; - derivative = error - prev_error; + derivative = error - error_prev; if (constants.ki != 0) { if (fabs(error) < constants.start_i) integral += error; - if (util::sign(error) != util::sign(prev_error)) + if (util::sign(error) != util::sign(error_prev)) integral = 0; } output = (error * constants.kp) + (integral * constants.ki) + (derivative * constants.kd); - prev_error = error; + error_prev = error; return output; } -void PID::reset_timers() { +void PID::timers_reset() { i = 0; k = 0; j = 0; @@ -81,12 +81,12 @@ void PID::reset_timers() { is_mA = false; } -void PID::set_name(std::string p_name) { +void PID::name_set(std::string p_name) { name = p_name; is_name = name == "" ? false : true; } -void PID::print_exit(ez::e_exit_output exit_type) { +void PID::exit_print(ez::e_exit_output exit_type) { std::cout << " "; if (is_name) std::cout << name << " PID " << exit_to_string(exit_type) << " Exit.\n"; @@ -97,7 +97,7 @@ void PID::print_exit(ez::e_exit_output exit_type) { 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); + exit_print(ERROR_NO_CONSTANTS); return ERROR_NO_CONSTANTS; } @@ -107,8 +107,8 @@ e_exit_output PID::exit_condition(bool print) { j += util::DELAY_TIME; i = 0; // While this is running, don't run big thresh if (j > exit.small_exit_time) { - reset_timers(); - if (print) print_exit(SMALL_EXIT); + timers_reset(); + if (print) exit_print(SMALL_EXIT); return SMALL_EXIT; } } else { @@ -122,8 +122,8 @@ e_exit_output PID::exit_condition(bool print) { if (abs(error) < exit.big_error) { i += util::DELAY_TIME; if (i > exit.big_exit_time) { - reset_timers(); - if (print) print_exit(BIG_EXIT); + timers_reset(); + if (print) exit_print(BIG_EXIT); return BIG_EXIT; } } else { @@ -136,8 +136,8 @@ e_exit_output PID::exit_condition(bool print) { if (abs(derivative) <= 0.05) { k += util::DELAY_TIME; if (k > exit.velocity_exit_time) { - reset_timers(); - if (print) print_exit(VELOCITY_EXIT); + timers_reset(); + if (print) exit_print(VELOCITY_EXIT); return VELOCITY_EXIT; } } else { @@ -154,8 +154,8 @@ e_exit_output PID::exit_condition(pros::Motor sensor, bool print) { if (sensor.is_over_current()) { l += util::DELAY_TIME; if (l > exit.mA_timeout) { - reset_timers(); - if (print) print_exit(mA_EXIT); + timers_reset(); + if (print) exit_print(mA_EXIT); return mA_EXIT; } } else { @@ -183,8 +183,8 @@ e_exit_output PID::exit_condition(std::vector sensor, bool print) { if (is_mA) { l += util::DELAY_TIME; if (l > exit.mA_timeout) { - reset_timers(); - if (print) print_exit(mA_EXIT); + timers_reset(); + if (print) exit_print(mA_EXIT); return mA_EXIT; } } else { diff --git a/src/EZ-Template/drive/exit_conditions.cpp b/src/EZ-Template/drive/exit_conditions.cpp index c7f12dab..808aa78c 100644 --- a/src/EZ-Template/drive/exit_conditions.cpp +++ b/src/EZ-Template/drive/exit_conditions.cpp @@ -10,15 +10,15 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. using namespace ez; void Drive::set_drive_exit_condition(int p_small_exit_time, okapi::QLength p_small_error, int p_big_exit_time, okapi::QLength p_big_error, int p_velocity_exit_time, int p_mA_timeout) { - leftPID.set_exit_condition(p_small_exit_time, p_small_error.convert(okapi::inch), p_big_exit_time, p_big_error.convert(okapi::inch), p_velocity_exit_time, p_mA_timeout); - rightPID.set_exit_condition(p_small_exit_time, p_small_error.convert(okapi::inch), p_big_exit_time, p_big_error.convert(okapi::inch), p_velocity_exit_time, p_mA_timeout); + leftPID.exit_condition_set(p_small_exit_time, p_small_error.convert(okapi::inch), p_big_exit_time, p_big_error.convert(okapi::inch), p_velocity_exit_time, p_mA_timeout); + rightPID.exit_condition_set(p_small_exit_time, p_small_error.convert(okapi::inch), p_big_exit_time, p_big_error.convert(okapi::inch), p_velocity_exit_time, p_mA_timeout); } void Drive::set_turn_exit_condition(int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout) { - turnPID.set_exit_condition(p_small_exit_time, p_small_error, p_big_exit_time, p_big_error, p_velocity_exit_time, p_mA_timeout); + turnPID.exit_condition_set(p_small_exit_time, p_small_error, p_big_exit_time, p_big_error, p_velocity_exit_time, p_mA_timeout); } void Drive::set_swing_exit_condition(int p_small_exit_time, double p_small_error, int p_big_exit_time, double p_big_error, int p_velocity_exit_time, int p_mA_timeout) { - swingPID.set_exit_condition(p_small_exit_time, p_small_error, p_big_exit_time, p_big_error, p_velocity_exit_time, p_mA_timeout); + swingPID.exit_condition_set(p_small_exit_time, p_small_error, p_big_exit_time, p_big_error, p_velocity_exit_time, p_mA_timeout); } // User wrapper for exit condition diff --git a/src/EZ-Template/drive/pid_tasks.cpp b/src/EZ-Template/drive/pid_tasks.cpp index 2559b04f..602f42f2 100644 --- a/src/EZ-Template/drive/pid_tasks.cpp +++ b/src/EZ-Template/drive/pid_tasks.cpp @@ -69,7 +69,7 @@ void Drive::turn_pid_task() { 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 (turnPID.constants.ki != 0 && (fabs(turnPID.target_get()) > turnPID.constants.start_i && fabs(turnPID.error) < turnPID.constants.start_i)) { if (get_turn_min() != 0) gyro_out = util::clamp_number(gyro_out, get_turn_min(), -get_turn_min()); } @@ -88,7 +88,7 @@ void Drive::swing_pid_task() { 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 (swingPID.constants.ki != 0 && (fabs(swingPID.target_get()) > swingPID.constants.start_i && fabs(swingPID.error) < swingPID.constants.start_i)) { if (get_swing_min() != 0) swing_out = util::clamp_number(swing_out, get_swing_min(), -get_swing_min()); } diff --git a/src/EZ-Template/drive/set_pid.cpp b/src/EZ-Template/drive/set_pid.cpp index 639a8634..5c90a8cb 100644 --- a/src/EZ-Template/drive/set_pid.cpp +++ b/src/EZ-Template/drive/set_pid.cpp @@ -13,23 +13,23 @@ void Drive::set_drive_pid_constants(double p, double i, double d, double p_start } void Drive::set_drive_forward_pid_constants(double p, double i, double d, double p_start_i) { - forward_drivePID.set_constants(p, i, d, p_start_i); + forward_drivePID.constants_set(p, i, d, p_start_i); } void Drive::set_drive_backwards_pid_constants(double p, double i, double d, double p_start_i) { - backward_drivePID.set_constants(p, i, d, p_start_i); + backward_drivePID.constants_set(p, i, d, p_start_i); } void Drive::set_turn_pid_constants(double p, double i, double d, double p_start_i) { - turnPID.set_constants(p, i, d, p_start_i); + turnPID.constants_set(p, i, d, p_start_i); } void Drive::set_swing_pid_constants(double p, double i, double d, double p_start_i) { - swingPID.set_constants(p, i, d, p_start_i); + swingPID.constants_set(p, i, d, p_start_i); } void Drive::set_heading_pid_constants(double p, double i, double d, double p_start_i) { - headingPID.set_constants(p, i, d, p_start_i); + headingPID.constants_set(p, i, d, p_start_i); } // Updates max speed @@ -38,16 +38,16 @@ void Drive::set_max_speed(int speed) { } void Drive::reset_pid_targets() { - headingPID.set_target(0); - leftPID.set_target(0); - rightPID.set_target(0); - forward_drivePID.set_target(0); - backward_drivePID.set_target(0); - turnPID.set_target(0); + headingPID.target_set(0); + leftPID.target_set(0); + rightPID.target_set(0); + forward_drivePID.target_set(0); + backward_drivePID.target_set(0); + turnPID.target_set(0); } void Drive::set_angle(double angle) { - headingPID.set_target(angle); + headingPID.target_set(angle); reset_gyro(angle); } @@ -85,20 +85,20 @@ void Drive::set_drive_pid(okapi::QLength p_target, int speed, bool slew_on, bool // Figure out if going forward or backward if (l_target_encoder < l_start && r_target_encoder < r_start) { - auto consts = backward_drivePID.get_constants(); - leftPID.set_constants(consts.kp, consts.ki, consts.kd, consts.start_i); - rightPID.set_constants(consts.kp, consts.ki, consts.kd, consts.start_i); + auto consts = backward_drivePID.constants_get(); + leftPID.constants_set(consts.kp, consts.ki, consts.kd, consts.start_i); + rightPID.constants_set(consts.kp, consts.ki, consts.kd, consts.start_i); is_backwards = true; } else { - auto consts = forward_drivePID.get_constants(); - leftPID.set_constants(consts.kp, consts.ki, consts.kd, consts.start_i); - rightPID.set_constants(consts.kp, consts.ki, consts.kd, consts.start_i); + auto consts = forward_drivePID.constants_get(); + leftPID.constants_set(consts.kp, consts.ki, consts.kd, consts.start_i); + rightPID.constants_set(consts.kp, consts.ki, consts.kd, consts.start_i); is_backwards = false; } // Set PID targets - leftPID.set_target(l_target_encoder); - rightPID.set_target(r_target_encoder); + leftPID.target_set(l_target_encoder); + rightPID.target_set(r_target_encoder); // Initialize slew slew_initialize(left_slew, slew_on, max_speed, l_target_encoder, left_sensor(), l_start, is_backwards); @@ -114,8 +114,8 @@ void Drive::set_turn_pid(double target, int speed) { if (print_toggle) printf("Turn Started... Target Value: %f\n", target); // Set PID targets - turnPID.set_target(target); - headingPID.set_target(target); // Update heading target for next drive motion + turnPID.target_set(target); + headingPID.target_set(target); // Update heading target for next drive motion set_max_speed(speed); // Run task @@ -124,14 +124,14 @@ 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; + double absolute_target = turnPID.target_get() + target; // Print targets if (print_toggle) printf("Turn Started... Target Value: %f\n", absolute_target); // Set PID targets - turnPID.set_target(absolute_target); - headingPID.set_target(absolute_target); + turnPID.target_set(absolute_target); + headingPID.target_set(absolute_target); set_max_speed(speed); // Run task @@ -145,8 +145,8 @@ void Drive::set_swing_pid(e_swing type, double target, int speed) { current_swing = type; // Set PID targets - swingPID.set_target(target); - headingPID.set_target(target); // Update heading target for next drive motion + swingPID.target_set(target); + headingPID.target_set(target); // Update heading target for next drive motion set_max_speed(speed); // Run task