forked from matthew-t-watson/Picopter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PID.h
41 lines (36 loc) · 828 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
32
33
34
35
36
37
38
39
40
/*
* File: PID.h
* Author: matt
*
* Created on 17 February 2013, 11:19
*/
#ifndef PID_H
#define PID_H
#include <cstddef>
class PIDClass
{
public:
PIDClass();
PIDClass(const PIDClass& orig);
virtual ~PIDClass();
void initialise(float KP, float KI, float KD, float ILIM, float LIM, int DFILLEN, double* ALT_DERIV_SOURCE = NULL);
void calculate(double* position, float* setpoint, float* dt);
void setPID(float KP, float KI, float KD);
void getPID();
float output;
private:
void constrain_(float* value, float range);
float proportional, integral, derivative;
float dHist[32];
float kp;
float ki;
float kd;
float ilim;
float lim;
int dFilLen;
int dFilK;
float error;
float prevError;
double* altDerivativeSource;
};
#endif /* PID_H */