-
Notifications
You must be signed in to change notification settings - Fork 0
/
pid.h
57 lines (51 loc) · 1.23 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef PID_H
#define PID_H
#include <iostream>
#include <vector>
/**
* @brief pid控制实现
* @note 字面意思,pid,计划改成通用型
*/
class pidbase
{
protected:
int N_times;
float pid_target;
float pid_actual;
float Kp;
float Ki;
float Kd;
float err;
float last_err;
float out;
float T;
float integral;
std::vector<float> result;
public:
pidbase();
virtual void pidrunonce() { std::cerr << "error runonce" << std::endl; return; }
virtual void pidrun() { std::cerr << "error run" << std::endl; return; }
virtual std::vector<float> getresult() { std::cerr << "error get result" << std::endl; return; }
};
class PositionPID :
public pidbase
{
public:
PositionPID();
PositionPID(int N_times,
float pid_target,
float Kp, float Ki, float Kd,
float T);
PositionPID(int N_times,
float pid_target,
float pid_actual,
float Kp, float Ki, float Kd,
float err,float last_err,
float out,
float T,
float integral);
virtual void pidrunonce();
virtual void pidrun();
virtual std::vector<float> getresult() { return result; };
};
#endif //PID_H