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, float w) : weight(w) {set_pid(p,i,d);}
00012 OutputPID(const OutputPID& a, const OutputPID& b, float w) : weight(0) { set(a,b,w); }
00013
00014 inline void set(const float p[3], float w=1) { set_pid(p); weight=w; }
00015 inline void set(const float p, const float i, const float d, float w=1) { set_pid(p,i,d); weight=w; }
00016
00017
00018 inline void set(const OutputPID& a, const OutputPID& b, float w) {
00019 pid[0]=a.pid[0]*w+b.pid[0]*(1-w);
00020 pid[1]=a.pid[1]*w+b.pid[1]*(1-w);
00021 pid[2]=a.pid[2]*w+b.pid[2]*(1-w);
00022 weight=a.weight*w+b.weight*(1-w);
00023 }
00024 inline void unset() { weight=0; }
00025
00026 float pid[3];
00027 float weight;
00028
00029 protected:
00030 inline void set_pid(const float p[3]) {
00031 pid[0]=p[0];
00032 pid[1]=p[1];
00033 pid[2]=p[2];
00034 }
00035 inline void set_pid(const float p, const float i, const float d) {
00036 pid[0]=p;
00037 pid[1]=i;
00038 pid[2]=d;
00039 }
00040 };
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #endif