This commit is contained in:
toni
2016-04-22 12:27:47 +02:00

View File

@@ -7,6 +7,7 @@
#include <Indoor/math/MovingAVG.h>
#include <Indoor/math/MovingMedian.h>
#include <Indoor/grid/walk/GridWalk.h>
#include <KLib/math/statistics/Statistics.h>
@@ -27,7 +28,8 @@ private:
Activity current = Activity::UNKNOWN;
K::Statistics<float> mag;
K::Statistics<float> hpa;
//K::Statistics<float> hpa;
std::vector<float> hpa;
MovingMedian<float> hpaAvg;
@@ -45,10 +47,11 @@ public:
/** add barometer values */
void addBaro(float hpa) {
hpaAvg.add(hpa);
float smoothed = hpaAvg.get();
this->hpa.add(smoothed);
if (this->hpa.getCount() > 50) {analyze();}
//hpaAvg.add(hpa);
//float smoothed = hpaAvg.get();
//this->hpa.add(smoothed);
this->hpa.push_back(hpa);
if (this->hpa.size() > 40) {analyze();}
}
struct ActClass {
@@ -85,18 +88,24 @@ public:
if (mag.getStdDev() < 0.3) {
current = Activity::STANDING;
} else if (mag.getStdDev() < 3) {
current = Activity::WALKING;
} else {
if (hpa.getRange() > 0.035) {
current = Activity::STAIRS;
float hpaD = hpa.front() - hpa.back();
if (hpaD > 0.01) {
current = Activity::STAIRS_UP;
} else if (hpaD < -0.01) {
current = Activity::STAIRS_DOWN;
} else {
current = Activity::WALKING;
}
}
// current = (Activity) idx;
// current = Activity::UNKNOWN;
mag.reset();
hpa.reset();
hpa.clear();
}
@@ -110,7 +119,8 @@ public:
case Activity::UNKNOWN: return "unknown";
case Activity::STANDING: return "standing";
case Activity::WALKING: return "walking";
case Activity::STAIRS: return "stairs";
case Activity::STAIRS_UP: return "stairs up";
case Activity::STAIRS_DOWN: return "stairs down";
case Activity::ELEVATOR: return "elevator";
}
throw "should not happen";