Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 #ifndef INCLUDED_SmoothCompareTrans_h_ 00003 #define INCLUDED_SmoothCompareTrans_h_ 00004 00005 #include "Behaviors/Transitions/CompareTrans.h" 00006 00007 //! A subclass of CompareTrans, which provides monitoring of exponentially weighted averages to a threshold 00008 /*! Has the additional requirement that template types must supply operator*=(float) 00009 * and operator+=(T) for the weighted average 00010 * 00011 * The gamma parameter is how much to weight the preceeding value - 1 will cause it to never update, 0 will cause it to only look at most recent. 00012 * So, the lower the value, the faster it is to switch, but more prone to noise 00013 */ 00014 template<class T> 00015 class SmoothCompareTrans : public CompareTrans<T> { 00016 public: 00017 //! constructor, see class notes for information 00018 SmoothCompareTrans(StateNode* source, StateNode* destination, const T* monitor, typename SmoothCompareTrans<T>::Test_t test, const T& value, const EventBase& poll, float gammap=0) 00019 : CompareTrans<T>(source,destination,&avg,test,value,poll), avg(*monitor), realmon(monitor), g(gammap) 00020 { } 00021 00022 //!don't care about the event, just a pulse to check the values 00023 virtual void processEvent(const EventBase& e) { 00024 avg*=g; 00025 T x(*realmon); 00026 x*=(1-g); 00027 avg+=x; 00028 CompareTrans<T>::processEvent(e); 00029 } 00030 protected: 00031 T avg; //!< the current running average 00032 const T* realmon; //!< pointer to the value being monitored 00033 00034 //! the gamma value controlling the exponential average, see the class documentation at the top 00035 float g; 00036 00037 private: 00038 SmoothCompareTrans(const SmoothCompareTrans& node); //!< don't call this 00039 SmoothCompareTrans operator=(const SmoothCompareTrans& node); //!< don't call this 00040 }; 00041 00042 /*! @file 00043 * @brief Defines SmoothCompareTrans, subclass of CompareTrans, which provides monitoring of exponentially weighted averages to a threshold 00044 * @author ejt (Creator) 00045 * 00046 * $Author: ejt $ 00047 * $Name: tekkotsu-1_4_1 $ 00048 * $Revision: 1.4 $ 00049 * $State: Exp $ 00050 * $Date: 2003/03/09 02:45:22 $ 00051 */ 00052 00053 #endif
Tekkotsu v1.4 |
Generated Sat Jul 19 00:06:31 2003 by Doxygen 1.3.2 |