removed Heading::rnd()

changed particle init
fixed uninitialized values
new ground-truth helper methods
added new stats to the eval (distance from ground-truth)
This commit is contained in:
kazu
2016-04-26 11:55:13 +02:00
parent f7e817d5e4
commit 9eb774f7b9
6 changed files with 50 additions and 16 deletions

View File

@@ -196,6 +196,8 @@ public:
K::Statistics<double> statsFiltering;
K::Statistics<double> statsSmoothing;
K::Statistics<float> statsDistFiltering;
K::Statistics<float> statsDistSmoothing;
int cnt = 0;
// error per update-step
@@ -245,12 +247,12 @@ public:
break;
}
case s_accel: {
float acc[3];
SensorReaderAccel sre; sre.read(se, acc);
actDet.addAccel(acc);
break;
}
case s_accel: {
float acc[3];
SensorReaderAccel sre; sre.read(se, acc);
actDet.addAccel(acc);
break;
}
// case s_linearAcceleration:{
// baroSensorReader.readVerticalAcceleration(se);
@@ -297,7 +299,6 @@ public:
// timed updates
((MyTransition*)pf->getTransition())->setCurrentTime(lastTransitionTS);
// update the particle filter (transition + eval), estimate a new current position and add it to the estimated path
const MyState est = pf->update(&ctrl, obs);
const Point3 curEst = est.pCur;
@@ -315,6 +316,7 @@ public:
pathEst.push_back(curEst);
const float err = diff.length();
const float errDist = gtw.getMinDist(curEst); // minimum distance between estimation and ground-truth
@@ -323,8 +325,10 @@ public:
if (cnt > 35) {
statsFiltering.add(err);
statsDistFiltering.add(errDist);
errorsNorm.push_back(err);
std::cout << "Filtering: " << se.ts << " " << statsFiltering.asString() << std::endl;
std::cout << "FilteringTime: " << se.ts << " " << statsFiltering.asString() << std::endl;
std::cout << "FilteringDist: " << se.ts << " " << statsDistFiltering.asString() << std::endl;
}
if(cnt > skip){
@@ -363,10 +367,14 @@ public:
const float errSmoothed = diffSmoothed.length();
const float errDistSmoothed = gtw.getMinDist(curSmoothedEst); // minimum distance between smoothed-estimation and ground-truth
statsSmoothing.add(errSmoothed);
statsDistSmoothing.add(errDistSmoothed);
errorsSmooth.push_back(errSmoothed);
std::cout << "Smoothing: " << tsHistory[(tsHistory.size() - 1) - MiscSettings::lag] << " " << statsSmoothing.asString() << std::endl;
std::cout << "SmoothingTime: " << tsHistory[(tsHistory.size() - 1) - MiscSettings::lag] << " " << statsSmoothing.asString() << std::endl;
std::cout << "SmoothingDist: " << tsHistory[(tsHistory.size() - 1) - MiscSettings::lag] << " " << statsDistSmoothing.asString() << std::endl;
//plot
vis.clearStates();

View File

@@ -18,6 +18,29 @@ public:
/** get the ground truth way */
const std::vector<InterpolatorEntry>& getWay() const {return entries;}
/** get the time where the ground-truth is nearest to p */
uint64_t getNearestTime(const Point3 p) const {
// TODO only an approximation (100ms) -> minor errors possible
float minD = INFINITY;
uint64_t minTS = 0;
for (uint64_t ts = getMinKey(); ts <= getMaxKey(); ts += 100) {
const Point3 cur = getPosAtTime(ts);
const float curD = cur.getDistance(p);
if (curD < minD) {minD = curD; minTS = ts;}
}
return minTS;
}
/** get the minimum distance between the given point and the ground-truth (at any time) */
float getMinDist(const Point3 p1) const {
const uint64_t minTS = getNearestTime(p1);
const Point3 p2 = getPosAtTime(minTS);
return p1.getDistance(p2);
}
};

View File

@@ -1,6 +1,7 @@
#ifndef PAPERVISIMPORTANCE_H
#define PAPERVISIMPORTANCE_H
/*
#include <Indoor/grid/Grid.h>
#include <Indoor/grid/factory/GridFactory.h>
#include <Indoor/grid/factory/GridImportance.h>
@@ -275,5 +276,6 @@ public:
};
*/
#endif // PAPERVISIMPORTANCE_H

View File

@@ -37,6 +37,7 @@ public:
std::minstd_rand gen;
std::uniform_int_distribution<> dist(0, grid.getNumNodes());
std::uniform_real_distribution<float> distHead(0, M_PI*2);
for (K::Particle<MyState>& p : particles) {
@@ -50,7 +51,7 @@ public:
p.state.walkState.node = &n;
p.state.pOld = p.state.pCur;
p.state.walkState.heading = Heading::rnd();
p.state.walkState.heading = distHead(gen);
p.state.hPa = 0;
}

View File

@@ -25,18 +25,18 @@ struct MyState {
GridWalkState<MyGridNode> walkState;
// cumulative heading
double cumulativeHeading;
double cumulativeHeading = 0;
// save last hPa measurement for the smoothing process
double measurement_pressure;
double measurement_pressure = 0;
// save last angularHeadingChangefor the smoothing process in Degree
double angularHeadingChange;
double angularHeadingChange = 0;
double avgAngle;
double avgAngle = 0;
//the current Activity
Activity currentActivity;
Activity currentActivity = Activity::UNKNOWN;
//int distanceWalkedCM;

View File

@@ -88,7 +88,7 @@ public:
// update the old heading and the other old values
//p.state.walkState.heading = p.state.heading;
if(!(p.state.pOld == p.state.pCur)){
p.state.cumulativeHeading = Angle::getDEG_360(p.state.pOld.x, p.state.pOld.y, p.state.pCur.x, p.state.pCur.y);
p.state.cumulativeHeading = Angle::getDEG_360(p.state.pOld.x, p.state.pOld.y, p.state.pCur.x, p.state.pCur.y);
}
p.state.pOld = p.state.pCur;