Go to the documentation of this file.
17 #ifndef IGNITION_MATH_PID_HH_
18 #define IGNITION_MATH_PID_HH_
22 #include <ignition/math/config.hh>
28 inline namespace IGNITION_MATH_VERSION_NAMESPACE
36 class IGNITION_MATH_VISIBLE
PID
55 public:
PID(
const double _p = 0.0,
56 const double _i = 0.0,
57 const double _d = 0.0,
58 const double _imax = -1.0,
59 const double _imin = 0.0,
60 const double _cmdMax = -1.0,
61 const double _cmdMin = 0.0,
62 const double _cmdOffset = 0.0);
84 public:
void Init(
const double _p = 0.0,
85 const double _i = 0.0,
86 const double _d = 0.0,
87 const double _imax = -1.0,
88 const double _imin = 0.0,
89 const double _cmdMax = -1.0,
90 const double _cmdMin = 0.0,
91 const double _cmdOffset = 0.0);
165 public:
double Update(
const double _error,
166 const std::chrono::duration<double> &_dt);
174 public:
double Cmd()
const;
180 public:
void Errors(
double &_pe,
double &_ie,
double &_de)
const;
191 private:
double pErrLast = 0.0;
194 private:
double pErr = 0.0;
197 private:
double iErr = 0.0;
200 private:
double dErr = 0.0;
203 private:
double pGain;
206 private:
double iGain = 0.0;
209 private:
double dGain = 0.0;
212 private:
double iMax = -1.0;
215 private:
double iMin = 0.0;
218 private:
double cmd = 0.0;
221 private:
double cmdMax = -1.0;
224 private:
double cmdMin = 0.0;
227 private:
double cmdOffset = 0.0;
void Init(const double _p=0.0, const double _i=0.0, const double _d=0.0, const double _imax=-1.0, const double _imin=0.0, const double _cmdMax=-1.0, const double _cmdMin=0.0, const double _cmdOffset=0.0)
Initialize PID-gains and integral term limits:[iMax:iMin]-[I1:I2].
void SetIMax(const double _i)
Set the integral upper limit.
double IMax() const
Get the integral upper limit.
double CmdMin() const
Get the maximum value for the command.
void Reset()
Reset the errors and command.
double CmdOffset() const
Get the offset value for the command.
void SetCmdMin(const double _c)
Set the minimum value for the command.
void Errors(double &_pe, double &_ie, double &_de) const
Return PID error terms for the controller.
double PGain() const
Get the proportional Gain.
void SetIMin(const double _i)
Set the integral lower limit.
double IMin() const
Get the integral lower limit.
void SetCmdOffset(const double _c)
Set the offset value for the command, which is added to the result of the PID controller.
double IGain() const
Get the integral Gain.
double CmdMax() const
Get the maximum value for the command.
double DGain() const
Get the derivative Gain.
void SetPGain(const double _p)
Set the proportional Gain.
Generic PID controller class. Generic proportional-integral-derivative controller class that keeps tr...
Definition: PID.hh:37
void SetCmd(const double _cmd)
Set current target command for this PID controller.
double Cmd() const
Return current command for this PID controller.
PID & operator=(const PID &_p)
Assignment operator.
~PID()=default
Destructor.
void SetIGain(const double _i)
Set the integral Gain.
PID(const double _p=0.0, const double _i=0.0, const double _d=0.0, const double _imax=-1.0, const double _imin=0.0, const double _cmdMax=-1.0, const double _cmdMin=0.0, const double _cmdOffset=0.0)
Constructor, zeros out Pid values when created and initialize Pid-gains and integral term limits:[iMa...
void SetDGain(const double _d)
Set the derivtive Gain.
double Update(const double _error, const std::chrono::duration< double > &_dt)
Update the Pid loop with nonuniform time step size.
void SetCmdMax(const double _c)
Set the maximum value for the command.