Mercurial > hg > beaglert
annotate include/Pid.h @ 149:134bff10e561 ClockSync
Added simple one-variable one-measurement Kalman filter, Pid controller(which output is not used). Virtual clock is now much more precise and reactive for period. Still it is lagging behind a bit on the overall offset.
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 21 Sep 2015 03:12:21 +0100 |
parents | |
children | 8f98b32d0e23 |
rev | line source |
---|---|
giuliomoro@149 | 1 /* |
giuliomoro@149 | 2 * Pid.h |
giuliomoro@149 | 3 * |
giuliomoro@149 | 4 * Created on: 14 Sep 2015 |
giuliomoro@149 | 5 * Author: giulio |
giuliomoro@149 | 6 */ |
giuliomoro@149 | 7 |
giuliomoro@149 | 8 #ifndef PID_H_ |
giuliomoro@149 | 9 #define PID_H_ |
giuliomoro@149 | 10 #include <stdio.h> |
giuliomoro@149 | 11 |
giuliomoro@149 | 12 class Pid{ |
giuliomoro@149 | 13 private: |
giuliomoro@149 | 14 float integralError; |
giuliomoro@149 | 15 float pastError; |
giuliomoro@149 | 16 float error; |
giuliomoro@149 | 17 float differentialError; |
giuliomoro@149 | 18 float output; |
giuliomoro@149 | 19 float kp; |
giuliomoro@149 | 20 float ki; |
giuliomoro@149 | 21 float kd; |
giuliomoro@149 | 22 float ts; |
giuliomoro@149 | 23 int idleTimeout; |
giuliomoro@149 | 24 int timeoutCount; |
giuliomoro@149 | 25 void updateIntegralError(); |
giuliomoro@149 | 26 void updateDifferentialError(); |
giuliomoro@149 | 27 public: |
giuliomoro@149 | 28 Pid(); |
giuliomoro@149 | 29 float setError(float anError); |
giuliomoro@149 | 30 void setIdleTimeout(int aIdleTimeout); |
giuliomoro@149 | 31 float getOutput(); |
giuliomoro@149 | 32 }; |
giuliomoro@149 | 33 |
giuliomoro@149 | 34 |
giuliomoro@149 | 35 |
giuliomoro@149 | 36 #endif /* PID_H_ */ |