00001 // -*- C++ -*- 00010 #ifndef CONVOLUTION_H 00011 #define CONVOLUTION_H 00012 00013 // </rtc-template> 00014 00015 #include "../Stabilizer/Integrator.h" 00016 00017 class Convolution { 00018 public: 00019 // if range = 0, integrate from 0 to t. Otherwise, integrate from t - (range - 1) * dt to t. 00020 Convolution(double _dt = 0.005, unsigned int _range = 0); 00021 ~Convolution(void); 00022 void reset(void); 00023 void setup(double _dt, unsigned int _range); 00024 void update(double _f, double _g); 00025 double calculate(void); 00026 private: 00027 double dt; // control cycle 00028 unsigned int range; // integration range (from t_now - range * dt to t_now [sec]) 00029 std::deque<double> f_buffer; // integration data buffer for f 00030 std::deque<double> g_buffer; // integration data buffer for g 00031 long long buffer_size; // buffer size of convolution values (f, g) 00032 Integrator integrator; // convolution(f, g) = integrate(f(x)*g(t-x), x=0, x=t); 00033 }; 00034 00035 #endif // CONVOLUTION_H