fixed some issues
added new pose/turn detections new helper classes define-flags for libEigen
This commit is contained in:
41
math/stats/SampleRateEstimator.h
Normal file
41
math/stats/SampleRateEstimator.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef SAMPLERATEESTIMATOR_H
|
||||
#define SAMPLERATEESTIMATOR_H
|
||||
|
||||
#include "../../data/Timestamp.h"
|
||||
|
||||
class SampleRateEstimator {
|
||||
|
||||
private:
|
||||
|
||||
const double a = 0.99;
|
||||
double curHz = 0;
|
||||
Timestamp tsLast;
|
||||
|
||||
public:
|
||||
|
||||
float update(const Timestamp ts) {
|
||||
|
||||
// first
|
||||
if (tsLast.isZero()) {
|
||||
tsLast = ts;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const double diffSec = static_cast<double>((ts-tsLast).sec());
|
||||
tsLast = ts;
|
||||
|
||||
if (diffSec != 0) {
|
||||
curHz = a*curHz + (1-a) * (1.0/diffSec);
|
||||
}
|
||||
|
||||
return static_cast<float>(curHz);
|
||||
|
||||
}
|
||||
|
||||
float getCurHz() const {
|
||||
return static_cast<float>(curHz);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SAMPLERATEESTIMATOR_H
|
||||
Reference in New Issue
Block a user