fir_diff_filter.h
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <numeric>
00003 
00004 struct FIRDiffFilter {
00005     std::vector<double> history;
00006     int step;
00007     double coll_sig, time_const;
00008 
00009     FIRDiffFilter(int history_size=15, double time_constant=0.01) : 
00010                                       history(history_size), step(0), coll_sig(0.0),
00011                                       time_const(time_constant) {
00012     }
00013     double updateState(double z_obs) {
00014         // find the average value over the past few steps
00015         double avg = std::accumulate(history.begin(), history.end(), 0.0) / history.size();
00016         // exponential zeroing filter
00017         // rapidly increases with every observation far from average
00018         coll_sig = time_const * (coll_sig + z_obs - avg);
00019         // add this observation to the history buffer
00020         history[step % history.size()] = z_obs;
00021         step++;
00022         // return current state
00023         return std::fabs(coll_sig);
00024     }
00025 };


pr2_collision_monitor
Author(s): Kelsey Hawkins, Advisor: Prof. Charlie Kemp (Healthcare Robotics Lab at Georgia Tech)
autogenerated on Wed Nov 27 2013 11:40:10