added tex
many changes/eval etc...
This commit is contained in:
153
EvalWiFiSigStrength.h
Normal file
153
EvalWiFiSigStrength.h
Normal file
@@ -0,0 +1,153 @@
|
||||
#ifndef EVALWIFISIGSTRENGTH_H
|
||||
#define EVALWIFISIGSTRENGTH_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/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 <KLib/misc/gnuplot/Gnuplot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementPoints.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementColorPoints.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotSplotElementLines.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotPlot.h>
|
||||
#include <KLib/misc/gnuplot/GnuplotPlotElementHistogram.h>
|
||||
|
||||
#include <KLib/math/statistics/Statistics.h>
|
||||
|
||||
#include "Structs.h"
|
||||
#include "Plotty.h"
|
||||
#include "CSV.h"
|
||||
#include "Helper.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
|
||||
/**
|
||||
* read path
|
||||
* fetch wifi
|
||||
* use given model to estimate the most likely location
|
||||
* -> WIFI ONLY
|
||||
*/
|
||||
class EvalWiFiSigStrength {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::IndoorMap* map;
|
||||
BBox3 mapBBox;
|
||||
|
||||
WiFiFingerprints calib;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with map and fingerprints */
|
||||
EvalWiFiSigStrength(const std::string& mapFile, const std::string& fpFile) {
|
||||
|
||||
// load floorplan
|
||||
map = Floorplan::Reader::readFromFile(mapFile);
|
||||
|
||||
// estimate bbox
|
||||
mapBBox = FloorplanHelper::getBBox(map);
|
||||
|
||||
// load fingerprints
|
||||
calib = WiFiFingerprints(fpFile);
|
||||
|
||||
// remove some stuff
|
||||
LeHelper::removeNonFHWS(calib);
|
||||
|
||||
}
|
||||
|
||||
float scale(const float val, const float min, const float max) {
|
||||
return (val - min) / (max-min);
|
||||
}
|
||||
|
||||
|
||||
void forAP_avg(Plotty* p, const MACAddress& mac) {
|
||||
|
||||
VAPGrouper vap(VAPGrouper::Mode::LAST_MAC_DIGIT_TO_ZERO, VAPGrouper::Aggregation::AVERAGE);
|
||||
|
||||
// get AP/floor
|
||||
std::pair<Floorplan::AccessPoint*, Floorplan::Floor*> _ap = FloorplanHelper::getAP(map, mac);
|
||||
const Floorplan::Floor* floor = _ap.second;
|
||||
const Floorplan::AccessPoint* ap = _ap.first;
|
||||
|
||||
// copy
|
||||
WiFiFingerprints calib = this->calib;
|
||||
for (WiFiFingerprint& fp : calib.getFingerprints()) {
|
||||
fp.measurements = vap.group(fp.measurements);
|
||||
}
|
||||
|
||||
// plot
|
||||
|
||||
|
||||
std::cout << ap->mac << std::endl;
|
||||
|
||||
const Point3 apPos3 = ap->getPos(floor);
|
||||
K::GnuplotPoint3 apPos(apPos3.x, apPos3.y, apPos3.z);
|
||||
p->points.add(apPos);
|
||||
|
||||
// process every fingerprint location
|
||||
for (const WiFiFingerprint& fp : calib.getFingerprints()) {
|
||||
|
||||
// either 0 entries [ap not seen here] or 1 entry due to vap grouping [ap seen here]
|
||||
std::vector<WiFiMeasurement> mes = fp.getAllForMAC(mac);
|
||||
|
||||
if (!mes.empty()) {
|
||||
|
||||
const float rssi = mes.front().getRSSI();
|
||||
const float s = scale(rssi, -100, -40);
|
||||
const Color c = Color::fromHSV(s*100, 255, 255);
|
||||
|
||||
// fingerprint onto the floor
|
||||
p->addFloorRect(fp.pos_m - Point3(0,0,1.3), 1, c);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void perAP_avg() {
|
||||
|
||||
std::vector<std::pair<Floorplan::AccessPoint*, Floorplan::Floor*>> aps = FloorplanHelper::getAPs(map);
|
||||
|
||||
for (const auto& it : aps) {
|
||||
|
||||
const Floorplan::Floor* floor = it.second;
|
||||
const Floorplan::AccessPoint* ap = it.first;
|
||||
const MACAddress mac(ap->mac);
|
||||
|
||||
Plotty* p = new Plotty(map);
|
||||
p->setTitle(ap->mac);
|
||||
p->buildFloorplan();
|
||||
forAP_avg(p, mac);
|
||||
|
||||
p->plot();
|
||||
|
||||
int i = 0; (void) i;
|
||||
|
||||
// MACs:
|
||||
// d8:84:66:4a:23:d0 <<<< BEST
|
||||
// d8:84:66:4a:25:c0
|
||||
// d8:84:66:4a:4c:60
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // EVALWIFISIGSTRENGTH_H
|
||||
Reference in New Issue
Block a user