From e34e773e31440a4d64752e9bf77d0b3508e8cf99 Mon Sep 17 00:00:00 2001 From: kazu Date: Fri, 24 Mar 2017 11:20:29 +0100 Subject: [PATCH] added new helper methods to work with ground-truth made some assertions optional [i know what i am doing!] --- floorplan/v2/Floorplan.h | 7 +++--- floorplan/v2/FloorplanCeilings.h | 2 +- floorplan/v2/FloorplanHelper.h | 25 +++++++++++++++++++ sensors/radio/model/WiFiModel.h | 3 +++ sensors/radio/model/WiFiModelLogDistCeiling.h | 25 ++++++++++++++----- 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/floorplan/v2/Floorplan.h b/floorplan/v2/Floorplan.h index 1f62b72..f1dcaf4 100644 --- a/floorplan/v2/Floorplan.h +++ b/floorplan/v2/Floorplan.h @@ -197,7 +197,7 @@ namespace Floorplan { using FloorPOIs = std::vector; using FloorStairs = std::vector; using FloorElevators = std::vector; - using FloorGroundTruthPoints = std::vector; + using FloorGroundTruthPoints = std::vector; /** describes one floor within the map, starting at a given height */ struct Floor { @@ -215,7 +215,7 @@ namespace Floorplan { FloorPOIs pois; // POIs within the floor FloorStairs stairs; // all stairs within one floor FloorElevators elevators; // all elevators within one floor - FloorGroundTruthPoints gtpoints; // all ground truth points within one floor + FloorGroundTruthPoints gtpoints; // all ground truth points within one floor //FloorKeyValue other; // other, free elements Floor() {;} @@ -251,9 +251,10 @@ namespace Floorplan { /** a GroundTruthPoint located somewhere on a floor */ struct GroundTruthPoint { int id; //TODO: this value can be changed and isn't set incremental within the indoormap - Point3 pos; + Point3 pos; // TODO: splint into 2D position + float for "heightAboveGround" [waypoints' height is relative to the floor's height! GroundTruthPoint() : id(), pos() {;} GroundTruthPoint(const int& id, const Point3& pos) : id(id), pos(pos) {;} + const Point3 getPosition(const Floor& f) const {return pos + Point3(0,0,f.atHeight);} bool operator == (const GroundTruthPoint& o) const {return (o.id == id) && (o.pos == pos);} }; diff --git a/floorplan/v2/FloorplanCeilings.h b/floorplan/v2/FloorplanCeilings.h index 887ed8e..857bfe8 100644 --- a/floorplan/v2/FloorplanCeilings.h +++ b/floorplan/v2/FloorplanCeilings.h @@ -87,7 +87,7 @@ namespace Floorplan { if (diff < 0.1) {++numNear;} else {++numFar;} } if ((numNear + numFar) > 150000) { - Assert::isTrue(numNear < numFar*0.1, + Assert::isTrue(numNear < numFar*0.15, "many requests to Floorplan::Ceilings::numCeilingsBetween address nodes (very) near to a ground! \ due to rounding issues, determining the number of floors between AP and point-in-question is NOT possible! \ expect very wrong outputs! \ diff --git a/floorplan/v2/FloorplanHelper.h b/floorplan/v2/FloorplanHelper.h index 53605cd..5a96f16 100644 --- a/floorplan/v2/FloorplanHelper.h +++ b/floorplan/v2/FloorplanHelper.h @@ -40,6 +40,31 @@ public: return res; } + /** get all ground-truth points within the map as hash-map: id->pos */ + static std::unordered_map getGroundTruthPoints(const Floorplan::IndoorMap* map) { + std::unordered_map res; + for (const Floorplan::Floor* f : map->floors) { + for (const Floorplan::GroundTruthPoint* gtp : f->gtpoints) { + res[gtp->id] = gtp->getPosition(*f); + } + } + return res; + } + + /** get all ground-truth points, identified by the given indices */ + static std::vector getGroundTruth(const Floorplan::IndoorMap* map, const std::vector indices) { + + // get a map id->pos for all ground-truth-points within the map + const std::unordered_map src = getGroundTruthPoints(map); + std::vector res; + for (const int idx : indices) { + const auto& it = src.find(idx); + if (it == src.end()) {throw Exception("map does not contain a ground-truth-point with ID " + std::to_string(idx));} + res.push_back(it->second); + } + return res; + } + public: /** align all floorplan values to the given grid size. needed for the grid factory */ diff --git a/sensors/radio/model/WiFiModel.h b/sensors/radio/model/WiFiModel.h index bebfce4..f6603c4 100644 --- a/sensors/radio/model/WiFiModel.h +++ b/sensors/radio/model/WiFiModel.h @@ -14,6 +14,9 @@ class WiFiModel { public: + /** dtor */ + virtual ~WiFiModel() {;} + // /** get the given access-point's RSSI at the provided location */ // virtual float getRSSI(const LocatedAccessPoint& ap, const Point3 p) = 0; diff --git a/sensors/radio/model/WiFiModelLogDistCeiling.h b/sensors/radio/model/WiFiModelLogDistCeiling.h index c823f9d..328bf01 100644 --- a/sensors/radio/model/WiFiModelLogDistCeiling.h +++ b/sensors/radio/model/WiFiModelLogDistCeiling.h @@ -71,21 +71,28 @@ public: } - /** load AP information from the floorplan. use the given fixed TXP/EXP/WAF for all APs */ - void loadAPs(const Floorplan::IndoorMap* map, const VAPGrouper& vg, const float txp = -40.0f, const float exp = 2.5f, const float waf = -8.0f) { + /** + * load AP information from the floorplan. + * use the given fixed TXP/EXP/WAF for all APs. + * usually txp,exp,waf are checked for a sane range. if you know what you are doing, set assertSafe to false! + */ + void loadAPs(const Floorplan::IndoorMap* map, const VAPGrouper& vg, const float txp = -40.0f, const float exp = 2.5f, const float waf = -8.0f, const bool assertSafe = true) { for (const Floorplan::Floor* floor : map->floors) { for (const Floorplan::AccessPoint* ap : floor->accesspoints) { const APEntry ape(ap->getPos(floor), txp, exp, waf); const MACAddress mac = vg.getBaseMAC(MACAddress(ap->mac)); - Log::add("WiModLDC", "AP: " + ap->mac + " -> " + mac.asString()); - addAP(MACAddress(mac), ape); + Log::add("WiModLDC", "AP added! given: " + ap->mac + " -> after VAP: " + mac.asString()); + addAP(MACAddress(mac), ape, assertSafe); } } } - /** make the given AP (and its parameters) known to the model */ + /** + * make the given AP (and its parameters) known to the model + * usually txp,exp,waf are checked for a sane range. if you know what you are doing, set assertSafe to false! + */ void addAP(const MACAddress& accessPoint, const APEntry& params, const bool assertSafe = true) { // sanity check @@ -126,7 +133,13 @@ public: const float wafLoss = params.waf * ceilings.numCeilingsBetween(position_m, params.position_m); // combine - return rssiLOS + wafLoss; + const float res = rssiLOS + wafLoss; + + // sanity check + Assert::isNotNaN(res, "detected NaN within WiFiModelLogDistCeiling::getRSSI()"); + + // ok + return res; }