OutputPID.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_OutputPID_h
00003 #define INCLUDED_OutputPID_h
00004
00005
00006 class OutputPID {
00007 public:
00008 OutputPID() : weight(0) { pid[0]=pid[1]=pid[2]=0; }
00009 OutputPID(const float p[3]) : weight(1) { set_pid(p); }
00010 OutputPID(const float p[3], float w) : weight(w) {set_pid(p);}
00011 OutputPID(const float p, const float i, const float d) : weight(1) {set_pid(p,i,d);}
00012 OutputPID(const float p, const float i, const float d, float w) : weight(w) {set_pid(p,i,d);}
00013 OutputPID(const OutputPID& a, const OutputPID& b, float w) : weight(0) { set(a,b,w); }
00014
00015 inline void set(const float p[3], float w=1) { set_pid(p); weight=w; }
00016 inline void set(const float p, const float i, const float d, float w=1) { set_pid(p,i,d); weight=w; }
00017
00018
00019 inline void set(const OutputPID& a, const OutputPID& b, float w) {
00020 pid[0]=a.pid[0]*w+b.pid[0]*(1-w);
00021 pid[1]=a.pid[1]*w+b.pid[1]*(1-w);
00022 pid[2]=a.pid[2]*w+b.pid[2]*(1-w);
00023 weight=a.weight*w+b.weight*(1-w);
00024 }
00025 inline void unset() { weight=0; }
00026
00027 float pid[3];
00028 float weight;
00029
00030 protected:
00031
00032 inline void set_pid(const float p[3]) {
00033 pid[0]=p[0];
00034 pid[1]=p[1];
00035 pid[2]=p[2];
00036 }
00037
00038 inline void set_pid(const float p, const float i, const float d) {
00039 pid[0]=p;
00040 pid[1]=i;
00041 pid[2]=d;
00042 }
00043 };
00044
00045
00046
00047
00048
00049
00050 #endif