Curves
A library for curves generation.
SamplingPolicy.hpp
Go to the documentation of this file.
1 /*
2  * @file SamplingPolicy.hpp
3  * @date Mar 02, 2015
4  * @author Abel Gawel
5  */
6 
7 #ifndef SAMPLING_POLICY_HPP
8 #define SAMPLING_POLICY_HPP
9 
10 #include <typeinfo>
11 
12 namespace curves {
13 
15 
16  protected:
21 
22  public:
23 
25  measurementsSinceLastExtend_(0),
26  minimumMeasurements_(1),
27  minSamplingPeriod_(0),
28  lastExtend_(0) {};
29 
30  SamplingPolicy(int minimumMeasurements, Time minSamplingPeriod) :
31  minimumMeasurements_(minimumMeasurements),
32  measurementsSinceLastExtend_(0),
33  minSamplingPeriod_(minSamplingPeriod),
34  lastExtend_(0) {};
35 
37 
38  template<typename CurveType, typename ValueType>
40  const ValueType& value,
41  CurveType* curve) {
42  CHECK(false) << "no interpolation extend policy implemented for " << typeid(CurveType).name();
43  }
44 
45  template<typename CurveType, typename ValueType>
46  Key defaultExtend(const Time& time,
47  const ValueType& value,
48  CurveType* curve) {
49  CHECK(false) << "no default extend policy implemented for " << typeid(CurveType).name();
50  }
51 
52  template<typename CurveType, typename ValueType>
53  void extend(const std::vector<Time>& times,
54  const std::vector<ValueType>& values,
55  CurveType* curve,
56  std::vector<Key>* outKeys = NULL) {
57  CHECK(false) << "no extend policy implemented for " << typeid(CurveType).name();
58  }
59 
63  }
64 
66  return minimumMeasurements_;
67  }
68 
70  return minSamplingPeriod_;
71  }
72 
74  return lastExtend_;
75  }
76 
77  void setLastExtendTime(Time time) {
78  lastExtend_ = time;
79  }
80 
81  void setMinimumMeasurements(int n) {
82  minimumMeasurements_ = n;
83  }
84 
85  void setMinSamplingPeriod(Time minSamplingPeriod) {
86  minSamplingPeriod_ = minSamplingPeriod;
87  }
88 
90  measurementsSinceLastExtend_ = measurementsSinceLastExtend_ + num;
91  }
92 
94  measurementsSinceLastExtend_ = num;
95  }
96 };
97 
98 } // namespace curves
99 
100 #endif /* SAMPLING_POLICY_HPP */
void setMeasurementsSinceLastExtend_(int num)
SE3Curve::ValueType ValueType
Key defaultExtend(const Time &time, const ValueType &value, CurveType *curve)
Key interpolationExtend(const Time &time, const ValueType &value, CurveType *curve)
void setLastExtendTime(Time time)
void setMinimumMeasurements(int n)
void incrementMeasurementsTaken(int num)
double Time
Definition: Curve.hpp:13
void setMinSamplingPeriod(Time minSamplingPeriod)
int getMeasurementsSinceLastExtend()
Print the value of the coefficient, for debugging and unit tests.
void extend(const std::vector< Time > &times, const std::vector< ValueType > &values, CurveType *curve, std::vector< Key > *outKeys=NULL)
SamplingPolicy(int minimumMeasurements, Time minSamplingPeriod)
size_t Key
Definition: Curve.hpp:14