current TeX and Code

This commit is contained in:
2017-05-05 14:33:13 +02:00
parent 1b24977a95
commit e3ba39c5a2
17 changed files with 621 additions and 114 deletions

View File

@@ -8,6 +8,7 @@
#include "Indoor/sensors/radio/VAPGrouper.h"
#include "Indoor/sensors/offline/FileReader.h"
#include "Indoor/sensors/radio/WiFiQualityAnalyzer.h"
#include "Indoor/floorplan/v2/Floorplan.h"
#include "Indoor/floorplan/v2/FloorplanReader.h"
@@ -195,9 +196,187 @@ public:
// const float h = 90 * (1 - std::pow(factor, 1.0));
// K::GnuplotColor color = K::GnuplotColor::fromHSV(h, 255, 255);
// scale
//factor = std::pow(factor, 2.0);
// hsv white->red
const float sat = 255 * factor;
K::GnuplotColor color = K::GnuplotColor::fromHSV(0, sat, 255);
const float val = 255;//255 - 128 * factor;
K::GnuplotColor color = K::GnuplotColor::fromHSV(0, sat, val);
K::GnuplotObjectPolygon* poly = new K::GnuplotObjectPolygon(
K::GnuplotFill(K::GnuplotFillStyle::SOLID, color),
K::GnuplotStroke::NONE()
);
// slightly overlapping??
const float s = ss * 0.50;
poly->add(K::GnuplotCoordinate3(ep.pos.x-s, ep.pos.y-s, ep.pos.z-oz, K::GnuplotCoordinateSystem::FIRST));
poly->add(K::GnuplotCoordinate3(ep.pos.x+s, ep.pos.y-s, ep.pos.z-oz, K::GnuplotCoordinateSystem::FIRST));
poly->add(K::GnuplotCoordinate3(ep.pos.x+s, ep.pos.y+s, ep.pos.z-oz, K::GnuplotCoordinateSystem::FIRST));
poly->add(K::GnuplotCoordinate3(ep.pos.x-s, ep.pos.y+s, ep.pos.z-oz, K::GnuplotCoordinateSystem::FIRST));
poly->close();
poly->setZIndex(ep.pos.z - 1.5);
plot->splot.getObjects().add(poly);
}
plot->splot.getObjects().reOrderByZIndex();
plot->plot();
return plot;
}
Plotty* showWifiQuality(const std::vector<Offline::FileReader>& readers, const std::vector<std::vector<int>>& paths) {
Plotty* plot = new Plotty(map);
plot->settings.obstacles = true;
plot->settings.outline = false;
plot->settings.stairs = false;
plot->settings.outlineColorCustom = true;
//plot->settings.outlineColor = K::GnuplotColor::fromRGB(0,0,0);
plot->buildFloorplan();
plot->equalXY();
plot->gp << "unset border\n";
plot->splot.getAxisX().setTicsVisible(false);
plot->splot.getAxisY().setTicsVisible(false);
plot->splot.getAxisZ().setTicsVisible(false);
plot->setScale(1.5, 1.5);
// combine position and quality
struct ErrPoint {
Point3 pos;
float err;
ErrPoint(const Point3 pos, const float err) : pos(pos), err(err) {;}
};
std::vector<ErrPoint> errors;
// process each location
for (int i = 0; i < readers.size(); ++i) {
const Offline::FileReader& reader = readers[i];
Offline::FileReader::GroundTruth gt = reader.getGroundTruth(map, paths[i]);
WiFiQualityAnalyzer analyzer;
for (const auto& entry : reader.getWiFiGroupedByTime()) {
analyzer.add(entry.data);
Point3 pt = gt.get(Timestamp::fromMS(entry.ts));
const float quality = analyzer.getQuality();
// enqueue MAX error
errors.push_back(ErrPoint(pt, quality));
}
}
// interpolated error points
std::vector<ErrPoint> errorsInt;
K::Statistics<float> errStats;
const float oz = 1.3;
const float ss = 4.0;
for (Floorplan::Floor* floor : map->floors) {
for (float y = -20; y < 70; y+=ss) {
for (float x = -10; x < 130; x+=ss) {
const Point3 pos(x,y,floor->atHeight+oz);
float errSum = 0;
float distSum = 0;
int cnt = 0;
float minDist = 99999;
for (const ErrPoint& ep : errors) {
//if (ep.pos.z != pos.z) {continue;}
const float dist = ep.pos.getDistance(pos);
//if (dist > 4.0) {continue;}
//const float imp = 1.0 / (std::pow((dist+0.01)/4.0, 3));
//errSum += ep.err * imp;
//distSum += imp;
if (dist < minDist) {
errSum = ep.err;
distSum = 1.0;
minDist = dist;
}
++cnt;
}
// limit estimations to the floorplan's outline
bool contained = false;
for (Floorplan::FloorOutlinePolygon* poly : floor->outline) {
HelperPoly hp(*poly);
if (hp.contains(pos.xy()*100)) {
if (poly->method == Floorplan::OutlineMethod::ADD) {
contained = true;
} else {
//contained = false; break;
}
}
}
if (distSum == 0) {continue;}
if (!contained) {continue;}
const float err = errSum/distSum;
// add
errStats.add(err);
errorsInt.push_back(ErrPoint(pos, err));
}
}
}
const float minErr = 0.0;//errStats.getMin();
const float maxErr = 20.0;//errStats.getQuantile(0.9);
//plot->splot.setTitle("max error: " + std::to_string(errStats.getMax()) + " dB");
// draw interpolated errors between min/max
for (const ErrPoint& ep : errorsInt) {
float factor = ep.err;
factor = std::pow(factor, 0.5);
// hsv white->red
const float sat = 128 - 128 * factor;
const float val = 255;//128 + 127 * factor;
K::GnuplotColor color = K::GnuplotColor::fromHSV(0, sat, val);
K::GnuplotObjectPolygon* poly = new K::GnuplotObjectPolygon(
K::GnuplotFill(K::GnuplotFillStyle::SOLID, color),
@@ -223,6 +402,13 @@ public:
}
};
#endif // EVALWIFIOPTRESULT_H