PIDController Class Reference

#include <PIDController.h>

Public Member Functions

 PIDController (Mdouble pGain, Mdouble iGain, Mdouble dGain)
 
Mdouble apply (Mdouble stressError, Mdouble timeStep)
 

Private Attributes

Mdouble pGain
 
Mdouble iGain
 
Mdouble dGain
 
Mdouble iController = 0
 
bool filterFlag =true
 
Mdouble previousError
 
Mdouble filterError
 

Constructor & Destructor Documentation

◆ PIDController()

PIDController::PIDController ( Mdouble  pGain,
Mdouble  iGain,
Mdouble  dGain 
)
inline
22  {}
Mdouble dGain
Definition: PIDController.h:12
Mdouble pGain
Definition: PIDController.h:10
Mdouble iGain
Definition: PIDController.h:11

Member Function Documentation

◆ apply()

Mdouble PIDController::apply ( Mdouble  stressError,
Mdouble  timeStep 
)
5  {
6 
7  Mdouble filterCoefficient = 0.2;
8  if (filterFlag==true) {
9  filterError = stressError;
10  filterFlag=false;
11  }
12  else {
13  filterError = filterCoefficient * filterError +(1-filterCoefficient) * stressError;
14  }
15 
16  // Proportional Controller
17  Mdouble pController = pGain * stressError;
18 
19  //Integral Controller
20  iController += iGain * timeStep * stressError;
21 
22  //Derivative Controller
23  Mdouble dController=dGain*(stressError-previousError)/timeStep;
24  previousError=stressError;
25 
26  // Controller Command
27  return pController + iController+dController;
28 }
double Mdouble
Definition: GeneralDefine.h:34
Mdouble iController
Definition: PIDController.h:13
bool filterFlag
Definition: PIDController.h:14
Mdouble previousError
Definition: PIDController.h:15
Mdouble filterError
Definition: PIDController.h:16

References dGain, filterError, filterFlag, iController, iGain, pGain, and previousError.

Member Data Documentation

◆ dGain

Mdouble PIDController::dGain
private

Referenced by apply().

◆ filterError

Mdouble PIDController::filterError
private

Referenced by apply().

◆ filterFlag

bool PIDController::filterFlag =true
private

Referenced by apply().

◆ iController

Mdouble PIDController::iController = 0
private

Referenced by apply().

◆ iGain

Mdouble PIDController::iGain
private

Referenced by apply().

◆ pGain

Mdouble PIDController::pGain
private

Referenced by apply().

◆ previousError

Mdouble PIDController::previousError
private

Referenced by apply().


The documentation for this class was generated from the following files: