many changes and updates
- changed the wifi-estimation api - adjusted test-cases - worked on grid-bulding and grid-importance - new walking modules - fixed some minor issues
This commit is contained in:
@@ -43,13 +43,13 @@ public:
|
||||
* as nodes only provide a limited number of rssi-entries,
|
||||
* store only the strongest ones.
|
||||
*/
|
||||
template <typename Node> static void estimate(Grid<Node>& grid, WiFiModel& mdl, const std::vector<LocatedAccessPoint> aps) {
|
||||
template <typename Node> static void estimate(Grid<Node>& grid, WiFiModel& mdl, const std::vector<AccessPoint> aps) {
|
||||
|
||||
// sanity checks
|
||||
Assert::isTrue(Node::getMapAPs().empty(), "there are already some processed APs available!");
|
||||
|
||||
// attach the access-points to the shared node-vector
|
||||
for (const LocatedAccessPoint& ap : aps) {
|
||||
for (const AccessPoint& ap : aps) {
|
||||
Node::getMapAPs().push_back(ap);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
for (int apIdx = 0; apIdx < (int) aps.size(); ++apIdx) {
|
||||
|
||||
// estimate the signal-strength
|
||||
const float rssi = mdl.getRSSI(aps[apIdx], n.inMeter());
|
||||
const float rssi = mdl.getRSSI(aps[apIdx].getMAC(), n.inMeter());
|
||||
|
||||
// keep it
|
||||
nodeAPs.push_back(WiFiGridNodeAP(apIdx, rssi));
|
||||
|
||||
@@ -12,7 +12,7 @@ struct WiFiGridNodeAP {
|
||||
|
||||
private:
|
||||
|
||||
static const int UNUSED_IDX = 255;
|
||||
static const uint8_t UNUSED_IDX = 255;
|
||||
|
||||
private:
|
||||
|
||||
@@ -25,10 +25,14 @@ private:
|
||||
public:
|
||||
|
||||
/** empty ctor */
|
||||
WiFiGridNodeAP() : idx(UNUSED_IDX), rssi(0) {;}
|
||||
WiFiGridNodeAP() : idx(UNUSED_IDX), rssi(0) {
|
||||
int i = 0; (void) i;
|
||||
}
|
||||
|
||||
/** ctor */
|
||||
WiFiGridNodeAP(const int idx, const float rssi) : idx(idx), rssi(stretch(rssi)) {;}
|
||||
WiFiGridNodeAP(const int idx, const float rssi) : idx(idx), rssi(stretch(rssi)) {
|
||||
int i = 0; (void) i;
|
||||
}
|
||||
|
||||
|
||||
/** is this entry valid/used? */
|
||||
@@ -70,13 +74,14 @@ private:
|
||||
*/
|
||||
template <int maxAccessPoints> struct WiFiGridNode {
|
||||
|
||||
|
||||
/** contains the 10 strongest APs measureable at this position */
|
||||
WiFiGridNodeAP strongestAPs[maxAccessPoints];
|
||||
|
||||
|
||||
/** ctor */
|
||||
WiFiGridNode() {;}
|
||||
explicit WiFiGridNode() : strongestAPs() {
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
/** get the maximum number of APs each node is able to store */
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <unordered_map>
|
||||
|
||||
/**
|
||||
* compare WiFi-Measurements within LIVE (exact) predictions
|
||||
* just based on the distance to the access-point
|
||||
* compare WiFi-Measurements within predictions of a given model.
|
||||
* predictions are just based on the distance to the access-point.
|
||||
*/
|
||||
class WiFiObserverFree : public WiFiProbability {
|
||||
|
||||
@@ -19,17 +19,16 @@ private:
|
||||
|
||||
const float sigmaPerSecond = 1.5f;
|
||||
|
||||
/** the RSSI prediction model */
|
||||
WiFiModel& model;
|
||||
std::unordered_map<MACAddress, LocatedAccessPoint> aps;
|
||||
|
||||
/** the map's floorplan */
|
||||
Floorplan::IndoorMap* map;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
WiFiObserverFree(const float sigma, WiFiModel& model, const std::vector<LocatedAccessPoint>& aps) : sigma(sigma), model(model) {
|
||||
|
||||
for (const LocatedAccessPoint& ap : aps) {
|
||||
this->aps.insert(std::pair<MACAddress, LocatedAccessPoint>(ap.getMAC(), ap));
|
||||
}
|
||||
WiFiObserverFree(const float sigma, WiFiModel& model) : sigma(sigma), model(model) {
|
||||
|
||||
}
|
||||
|
||||
@@ -38,18 +37,17 @@ public:
|
||||
|
||||
double prob = 1.0;
|
||||
|
||||
// process each measured AP
|
||||
for (const WiFiMeasurement& entry : obs.entries) {
|
||||
|
||||
auto it = aps.find(entry.getAP().getMAC());
|
||||
// get the model's RSSI (if possible!)
|
||||
const float modelRSSI = model.getRSSI(entry.getAP().getMAC(), pos);
|
||||
|
||||
// AP is unknown
|
||||
if (it == aps.end()) {continue;}
|
||||
// NaN? -> AP not known to the model -> skip
|
||||
if (modelRSSI != modelRSSI) {continue;}
|
||||
|
||||
// get the AP
|
||||
const LocatedAccessPoint& ap = it->second;
|
||||
|
||||
// model and scan rssi
|
||||
const float modelRSSI = model.getRSSI(ap, pos);
|
||||
// the scan's RSSI
|
||||
const float scanRSSI = entry.getRSSI();
|
||||
|
||||
// the measurement's age
|
||||
|
||||
@@ -4,14 +4,25 @@
|
||||
#include "../LocatedAccessPoint.h"
|
||||
|
||||
/**
|
||||
* interface for signal-strength prediction models
|
||||
* interface for signal-strength prediction models.
|
||||
*
|
||||
* the model is passed a MAC-address of an AP in question, and a position.
|
||||
* hereafter the model returns the RSSI for this AP at the questioned location.
|
||||
*/
|
||||
class WiFiModel {
|
||||
|
||||
public:
|
||||
|
||||
/** get the given access-point's RSSI at the provided location */
|
||||
virtual float getRSSI(const LocatedAccessPoint& ap, const Point3 p) = 0;
|
||||
// /** get the given access-point's RSSI at the provided location */
|
||||
// virtual float getRSSI(const LocatedAccessPoint& ap, const Point3 p) = 0;
|
||||
|
||||
/**
|
||||
* get the RSSI expected at the given location (in meter)
|
||||
* for an AP identified by the given MAC.
|
||||
*
|
||||
* if the model can not predict the RSSI for an AP, it returns NaN!
|
||||
*/
|
||||
virtual float getRSSI(const MACAddress& accessPoint, const Point3 position_m) const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -9,21 +9,63 @@
|
||||
*/
|
||||
class WiFiModelLogDist : public WiFiModel {
|
||||
|
||||
public:
|
||||
|
||||
/** parameters describing one AP to the model */
|
||||
struct APEntry {
|
||||
|
||||
Point3 position_m; // the AP's position (in meter)
|
||||
float txp; // sending power (-40)
|
||||
float exp; // path-loss-exponent (~2.0 - 4.0)
|
||||
|
||||
/** ctor */
|
||||
APEntry(const Point3 position_m, const float txp, const float exp) :
|
||||
position_m(position_m), txp(txp), exp(exp) {;}
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
float txp;
|
||||
float exp;
|
||||
/** map of all APs (and their parameters) known to the model */
|
||||
std::unordered_map<MACAddress, APEntry> accessPoints;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
WiFiModelLogDist(const float txp, const float exp) : txp(txp), exp(exp) {
|
||||
WiFiModelLogDist() {
|
||||
;
|
||||
}
|
||||
|
||||
/** get the given access-point's RSSI at the provided location */
|
||||
float getRSSI(const LocatedAccessPoint& ap, const Point3 p) override {
|
||||
return LogDistanceModel::distanceToRssi(txp, exp, ap.getDistance(p));
|
||||
/** make the given AP (and its parameters) known to the model */
|
||||
void addAP(const MACAddress& accessPoint, const APEntry& params) {
|
||||
|
||||
// sanity check
|
||||
Assert::isBetween(params.txp, -50.0f, -30.0f, "TXP out of bounds [-90:-30]");
|
||||
Assert::isBetween(params.exp, 1.0f, 4.0f, "EXP out of bounds [1:4]");
|
||||
|
||||
// add
|
||||
accessPoints.insert( std::pair<MACAddress, APEntry>(accessPoint, params) );
|
||||
|
||||
}
|
||||
|
||||
virtual float getRSSI(const MACAddress& accessPoint, const Point3 position_m) const override {
|
||||
|
||||
// try to get the corresponding parameters
|
||||
const auto it = accessPoints.find(accessPoint);
|
||||
|
||||
// AP unknown? -> NAN
|
||||
if (it == accessPoints.end()) {return NAN;}
|
||||
|
||||
// the access-points' parameters
|
||||
const APEntry& params = it->second;
|
||||
|
||||
// free-space (line-of-sight) RSSI
|
||||
const float distance_m = position_m.getDistance(params.position_m);
|
||||
const float rssiLOS = LogDistanceModel::distanceToRssi(params.txp, params.exp, distance_m);
|
||||
|
||||
// done
|
||||
return rssiLOS;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../../../floorplan/v2/Floorplan.h"
|
||||
|
||||
#include "../../../Assertions.h"
|
||||
#include "WiFiModel.h"
|
||||
#include "LogDistanceModel.h"
|
||||
|
||||
@@ -12,11 +13,26 @@
|
||||
*/
|
||||
class WiFiModelLogDistCeiling : public WiFiModel {
|
||||
|
||||
public:
|
||||
|
||||
/** parameters describing one AP to the model */
|
||||
struct APEntry {
|
||||
|
||||
Point3 position_m; // the AP's position (in meter)
|
||||
float txp; // sending power (-40)
|
||||
float exp; // path-loss-exponent (~2.0 - 4.0)
|
||||
float waf; // attenuation per ceiling/floor (~-8.0)
|
||||
|
||||
/** ctor */
|
||||
APEntry(const Point3 position_m, const float txp, const float exp, const float waf) :
|
||||
position_m(position_m), txp(txp), exp(exp), waf(waf) {;}
|
||||
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
float txp; // sending power (-40)
|
||||
float exp; // path-loss-exponent (~2.0 - 4.0)
|
||||
float waf; // attenuation per ceiling/floor (~-8.0)
|
||||
/** map of all APs (and their parameters) known to the model */
|
||||
std::unordered_map<MACAddress, APEntry> accessPoints;
|
||||
|
||||
/** position (height) of all ceilings (in meter) */
|
||||
std::vector<float> ceilingsAtHeight_m;
|
||||
@@ -24,9 +40,7 @@ private:
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
WiFiModelLogDistCeiling(const float txp, const float exp, const float waf, const Floorplan::IndoorMap* map) : txp(txp), exp(exp), waf(waf) {
|
||||
|
||||
Assert::isTrue(waf <= 0, "WAF must be a negative number!");
|
||||
WiFiModelLogDistCeiling(const Floorplan::IndoorMap* map) {
|
||||
|
||||
// position of all ceilings
|
||||
for (Floorplan::Floor* f : map->floors) {
|
||||
@@ -35,23 +49,56 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** get the given access-point's RSSI at the provided location */
|
||||
float getRSSI(const LocatedAccessPoint& ap, const Point3 p) override {
|
||||
const int numCeilings = numCeilingsBetween(ap.z, p.z);
|
||||
const float rssi = LogDistanceModel::distanceToRssi(txp, exp, ap.getDistance(p));
|
||||
return rssi + (numCeilings * waf);
|
||||
/** make the given AP (and its parameters) known to the model */
|
||||
void addAP(const MACAddress& accessPoint, const APEntry& params) {
|
||||
|
||||
// sanity check
|
||||
Assert::isBetween(params.waf, -99.0f, 0.0f, "WAF out of bounds [-99:0]");
|
||||
Assert::isBetween(params.txp, -50.0f, -30.0f, "TXP out of bounds [-50:-30]");
|
||||
Assert::isBetween(params.exp, 1.0f, 4.0f, "EXP out of bounds [1:4]");
|
||||
|
||||
// add
|
||||
accessPoints.insert( std::pair<MACAddress, APEntry>(accessPoint, params) );
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
float getRSSI(const MACAddress& accessPoint, const Point3 position_m) const override {
|
||||
|
||||
// try to get the corresponding parameters
|
||||
const auto it = accessPoints.find(accessPoint);
|
||||
|
||||
// AP unknown? -> NAN
|
||||
if (it == accessPoints.end()) {return NAN;}
|
||||
|
||||
// the access-points' parameters
|
||||
const APEntry& params = it->second;
|
||||
|
||||
// free-space (line-of-sight) RSSI
|
||||
const float distance_m = position_m.getDistance(params.position_m);
|
||||
const float rssiLOS = LogDistanceModel::distanceToRssi(params.txp, params.exp, distance_m);
|
||||
|
||||
// WAF loss (params.waf is a negative value!) -> WAF loss is also a negative value
|
||||
const float wafLoss = params.waf * numCeilingsBetween(position_m, params.position_m);
|
||||
|
||||
// combine
|
||||
return rssiLOS + wafLoss;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
FRIEND_TEST(LogDistanceCeilingModel, numCeilings);
|
||||
|
||||
/** get the number of ceilings between z1 and z2 */
|
||||
int numCeilingsBetween(const float z1, const float z2) const {
|
||||
int numCeilingsBetween(const Point3 pos1, const Point3 pos2) const {
|
||||
|
||||
int cnt = 0;
|
||||
const float zMin = std::min(z1, z2);
|
||||
const float zMax = std::max(z1, z2);
|
||||
const float zMin = std::min(pos1.z, pos2.z);
|
||||
const float zMax = std::max(pos1.z, pos2.z);
|
||||
|
||||
for (float z : ceilingsAtHeight_m) {
|
||||
for (const float z : ceilingsAtHeight_m) {
|
||||
if (zMin < z && zMax > z) {++cnt;}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user