LRT14  1.0
 All Classes Namespaces Functions Variables Enumerations Enumerator
PID.h
1 #ifndef PID_CONTROLLER_H_
2 #define PID_CONTROLLER_H_
3 
4 #include "RunningSum.h"
5 
9 class PID
10 {
11 public:
22  PID(double p_gain, double i_gain, double d_gain, double ff_gain = 1.0,
23  double i_decay = 0.5, bool feedforward = true, double filterFreq = 7.0);
24 
28  PID();
29 
41  void SetParameters(double p_gain, double i_gain, double d_gain,
42  double ff_gain = 1.0, double i_decay = 0.87,
43  bool feedforward = true, double filterFreq = 7.0);
44 
50  virtual double Update(double dt);
51 
56  void SetInput(double input);
57 
62  virtual void SetSetpoint(double setpoint);
63 
68  double GetOutput();
69 
74  double GetProportionalGain();
75 
80  double GetIntegralGain();
81 
86  double GetDerivativeGain();
87 
92  double GetFeedForwardGain();
93 
98  double GetIntegralDecay();
99 
104  double GetInput();
105 
110  double GetSetpoint();
111 
116  double GetError();
117 
122  double GetAccumulatedError();
123 
128  double GetPreviousError();
129 
134  bool IsFeedForward();
135 
139  void Reset();
140 
144  void DisablePID();
145 
149  void EnablePID();
150 
154  void SetIIREnabled(bool enabled);
155 
159  void SetIIRDecay(double decay);
160 
161 private:
162  double m_proportional_gain;
163  double m_integral_gain;
164  double m_derivative_gain;
165  double m_feedforward_gain;
166  double m_integral_decay;
167  double m_input;
168  double m_output;
169  double m_setpoint;
170  double m_error;
171  double m_prev_error;
172  double m_acc_error;
173  bool m_is_feed_forward;
174  bool m_enabled;
175 
176  bool m_IIREnabled;
177  RunningSum m_runningSum;
178 };
179 #endif