fixed some issues
added new pose/turn detections new helper classes define-flags for libEigen
This commit is contained in:
74
math/filter/Complementary.h
Normal file
74
math/filter/Complementary.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef COMPLEMENTARY_H
|
||||
#define COMPLEMENTARY_H
|
||||
|
||||
#include "../dsp/iir/BiQuad.h"
|
||||
#include "../../math/stats/SampleRateEstimator.h"
|
||||
|
||||
namespace Filter {
|
||||
|
||||
template <typename T> class Complementary {
|
||||
|
||||
private:
|
||||
|
||||
const float fLo;
|
||||
const float fHi;
|
||||
|
||||
IIR::BiQuad<T> lp;
|
||||
IIR::BiQuad<T> hp;
|
||||
|
||||
SampleRateEstimator slp;
|
||||
SampleRateEstimator shp;
|
||||
|
||||
T slow;
|
||||
T fast;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with transition frequency and sample-rate */
|
||||
Complementary(const float fLo, const float fHi) : fLo(fLo), fHi(fHi), slow(), fast() {
|
||||
//adjust();
|
||||
}
|
||||
|
||||
void addSlow(const Timestamp ts, const T& slow) {
|
||||
slp.update(ts);
|
||||
this->slow = lp.filter(slow);
|
||||
adjustLP();
|
||||
}
|
||||
|
||||
void addFast(const Timestamp ts, const T& fast) {
|
||||
shp.update(ts);
|
||||
this->fast = hp.filter(fast);
|
||||
adjustHP();
|
||||
}
|
||||
|
||||
T get() const {
|
||||
return slow+fast;
|
||||
}
|
||||
|
||||
T getLo() const {
|
||||
return slow;
|
||||
}
|
||||
|
||||
T getHi() const {
|
||||
return fast;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void adjustLP() {
|
||||
const float freqLP = slp.getCurHz();
|
||||
//std::cout << freqLP << ":" << freqHP << std::endl;
|
||||
if (freqLP > fLo*2) {lp.setLowPass(fLo, 0.707, freqLP);}
|
||||
}
|
||||
|
||||
void adjustHP() {
|
||||
const float freqHP = slp.getCurHz();
|
||||
//std::cout << freqLP << ":" << freqHP << std::endl;
|
||||
if (freqHP > fHi*2) {hp.setHighPass(fHi, 0.707, freqHP);}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // COMPLEMENTARY_H
|
||||
Reference in New Issue
Block a user