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