-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSimplePID.h
50 lines (42 loc) · 1.36 KB
/
SimplePID.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Description: A simple PID controller class
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef SIMPLEPID_H_
#define SIMPLEPID_H_
class PID
{
public:
PID(double kp, double ki, double kd, double sp, double dt);
PID() = default;
void setSetPoint(double setPoint);
void setInput(double input);
void setKp(double kp);
void setKi(double ki);
void setKd(double kd);
void setSampleTime(double sampleTime);
double compute(double input);
double getError();
double getOutput();
private:
double kp;
double ki;
double kd;
double error;
double last_e;
double integral;
double derivative;
double input;
double output;
double setPoint;
double dt;
double sampleTime;
double maxI=1;
double maxD=1;
};
#endif /* SIMPLEPID_H_ */