28 typedef std::chrono::time_point<std::chrono::high_resolution_clock>
TimePoint;
150 void setConstants(
double kp,
double ki,
double kd,
double ff);
360 double calculate(
double target,
double feedback);
double m_settleZone
The range which the error must be for the PID to be considered settled.
double getki()
Returns the value of m_ki.
double m_timeout
The duration the PID should run for before it is considered finished.
PID & withConstants(double kp, double ki, double kd)
Sets the PID constans and returns a refrence to the PID object.
double m_integralZone
The range within which the error is applied to calculate the integral.
double m_prevError
The error fed into the PID controller on it's previous iteration.
double m_integral
The integral caluculated by the PID controller.
double m_error
The error last fed into the PID controller.
double m_derivative
The derivate calculated by the PID controller.
double getProportional()
Get the output produced by the Proportional(P) term.
TimePoint m_startSettledTime
A point in time representing when the PID first entered the acceptable error range.
void setConstants(double kp, double ki, double kd)
Sets the PID constants.
double getkp()
Returns the value of m_kp.
void setIntegralZone(double integralZone)
Sets the range within which the error will be applied to the integral term.
void setSettleTimeout(double settleTimeout)
Set the duration the PID must be settled for before being complete.
double timePassed()
Gets the amoount of time passed since the PID started.
double getff()
Returns the value of m_ff.
PID & withIntegralZone(double integralZone)
Set range within which the error will be applied to the integral term and returns a PID refrence.
double calculate(double error)
Runs the PID by providing an input, then calculates and returns an output.
void setTimeout(double timeout)
Sets the timeout duration.
TimePoint m_startTime
A point in time representing when the PID started.
bool isCompleted()
Gets the current state of the PID.
double getDerivative()
Get the output produced by the Derivative(D) term.
double getIntegral()
Get the output produced by the Integral(I) term.
double getkd()
Returns the value of m_kd.
double m_kp
A constant applied to the Proportional term.
void setSettleZone(double settleZone)
Set the range within which the PID is considered settled.
void reset()
Resets the PID object.
double m_ff
A constant applied directly to the output.
double m_ki
A constant applied to the Integral term.
PID()
Constructs a new PID object.
double m_settleTimeout
The duration the error must be within before the PID is considered complete.
double settledTimePassed()
Gets the amoount of time the PID has been settled for.
double m_kd
A constant applied to the Derivative term.
PID & withTimeout(double timeout)
Sets the timeout duration and returns a refrence to the PID object.
PID & withSettleZone(double settleZone)
Set the range within which the PID is considered settled and returns a refrence to the PID object.
PID & withSettleTimeout(double settleTimeout)
Set the duration the PID must be settled for before being complete.
std::chrono::time_point< std::chrono::high_resolution_clock > TimePoint
A Point in time.