29template <
typename ValueType =
double,
typename TimeType =
double>
43 : _gainP(1), _gainI(0), _gainD(0),
44 _setPoint(0), _integral(0), _prevError(0),
46 _prevUpdate(_currentTime()) {}
108 _prevUpdate = _currentTime();
Dynamic array container wrapping std::vector.
Definition list.h:40
Discrete Proportional-Integral-Derivative (PID) controller.
Definition pidcontroller.h:30
void updateSetPoint(const ValueType &val)
Updates the set point (target value the PID should converge on).
Definition pidcontroller.h:79
void reset()
Resets the integral accumulator, previous error, and update timestamp.
Definition pidcontroller.h:105
ValueType step()
Advances the PID by one time step and returns the control output.
Definition pidcontroller.h:90
void setGainI(const ValueType &val)
Sets the integral gain.
Definition pidcontroller.h:64
PIDController(CurrentValueFunc currentValueFunc, CurrentTimeFunc currentTimeFunc)
Constructs a PID controller with the given feedback callbacks.
Definition pidcontroller.h:42
std::function< TimeType()> CurrentTimeFunc
Callback type that returns the current time.
Definition pidcontroller.h:33
void setGainD(const ValueType &val)
Sets the derivative gain.
Definition pidcontroller.h:73
std::function< ValueType()> CurrentValueFunc
Callback type that returns the current measured process value.
Definition pidcontroller.h:35
ValueType getGainD() const
Returns the derivative gain.
Definition pidcontroller.h:67
void setGainP(const ValueType &val)
Sets the proportional gain.
Definition pidcontroller.h:55
ValueType getGainI() const
Returns the integral gain.
Definition pidcontroller.h:58
ValueType getGainP() const
Returns the proportional gain.
Definition pidcontroller.h:49
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
const Error & error(const Result< T > &r)
Returns the error from a Result.
Definition result.h:65