vicon
ViconUncertainty.hpp
Go to the documentation of this file.
1 #ifndef VICON_UNCERTAINTY_HPP
2 #define VICON_UNCERTAINTY_HPP
3 
4 #include <Eigen/Core>
5 #include <Eigen/Cholesky>
6 
8 #include <boost/circular_buffer.hpp>
10 namespace vicon {
11  template <typename _EigenMatrixType>
13  {
14  protected:
15  size_t dimension;
16  boost::circular_buffer< _EigenMatrixType > data;
17 
18 
19  public:
20  ViconUncertainty(size_t dimension = 0)
21  {
22  this->dimension = dimension;
23  data = boost::circular_buffer< _EigenMatrixType >(this->dimension);
24  }
25 
26 
27  void push(const _EigenMatrixType& value)
28  {
29  if (this->dimension > 0)
30  {
31  data.push_front(value);
32  }
33  }
34 
35 
36  _EigenMatrixType getMean()
37  {
38  _EigenMatrixType sum;
39  sum.setZero();
40 
41  if (this->dimension > 0)
42  {
43  for(register unsigned int i=0; i<data.size(); ++i)
44  {
45  sum += data[i];
46  }
47  }
48  return sum/data.size();
49  }
50 
51  _EigenMatrixType getVariance()
52  {
53  _EigenMatrixType mean = getMean();
54  _EigenMatrixType temp;
55  temp.setZero();
56 
57  if (this->dimension > 0)
58  {
59  for(register unsigned int i=0; i<data.size(); ++i)
60  {
61  temp += (mean - data[i]) * (mean - data[i]);
62  }
63 
64  }
65  return temp/data.size();
66  }
67 
68  _EigenMatrixType getStdDev()
69  {
70  _EigenMatrixType variance = getVariance();
71  Eigen::LLT< _EigenMatrixType > lltOfVar (variance);
72 
73  return variance.matrixL();
74  }
75 
76  inline size_t size()
77  {
78  return data.size();
79  }
80 
81  inline size_t capacity()
82  {
83  return data.capacity();
84  }
85 
86  public:
87  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
88 
89  };
90 }
91 
92 #endif
boost::circular_buffer< _EigenMatrixType > data
ViconUncertainty(size_t dimension=0)
_EigenMatrixType getVariance()
_EigenMatrixType getMean()
_EigenMatrixType getStdDev()
void push(const _EigenMatrixType &value)