fixed some issues
added new pose/turn detections new helper classes define-flags for libEigen
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <vector>
|
||||
#include "../data/Timestamp.h"
|
||||
#include <algorithm>
|
||||
#include "KahanSum.h"
|
||||
|
||||
template <typename T> class MovingAverageTS {
|
||||
|
||||
@@ -22,14 +23,19 @@ private:
|
||||
/** the value history for the window-size */
|
||||
std::vector<Entry> history;
|
||||
|
||||
const T zero;
|
||||
|
||||
/** current sum */
|
||||
T sum;
|
||||
|
||||
/** more exact running summation of many values */
|
||||
KahanSum<T> kSum;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/** ctor with the window-size to use */
|
||||
MovingAverageTS(const Timestamp window, const T zeroElement) : window(window), sum(zeroElement) {
|
||||
MovingAverageTS(const Timestamp window, const T zeroElement) : window(window), zero(zeroElement), sum(zeroElement), kSum(zeroElement) {
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +47,7 @@ public:
|
||||
|
||||
// adjust sum
|
||||
sum += data;
|
||||
kSum += data;
|
||||
|
||||
// remove too-old history entries
|
||||
const Timestamp oldest = ts - window;
|
||||
@@ -48,6 +55,7 @@ public:
|
||||
|
||||
// adjust sum
|
||||
sum -= history.front().value;
|
||||
kSum -= history.front().value;
|
||||
|
||||
// remove from history
|
||||
history.erase(history.begin());
|
||||
@@ -56,11 +64,31 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** get the current average */
|
||||
T get() const {
|
||||
/** get the current average (with increasing error due to float sum!) */
|
||||
T getOldAPX() const {
|
||||
return sum / history.size();
|
||||
}
|
||||
|
||||
/** get the current average */
|
||||
T get() const {
|
||||
return kSum.get() / history.size();
|
||||
}
|
||||
|
||||
// T get() const {
|
||||
|
||||
// T sum = zero;
|
||||
// volatile T comp = zero;
|
||||
// for (const auto e : history) {
|
||||
// T inp = e.value;
|
||||
// T y = inp - comp;
|
||||
// T t = sum + y;
|
||||
// comp = (t-sum) - y;
|
||||
// sum = t;
|
||||
// }
|
||||
|
||||
// return sum / history.size();
|
||||
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user