code that runs the final eval
TeX update
This commit is contained in:
136
pf/EvalWalk.h
136
pf/EvalWalk.h
@@ -45,7 +45,7 @@
|
||||
#include <Indoor/sensors/offline/Listener.h>
|
||||
|
||||
|
||||
#define PLOT_LIVE
|
||||
//#define PLOT_LIVE
|
||||
//#define PLOT_WIFI
|
||||
//#define PLOT_ERROR_TIME
|
||||
//#define PLOT_ERROR_FUNC
|
||||
@@ -60,10 +60,21 @@ class EvalWalk : public Offline::Listener {
|
||||
|
||||
std::string runName;
|
||||
|
||||
#ifdef PLOT_LIVE
|
||||
Plotty plotty;
|
||||
#endif
|
||||
|
||||
#ifdef PLOT_WIFI
|
||||
PlotWifiMeasurements plotWifi;
|
||||
#endif
|
||||
|
||||
#ifdef PLOT_ERROR_TIME
|
||||
PlotErrTime pet;
|
||||
#endif
|
||||
|
||||
#ifdef PLOT_ERROR_FUNC
|
||||
PlotErrFunc pef;
|
||||
#endif
|
||||
|
||||
Offline::FileReader reader;
|
||||
Offline::FilePlayer player;
|
||||
@@ -91,15 +102,34 @@ class EvalWalk : public Offline::Listener {
|
||||
|
||||
public:
|
||||
|
||||
EvalWalk(Floorplan::IndoorMap* map) : plotty(map), map(map), em(map),
|
||||
pet("\\small{time (sec)}", "\\small{error (m)}", "\\small{APs visible}"),
|
||||
pef("\\small{error (m)}", "\\small{updates (\\%)}") {
|
||||
~EvalWalk() {
|
||||
delete grid;
|
||||
delete pf;
|
||||
}
|
||||
|
||||
EvalWalk(Floorplan::IndoorMap* map) :
|
||||
|
||||
#ifdef PLOT_LIVE
|
||||
plotty(map),
|
||||
#endif
|
||||
|
||||
map(map), em(map)
|
||||
|
||||
#ifdef PLOT_ERROR_TIME
|
||||
,pet("\\small{time (sec)}", "\\small{error (m)}", "\\small{APs visible}")
|
||||
#endif
|
||||
#ifdef PLOT_ERROR_FUNC
|
||||
,pef("\\small{error (m)}", "\\small{updates (\\%)}")
|
||||
#endif
|
||||
{
|
||||
|
||||
const std::string saveFile = Settings::pathData + "/grid.dat";
|
||||
grid = new Grid<MyGridNode>(Settings::Grid::gridSize_cm);
|
||||
|
||||
// once
|
||||
plotty.buildFloorplan();
|
||||
#ifdef PLOT_LIVE
|
||||
// once
|
||||
plotty.buildFloorplan();
|
||||
#endif
|
||||
|
||||
// deserialize grid
|
||||
std::ifstream inp(saveFile, std::ofstream::binary);
|
||||
@@ -173,12 +203,13 @@ public:
|
||||
|
||||
struct LeModel {
|
||||
std::string name;
|
||||
std::string plotKey;
|
||||
WiFiModel* model;
|
||||
LeModel(const std::string& name, WiFiModel* model) : name(name), model(model) {;}
|
||||
LeModel(const std::string& name, const std::string& plotKey, WiFiModel* model) : name(name), plotKey(plotKey), model(model) {;}
|
||||
};
|
||||
|
||||
static void serialize(const K::Statistics<float>& stats, const LeWalk& walk, const LeModel& model, const int idx) {
|
||||
const std::string file = Settings::fPathGFX + "/walks/data/" + walk.name + "_" + model.name + "_" + std::to_string(idx) + ".txt";
|
||||
const std::string file = Settings::fPathGFX + "/walks/data/" + model.name + "/" + walk.name + "_" + model.name + "_" + std::to_string(idx) + ".txt";
|
||||
std::ofstream out(file);
|
||||
for (const float f : stats.getAll()) {
|
||||
out << f << "\n";
|
||||
@@ -187,7 +218,7 @@ public:
|
||||
}
|
||||
|
||||
static K::Statistics<float>* deserialize(const LeWalk& walk, const LeModel& model, const int idx) {
|
||||
const std::string file = Settings::fPathGFX + "/walks/data/" + walk.name + "_" + model.name + "_" + std::to_string(idx) + ".txt";
|
||||
const std::string file = Settings::fPathGFX + "/walks/data/" + model.name + "/" + walk.name + "_" + model.name + "_" + std::to_string(idx) + ".txt";
|
||||
K::Statistics<float>* res = new K::Statistics<float>();
|
||||
std::ifstream inp(file);
|
||||
while(inp) {
|
||||
@@ -221,16 +252,16 @@ public:
|
||||
static std::vector<LeModel> allModels(Floorplan::IndoorMap* map) {
|
||||
WiFiModelFactory fac(map);
|
||||
return {
|
||||
//LeModel("empiric", fac.loadXML(Settings::wifiAllFixed)),
|
||||
//LeModel("opt 1", fac.loadXML(Settings::wifiAllOptPar)),
|
||||
//LeModel("opt 2", fac.loadXML(Settings::wifiEachOptPar)),
|
||||
//LeModel("opt 3", fac.loadXML(Settings::wifiEachOptParPos)),
|
||||
//LeModel("per floor", fac.loadXML(Settings::wifiEachOptParPos_multimodel)),
|
||||
LeModel("per bbox", fac.loadXML(Settings::wifiEachOptParPos_perBBox)),
|
||||
LeModel("empiric", "\\noOptEmpiric{}", fac.loadXML(Settings::wifiAllFixed)),
|
||||
LeModel("opt 1", "\\optParamsAllAP{}", fac.loadXML(Settings::wifiAllOptPar)),
|
||||
LeModel("opt 2", "\\optParamsEachAP{}", fac.loadXML(Settings::wifiEachOptPar)),
|
||||
LeModel("opt 3", "\\optParamsPosEachAP{}", fac.loadXML(Settings::wifiEachOptParPos)),
|
||||
LeModel("per floor", "\\optPerFloor{}", fac.loadXML(Settings::wifiEachOptParPos_multimodel)),
|
||||
LeModel("per bbox", "\\optPerRegion{}", fac.loadXML(Settings::wifiEachOptParPos_perBBox)),
|
||||
};
|
||||
}
|
||||
|
||||
static constexpr int numRepeats = 1;
|
||||
static constexpr int numRepeats = 25;
|
||||
|
||||
/** create GFX for all previously walked parts */
|
||||
static void walkEverythingBuildStats(Floorplan::IndoorMap* map) {
|
||||
@@ -239,8 +270,10 @@ public:
|
||||
const std::vector<LeModel> models = allModels(map);
|
||||
|
||||
PlotErrFunc* pefAll = new PlotErrFunc();
|
||||
int numStuck = 0;
|
||||
int numTotal = 0;
|
||||
pefAll->setYRange(0, 90, 5);
|
||||
pefAll->getPlot().getAxisY().setRange(0, 90);
|
||||
pefAll->getPlot().getAxisY().setTicsStep({0, 25, 50, 75, 90});
|
||||
pefAll->getPlot().getAxisX().setRange(0, 15);
|
||||
|
||||
for (const LeModel& mdl : models) {
|
||||
|
||||
@@ -248,34 +281,71 @@ public:
|
||||
K::Statistics<float>* modelStatsMed = new K::Statistics<float>();
|
||||
|
||||
K::Statistics<float>* modelStatsSingle = new K::Statistics<float>();
|
||||
pefAll->add(mdl.name, modelStatsSingle);
|
||||
pefAll->add(mdl.plotKey, modelStatsSingle);
|
||||
|
||||
|
||||
int numStuck = 0;
|
||||
int numTotal = 0;
|
||||
|
||||
std::cout << "model " << mdl.name << std::endl;
|
||||
|
||||
|
||||
// ... to perform every walk...
|
||||
for (const LeWalk& walk : walks) {
|
||||
|
||||
for (int i = 0; i < numRepeats; ++i) {
|
||||
int numStuckWalk = 0;
|
||||
int numTotalWalk = 0;
|
||||
|
||||
// stats for all runs of one walk
|
||||
K::Statistics<float> walkStatsAvg;
|
||||
|
||||
for (int i = 0; i < 75; ++i) {
|
||||
|
||||
++numTotal;
|
||||
++numTotalWalk;
|
||||
|
||||
K::Statistics<float>* walkStats = deserialize(walk, mdl, i);
|
||||
|
||||
if (walkStats->getMedian() < 10) {
|
||||
modelStatsSingle->add(*walkStats);
|
||||
pefAll->plot();
|
||||
//if (walkStats->getMedian() < 15) {
|
||||
if (walkStats->getQuantile(0.75) < 20) {
|
||||
//modelStatsSingle->add(*walkStats);
|
||||
} else {
|
||||
++numStuck;
|
||||
++numStuckWalk;
|
||||
}
|
||||
|
||||
modelStatsSingle->add(*walkStats);
|
||||
walkStatsAvg.add(*walkStats);
|
||||
|
||||
}
|
||||
|
||||
if (modelStatsSingle->getCount() > 0) {
|
||||
pefAll->plot();
|
||||
}
|
||||
|
||||
std::cout << "|" << walk.name << "(" << walkStatsAvg.getMedian() << "@" << (numStuckWalk*100/numTotalWalk) << "%)\t";
|
||||
|
||||
}
|
||||
|
||||
std::cout << " | OVERALL:" << "(" << modelStatsSingle->getMedian() << "@" << (numStuck*100/numTotal) << "%)" << std::endl;
|
||||
sleep(1);
|
||||
|
||||
}
|
||||
|
||||
std::cout << "stuck: " << numStuck << " (" << (numStuck*100/numTotal) << "%)" << std::endl;
|
||||
pefAll->getGP().setTerminal("epslatex", K::GnuplotSize(8.6, 3.7));
|
||||
pefAll->getGP().setOutput(Settings::fPathGFX + "/overall-system-error.tex");
|
||||
pefAll->writePlotToFile(Settings::fPathGFX + "/overall-system-error.gp");
|
||||
pefAll->getPlot().getMargin().set(4, 0.2, 0.1, 1.8);
|
||||
pefAll->getPlot().setStringMod(new K::GnuplotStringModLaTeX());
|
||||
pefAll->getPlot().getKey().setVisible(true);
|
||||
pefAll->getPlot().getKey().setPosition(K::GnuplotKey::Hor::RIGHT, K::GnuplotKey::Ver::BOTTOM);
|
||||
pefAll->getPlot().getKey().setWidthIncrement(7);
|
||||
pefAll->getPlot().getAxisX().setTicsLabelFormat("%h m");
|
||||
pefAll->getPlot().getAxisX().setRange(0, 22);
|
||||
pefAll->getPlot().getAxisX().setLabel("");
|
||||
pefAll->getPlot().getAxisY().setLabel("filter updates (%)");
|
||||
pefAll->getPlot().getAxisY().setLabelOffset(3.0, 0);
|
||||
pefAll->plot();
|
||||
|
||||
sleep(100);
|
||||
|
||||
@@ -303,7 +373,8 @@ public:
|
||||
//K::Statistics<float> curWalkRepeatStatsMed;
|
||||
|
||||
// ... several times
|
||||
for (int i = 0; i < numRepeats; ++i) {
|
||||
//#pragma omp parallel for num_threads(2)
|
||||
for (int i = numRepeats*2; i < numRepeats*3; ++i) {
|
||||
|
||||
EvalWalk ew(map);
|
||||
ew.walkName = walk.name + " - " + mdl.name + " - " + std::to_string(i);
|
||||
@@ -530,6 +601,7 @@ private:
|
||||
std::string path = Settings::fPathGFX;
|
||||
std::string base = path + "/walks/" + "walk-" + walkName;
|
||||
|
||||
#ifdef PLOT_LIVE
|
||||
plotty.gp << "unset arrow 1\n";
|
||||
plotty.gp << "unset arrow 2\n";
|
||||
plotty.gp << "unset colorbox\n";
|
||||
@@ -546,18 +618,23 @@ private:
|
||||
plotty.gp.setOutput(base + "-map.tex");
|
||||
plotty.writeCodeTo(base + "-map.gp");
|
||||
plotty.plot();
|
||||
#endif
|
||||
|
||||
#ifdef PLOT_ERROR_FUNC
|
||||
pef.getPlot().getMargin().set(4, 0.2, 0.1, 2.0);
|
||||
pef.getGP().setTerminal("epslatex", K::GnuplotSize(8.6, 3.0));
|
||||
pef.getGP().setOutput(base + "-error-cum.tex");
|
||||
pef.writePlotToFile(base + "-error-cum.gp");
|
||||
pef.plot();
|
||||
#endif
|
||||
|
||||
#ifdef PLOT_ERROR_TIME
|
||||
pet.getPlot().getMargin().set(4, 0.2, 0.1, 2.0);
|
||||
pet.getGP().setTerminal("epslatex", K::GnuplotSize(8.6, 3.0));
|
||||
pet.getGP().setOutput(base + "-error-time.tex");
|
||||
pet.writePlotToFile(base + "-error-time.gp");
|
||||
pet.plot();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -566,10 +643,6 @@ private:
|
||||
|
||||
++updateCount;
|
||||
|
||||
pef.showMarkers(true, true);
|
||||
|
||||
std::cout << "update" << std::endl;
|
||||
|
||||
MyControl ctrlCopy = curCtrl;
|
||||
//static float absHead = relHeadingOffset;
|
||||
absHead += ctrlCopy.turnSinceLastTransition_rad;
|
||||
@@ -587,6 +660,7 @@ private:
|
||||
statsErr.add(estRealErr);
|
||||
|
||||
#ifdef PLOT_ERROR_FUNC
|
||||
pef.showMarkers(true, true);
|
||||
pef.clear();
|
||||
pef.add("", &statsErr);
|
||||
#endif
|
||||
@@ -597,9 +671,11 @@ private:
|
||||
pet.addB(lastTransition, getNumFHWSAPs(curObs.wifi));
|
||||
#endif
|
||||
|
||||
#ifdef PLOT_LIVE
|
||||
// update estimated path
|
||||
const K::GnuplotPoint3 p3(curEst.position.x_cm, curEst.position.y_cm, curEst.position.z_cm);
|
||||
plotty.pathEst.add(p3/100);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -611,6 +687,7 @@ private:
|
||||
|
||||
std::cout << statsErr.asString() << std::endl;
|
||||
|
||||
#ifdef PLOT_LIVE
|
||||
// estimation and ground-truth
|
||||
plotty.setCurEst(curEst.position.inMeter());
|
||||
plotty.setGroundTruth(curGT);
|
||||
@@ -654,6 +731,7 @@ private:
|
||||
plotty.gp << "set arrow 2 from screen " << cen.x << "," << cen.y << " to screen " << arr.x << "," << arr.y << "\n";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PLOT_LIVE
|
||||
plotty.plot();
|
||||
|
||||
Reference in New Issue
Block a user