#ifndef EVALWIFIGROUND_H #define EVALWIFIGROUND_H #include "Indoor/sensors/radio/setup/WiFiOptimizer.h" #include "Indoor/sensors/radio/setup/WiFiFingerprint.h" #include "Indoor/sensors/radio/setup/WiFiFingerprints.h" #include "Indoor/sensors/radio/setup/WiFiOptimizer.h" #include "Indoor/sensors/radio/model/WiFiModels.h" #include "Indoor/sensors/radio/VAPGrouper.h" #include "Indoor/sensors/offline/FileReader.h" #include "Indoor/floorplan/v2/Floorplan.h" #include "Indoor/floorplan/v2/FloorplanReader.h" #include "Indoor/floorplan/v2/FloorplanHelper.h" #include "Indoor/floorplan/v2/FloorplanCeilings.h" #include #include #include #include #include #include #include #include #include "../Structs.h" #include "../plots/Plotty.h" #include "../plots/PlotErrTime.h" #include "../plots/PlotErrFunc.h" #include "../plots/PlotWiFiGroundProb.h" //#include "../CSV.h" #include #include class EvalWiFiGround { private: Floorplan::IndoorMap* map; WiFiModel* mdl; WiFiObserverFree* obs; public: PlotWiFiGroundProb* groundProb; public: EvalWiFiGround(Floorplan::IndoorMap* map, const std::string calibModel, Plotty::Settings settings = Plotty::Settings()) : map(map) { mdl = WiFiModelFactory(map).loadXML(calibModel); obs = new WiFiObserverFree(8.0, *mdl); groundProb = new PlotWiFiGroundProb(map, settings); } void show(const std::string walkFile, const int idx = -1) { Offline::FileReader reader(walkFile); int cnt = 0; for (const auto& entry : reader.getWiFiGroupedByTime()) { const WiFiMeasurements& mes = entry.data; groundProb->show(*obs, mes); groundProb->plotMe(); //if (++cnt > 70) {break;} std::this_thread::sleep_for(std::chrono::milliseconds(2)); } //groundProb->update(); groundProb->plotMe(); int i = 0; (void) i; } void add(const std::string walkFile, const int idx, const float hue) { VAPGrouper vap(VAPGrouper::Mode::LAST_MAC_DIGIT_TO_ZERO, VAPGrouper::Aggregation::AVERAGE); Offline::FileReader reader(walkFile); const auto& entry = reader.getWiFiGroupedByTime()[idx]; const WiFiMeasurements& _mes = entry.data; const WiFiMeasurements mes = vap.group(_mes); groundProb->showStrongest(*obs, mes, hue); //groundProb->plotMe(); //std::this_thread::sleep_for(std::chrono::milliseconds(2)); //groundProb->update(); //groundProb->plotMe(); int i = 0; (void) i; } void addGT(const std::string walkFile, const int idx, const float hue, const std::vector& path) { Offline::FileReader reader(walkFile); const auto& entry = reader.getWiFiGroupedByTime()[idx]; const WiFiMeasurements& mes = entry.data; // gt at the time of the wifi measurement const Timestamp ts = mes.entries.front().getTimestamp(); const Point3 pt = reader.getGroundTruth(map, path).get(ts); Color c1 = Color::fromRGB(0,0,0); Color c2 = Color::fromHSV(hue, 255, 255); groundProb->getPlot().addFloorRect(pt+Point3(0,0,0.200), 1.5, c1); groundProb->getPlot().addFloorRect(pt+Point3(0,0,0.201), 1.0, c2); } void writeGP(const std::string& path, const std::string& name) { const std::string file = path + "/" + name; groundProb->getPlot().splot.getCustom() << "unset border \n"; groundProb->getPlot().splot.getCustom() << "set view equal xy\n"; groundProb->getPlot().splot.getAxisX().setTicsVisible(false); groundProb->getPlot().splot.getAxisY().setTicsVisible(false); groundProb->getPlot().splot.getAxisZ().setTicsVisible(false); groundProb->getPlot().splot.getAxisZ().setRange(-12.500000, 21.200000); groundProb->getPlot().splot.getView().setCamera(72, 28); groundProb->getPlot().splot.getView().setScaleAll(5.5); groundProb->getPlot().gp.setTerminal("epslatex", K::GnuplotSize(8.6, 4.0)); groundProb->getPlot().gp.setOutput(file+".tex"); groundProb->getPlot().gp.writePlotToFile(file+".gp"); groundProb->plotMe(); groundProb->getPlot().gp.writePlotToFile(""); } }; #endif // EVALWIFIGROUND_H