fix: RunningQuality must add ssf, not add beat
This commit is contained in:
@@ -81,10 +81,11 @@ TEST(SignalTest, ranges) {
|
||||
class DebugRunningQuality : public RunningQuality {
|
||||
protected:
|
||||
virtual void dispatchLocked() { locked = true; }
|
||||
virtual void dispatchBeat(int idx, bool good, double posCorr) { corrs.push_back(posCorr); }
|
||||
virtual void dispatchBeat(int idx, bool good, double posCorr) { goods.push_back(good); corrs.push_back(posCorr); }
|
||||
|
||||
bool locked;
|
||||
std::vector<double> corrs;
|
||||
std::vector<bool> goods;
|
||||
|
||||
public:
|
||||
DebugRunningQuality(): locked(false) {}
|
||||
@@ -92,6 +93,7 @@ public:
|
||||
virtual ~DebugRunningQuality() {}
|
||||
bool isLocked() { return locked; }
|
||||
std::vector<double> getCorrs() { return corrs; }
|
||||
std::vector<bool> getGoods() { return goods; }
|
||||
std::vector<double> getBeatTemplate() { return this->beatTemplate; }
|
||||
};
|
||||
|
||||
@@ -210,4 +212,7 @@ TEST(SignalTest, RunningQuality_t2) {
|
||||
|
||||
std::vector<double> corrs(sqi.getCorrs());
|
||||
npy_save("test3/ssf_t3_sqi_corrs.npy", corrs);
|
||||
|
||||
std::vector<bool> goods(sqi.getGoods());
|
||||
npy_save("test3/ssf_t3_sqi_goods.npy", goods);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@ void npy_save(std::string path, std::vector<double>& x) {
|
||||
d.shape = {(unsigned long) x.size()};
|
||||
npy::write_npy(path, d);
|
||||
}
|
||||
void npy_save(std::string path, std::vector<bool>& x) {
|
||||
npy::npy_data_ptr<int> d;
|
||||
std::vector<int> xx(x.begin(), x.end());
|
||||
d.data_ptr = xx.data();
|
||||
d.shape = {(unsigned long) x.size()};
|
||||
npy::write_npy(path, d);
|
||||
}
|
||||
|
||||
std::vector<double> fetch_y_axis(npy::npy_data<double>& acc) {
|
||||
// TODO: later on, we should use a vector projection towards gravity
|
||||
|
||||
@@ -20,6 +20,7 @@ template <typename T> static std::vector<double> apply_filter(T& filter, std::ve
|
||||
}
|
||||
|
||||
void npy_save(std::string path, std::vector<double>& x);
|
||||
void npy_save(std::string path, std::vector<bool>& x);
|
||||
|
||||
std::vector<double> fetch_y_axis(npy::npy_data<double>& acc);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "pd_signal.h"
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
static std::vector<double> make_ones(size_t sw) {
|
||||
@@ -138,19 +139,19 @@ void RunningQuality::append(std::vector<double> &rawBeat, std::vector<double> &r
|
||||
if (beatTemplates.size() == 0) {
|
||||
// cannot correlate the first beat, no template yet
|
||||
std::cerr << "(0) first beat -> addTemplate()" << std::endl;
|
||||
addTemplate(beat);
|
||||
addTemplate(ssf);
|
||||
justLocked = false;
|
||||
} else if (beatTemplates.size() <= 2) {
|
||||
// restart if there is no clear correlation between beats
|
||||
if (goodBeat) {
|
||||
std::cerr << "(2) good initial beat -> addTemplate()" << std::endl;
|
||||
addTemplate(beat);
|
||||
addTemplate(ssf);
|
||||
if (beatTemplates.size() > 2)
|
||||
justLocked = true; // TODO why not set? wrong compiler optimization? (is it unaware of member change?)
|
||||
//std::cerr << " (2) beatTemplates.size()=" << beatTemplates.size() << " justLocked=" << ((int) justLocked) << std::endl;
|
||||
} else {
|
||||
std::cerr << "(2) bad initial beat -> replaceTemplate()" << std::endl;
|
||||
replaceTemplate(beat);
|
||||
std::cerr << "(2) bad initial beat idx=" << idx << " -> replaceTemplate() corr=" << std::fixed << std::setw(7) << std::setprecision(4) << corr << " checkedSsf=" << checkedSsf << std::endl;
|
||||
replaceTemplate(ssf);
|
||||
//badBeatRanges.clear();
|
||||
justLocked = false;
|
||||
}
|
||||
@@ -159,7 +160,7 @@ void RunningQuality::append(std::vector<double> &rawBeat, std::vector<double> &r
|
||||
|
||||
std::cerr << "(3) running mode, good=" << ((int) goodBeat) << " justLocked=" << ((int) justLocked) << std::endl;
|
||||
if (goodBeat) {
|
||||
addTemplate(beat);
|
||||
addTemplate(ssf);
|
||||
} else {
|
||||
// badBeatRanges.add(s, e)
|
||||
// numNoisy++
|
||||
|
||||
Reference in New Issue
Block a user