51 PID(
double p,
double i = 0,
double d = 0,
double start_i = 0, std::string name =
"");
65 void constants_set(
double p,
double i = 0,
double d = 0,
double p_start_i = 0);
103 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);
302 double velocity_zero_main = 0.05;
303 double velocity_zero_secondary = 0.075;
304 int i = 0, j = 0, k = 0, l = 0, m = 0;
306 double second_sensor = 0.0;
309 bool name_active =
false;
311 bool reset_i_sgn =
true;
312 double raw_compute();
313 bool use_second_sensor =
false;
PROS API header provides high-level user functionality.
Discrete PID controller with rich exit-condition support.
bool i_reset_get()
Returns if i will reset when sgn of error changes.
void variables_reset()
Resets all variables to 0.
PID()
Default constructor.
void timers_reset()
Resets all timers for exit conditions.
double velocity_sensor_main_exit_get()
Returns the threshold that the main sensor will return 0 velocity within.
double target_get()
Returns target value.
void constants_set(double p, double i=0, double d=0, double p_start_i=0)
Set constants for PID.
void i_reset_toggle(bool toggle)
Enables / disables i resetting when sgn of error changes.
double derivative
Last derivative term.
light::exit_output exit_condition(std::vector< pros::Motor > sensor, bool print=false)
Iterative exit condition for PID.
Constants constants_get()
Returns constants.
long time
Timestamp of last compute (ms).
double output
Last computed control output.
double integral
Accumulated integral term.
exit_condition_ exit
Active exit-condition thresholds (read/write).
void velocity_sensor_secondary_set(double secondary_sensor)
Updates a secondary sensor for velocity exiting.
std::string name_get()
Returns the name of the PID that prints during exit conditions.
double error
Current error (target − cur).
Constants constants
Active PID gain constants (read/write).
bool constants_set_check()
Returns true if PID constants are set, returns false if they're all 0.
PID(double p, double i=0, double d=0, double start_i=0, std::string name="")
Constructor with constants.
void name_set(std::string name)
Sets the name of the PID that prints during exit conditions.
light::exit_output exit_condition(pros::MotorGroup sensor, bool print=false)
Iterative exit condition for PID.
light::exit_output exit_condition(pros::Motor sensor, bool print=false)
Iterative exit condition for PID.
double velocity_sensor_secondary_get()
Returns the updated secondary sensor for velocity exiting.
double prev_error
Previous-cycle error.
double target
Current target.
void velocity_sensor_main_exit_set(double zero)
Sets the threshold that the main sensor will return 0 velocity within.
void velocity_sensor_secondary_exit_set(double zero)
Sets the threshold that the secondary sensor will return 0 velocity within.
bool velocity_sensor_secondary_toggle_get()
Returns the boolean for if the secondary sensor will be updated or not.
long prev_time
Timestamp of previous compute (ms).
double compute(double current)
Computes PID.
void velocity_sensor_secondary_toggle_set(bool toggle)
Boolean for if the secondary sensor will be updated or not.
double velocity_sensor_secondary_exit_get()
Returns the threshold that the secondary sensor will return 0 velocity within.
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)
Set's constants for exit conditions.
double prev_current
Previous-cycle sensor value.
void target_set(double input)
Sets PID target.
double compute_error(double err, double current)
Computes PID, but you compute the error yourself.
light::exit_output exit_condition(bool print=false)
Iterative exit condition for PID.
double cur
Last sensor value seen.
Public LightLib odometry / pose-estimation API.
exit_output
Result codes returned by PID::exit_condition.
double kd
Derivative gain.
double start_i
Error threshold below which integral begins accumulating.
double kp
Proportional gain.
Exit condition timing and thresholds.
int small_exit_time
ms to exit when error stays within small_error.
int big_exit_time
ms to exit when error stays within big_error.
double small_error
Error band that starts the small-exit timer.
int mA_timeout
ms above current limit before exiting.
double big_error
Error band that starts the big-exit timer.
int velocity_exit_time
ms of zero velocity before exiting.
Shared types, enums, math helpers, and unit conversions used across LightLib.