Changeset 14:124f25d79a76 in rrlib_data_fusion


Ignore:
Timestamp:
03.07.2012 13:27:23 (7 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Added specialization for tAngle

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tAverage.h

    r12 r14  
    4343//---------------------------------------------------------------------- 
    4444#ifdef _LIB_RRLIB_MATH_PRESENT_ 
     45#include "rrlib/math/tAngle.h" 
    4546#include "rrlib/math/tPose2D.h" 
    4647#include "rrlib/math/tPose3D.h" 
     
    118119#ifdef _LIB_RRLIB_MATH_PRESENT_ 
    119120 
     121template <typename TElement, typename TUnitPolicy, typename TSignedPolicy, template <typename> class TChannel> 
     122class tAverage<math::tAngle<TElement, TUnitPolicy, TSignedPolicy>, TChannel> : public tDataFusion<math::tAngle<TElement, TUnitPolicy, TSignedPolicy>, TChannel> 
     123{ 
     124 
     125  typedef math::tAngle<TElement, TUnitPolicy, TSignedPolicy> tAngle; 
     126 
     127//---------------------------------------------------------------------- 
     128// Private fields and methods 
     129//---------------------------------------------------------------------- 
     130private: 
     131 
     132  virtual const char *GetLogDescription() const 
     133  { 
     134    return "tWeightedAverage<math::tAngle<...>>"; 
     135  } 
     136 
     137  virtual const bool HasValidState() const 
     138  { 
     139    return true; 
     140  } 
     141 
     142  virtual const tAngle CalculateFusedValue(const std::vector<TChannel<tAngle>> &channels) 
     143  { 
     144    double accumulated_value = 0; 
     145    for (typename std::vector<TChannel<tAngle>>::const_iterator it = channels.begin(); it != channels.end(); ++it) 
     146    { 
     147      accumulated_value += static_cast<double>(it->GetSample()); 
     148    } 
     149    return tAngle(accumulated_value / channels.size()); 
     150  } 
     151 
     152  virtual void ResetStateImplementation() 
     153  {} 
     154 
     155  virtual void EnterNextTimestepImplementation() 
     156  {} 
     157 
     158}; 
     159 
    120160template <template <typename> class TChannel> 
    121161class tAverage<math::tPose2D, TChannel> : public tDataFusion<math::tPose2D, TChannel> 
  • tWeightedAverage.h

    r12 r14  
    4343//---------------------------------------------------------------------- 
    4444#ifdef _LIB_RRLIB_MATH_PRESENT_ 
     45#include "rrlib/math/tAngle.h" 
    4546#include "rrlib/math/tPose2D.h" 
    4647#include "rrlib/math/tPose3D.h" 
     
    120121#ifdef _LIB_RRLIB_MATH_PRESENT_ 
    121122 
     123template <typename TElement, typename TUnitPolicy, typename TSignedPolicy, template <typename> class TChannel> 
     124class tWeightedAverage<math::tAngle<TElement, TUnitPolicy, TSignedPolicy>, TChannel> : public tDataFusion<math::tAngle<TElement, TUnitPolicy, TSignedPolicy>, TChannel> 
     125{ 
     126 
     127  typedef math::tAngle<TElement, TUnitPolicy, TSignedPolicy> tAngle; 
     128 
     129//---------------------------------------------------------------------- 
     130// Private fields and methods 
     131//---------------------------------------------------------------------- 
     132private: 
     133 
     134  virtual const char *GetLogDescription() const 
     135  { 
     136    return "tWeightedAverage<math::tAngle<...>>"; 
     137  } 
     138 
     139  virtual const bool HasValidState() const 
     140  { 
     141    return true; 
     142  } 
     143 
     144  virtual const tAngle CalculateFusedValue(const std::vector<TChannel<tAngle>> &channels) 
     145  { 
     146    double accumulated_value = 0; 
     147    double accumulated_weights = 0; 
     148    for (typename std::vector<TChannel<tAngle>>::const_iterator it = channels.begin(); it != channels.end(); ++it) 
     149    { 
     150      accumulated_value += static_cast<double>(it->GetSample()) * it->GetKey(); 
     151      accumulated_weights += it->GetKey(); 
     152    } 
     153    return tAngle(accumulated_value / accumulated_weights); 
     154  } 
     155 
     156  virtual void ResetStateImplementation() 
     157  {} 
     158 
     159  virtual void EnterNextTimestepImplementation() 
     160  {} 
     161 
     162}; 
     163 
    122164template <template <typename> class TChannel> 
    123165class tWeightedAverage<math::tPose2D, TChannel> : public tDataFusion<math::tPose2D, TChannel> 
Note: See TracChangeset for help on using the changeset viewer.