RapidLib  v2.2.0
A simple library for interactive machine learning
rapidStream.h
Go to the documentation of this file.
1 
8 #ifndef rapidStream_h
9 #define rapidStream_h
10 
11 #include <stdint.h>
12 #include <atomic>
13 #include "../dependencies/bayesfilter/src/BayesianFilter.h"
14 
15 namespace rapidLib
16 {
17  template<typename T>
19  {
20  public:
21 
25  rapidStream();
30  rapidStream(std::size_t windowSize);
31 
32  ~rapidStream();
33 
37  void clear();
38 
42  void pushToWindow(T input);
43 
47  T velocity() const;
48 
52  T acceleration() const;
53 
57  T minimum() const;
58 
62  T maximum() const;
63 
67  uint32_t numZeroCrossings() const;
68 
72  T sum() const;
73 
77  T mean() const;
78 
82  T standardDeviation() const;
83 
87  T rms() const;
88 
92  T bayesFilter(T inputValue);
93  void bayesSetDiffusion(float logDiffusion);
94  void bayesSetJumpRate(float jump_rate);
95  void bayesSetMVC(float mvc);
96 
100  T minVelocity() const;
101 
105  T maxVelocity() const;
106 
110  T minAcceleration() const;
111 
115  T maxAcceleration() const;
116 
117  private:
118  std::size_t windowSize;
119  std::atomic<uint32_t> windowIndex;
120  std::vector<T> circularWindow;
121 
122  inline T calcCurrentVel(std::size_t i) const;
123 
124  BayesianFilter bayesFilt;
125  };
126 };
127 
128 #endif
Definition: rapidStream.h:19
void bayesSetMVC(float mvc)
Definition: rapidStream.cpp:204
T standardDeviation() const
Definition: rapidStream.cpp:155
T maxVelocity() const
Definition: rapidStream.cpp:225
T maximum() const
Definition: rapidStream.cpp:97
T minimum() const
Definition: rapidStream.cpp:91
void clear()
Definition: rapidStream.cpp:58
T rms() const
Definition: rapidStream.cpp:168
uint32_t numZeroCrossings() const
Definition: rapidStream.cpp:103
void bayesSetJumpRate(float jump_rate)
Definition: rapidStream.cpp:197
T sum() const
Definition: rapidStream.cpp:143
T maxAcceleration() const
Definition: rapidStream.cpp:256
void bayesSetDiffusion(float logDiffusion)
Definition: rapidStream.cpp:190
~rapidStream()
Definition: rapidStream.cpp:52
T acceleration() const
Definition: rapidStream.cpp:85
void pushToWindow(T input)
Definition: rapidStream.cpp:66
rapidStream()
Definition: rapidStream.cpp:37
T bayesFilter(T inputValue)
Definition: rapidStream.cpp:182
T mean() const
Definition: rapidStream.cpp:149
T minVelocity() const
Definition: rapidStream.cpp:211
T velocity() const
Definition: rapidStream.cpp:79
T minAcceleration() const
Definition: rapidStream.cpp:239
Definition: classification.h:75