RIT VEXU Core API
|
#include <pid.h>
Classes | |
struct | pid_config_t |
Public Types | |
enum | ERROR_TYPE |
Public Member Functions | |
PID (pid_config_t &config) | |
void | init (double start_pt, double set_pt) override |
double | update (double sensor_val) override |
double | update (double sensor_val, double v_setpt) |
double | get_sensor_val () const |
gets the sensor value that we were last updated with | |
double | get () override |
void | set_limits (double lower, double upper) override |
bool | is_on_target () override |
void | reset () |
double | get_error () |
double | get_target () const |
void | set_target (double target) |
Public Attributes | |
pid_config_t & | config |
PID Class
Defines a standard feedback loop using the constants kP, kI, kD, deadband, and on_target_time. The formula is:
out = kP*error + kI*integral(d Error) + kD*(dError/dt)
The PID object will determine it is "on target" when the error is within the deadband, for a duration of on_target_time
enum PID::ERROR_TYPE |
An enum to distinguish between a linear and angular caluclation of PID error.
PID::PID | ( | pid_config_t & | config | ) |
|
overridevirtual |
double PID::get_error | ( | ) |
Get the delta between the current sensor data and the target
Get the delta between the current sensor data and the target
double PID::get_sensor_val | ( | ) | const |
gets the sensor value that we were last updated with
double PID::get_target | ( | ) | const |
|
overridevirtual |
Inherited from Feedback for interoperability. Update the setpoint and reset integral accumulation
start_pt can be safely ignored in this feedback controller
start_pt | commpletely ignored for PID. necessary to satisfy Feedback base |
set_pt | sets the target of the PID controller |
start_vel | completely ignored for PID. necessary to satisfy Feedback base |
end_vel | sets the target end velocity of the PID controller |
Implements Feedback.
|
overridevirtual |
void PID::reset | ( | ) |
Reset the PID loop by resetting time since 0 and accumulated error.
|
overridevirtual |
Set the limits on the PID out. The PID out will "clip" itself to be between the limits.
lower | the lower limit. the PID controller will never command the output go below lower |
upper | the upper limit. the PID controller will never command the output go higher than upper |
Set the limits on the PID out. The PID out will "clip" itself to be between the limits.
Implements Feedback.
void PID::set_target | ( | double | target | ) |
|
overridevirtual |
Update the PID loop by taking the time difference from last update, and running the PID formula with the new sensor data
sensor_val | the distance, angle, encoder position or whatever it is we are measuring |
Implements Feedback.
double PID::update | ( | double | sensor_val, |
double | v_setpt ) |
Update the PID loop by taking the time difference from last update, and running the PID formula with the new sensor data
sensor_val | the distance, angle, encoder position or whatever it is we are measuring |
v_setpt | Expected velocity setpoint, to subtract from the D term (for velocity control) |
pid_config_t& PID::config |
configuration struct for this controller. see pid_config_t for information about what this contains