-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpid.h
31 lines (26 loc) · 837 Bytes
/
pid.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
#ifndef PID_H
#define PID_H
namespace diffbot {
class PID
{
public:
PID(float min_val, float max_val, float kp, float ki, float kd);
double compute(float setpoint, float measured_value);
void updateConstants(float kp, float ki, float kd);
inline double proportional() { return proportional_; };
inline double integral() { return integral_; };
inline double derivative() { return derivative_; };
inline double prev_error() { return prev_error_; };
private:
float min_val_;
float max_val_;
float kp_;
float ki_;
float kd_;
double proportional_;
double integral_;
double derivative_;
double prev_error_;
};
}
#endif