worked on signal-strength-estimation
add this information to grid nodes evaluate this information new test-cases
This commit is contained in:
47
sensors/radio/model/LogDistanceModel.h
Normal file
47
sensors/radio/model/LogDistanceModel.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef LOGDISTANCEMODEL_H
|
||||
#define LOGDISTANCEMODEL_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class LogDistanceModel {
|
||||
|
||||
public:
|
||||
|
||||
/** convert from RSSI to a distance (in meter) */
|
||||
static float rssiToDistance(const float txPower, const float pathLoss, const float rssi) {
|
||||
return pow(10, (txPower - rssi) / (10 * pathLoss));
|
||||
}
|
||||
|
||||
/** convert from a distance (in meter) to the expected RSSI */
|
||||
static float distanceToRssi(const float txPower, const float pathLoss, const float distance_m) {
|
||||
if (distance_m <= 1) {return txPower;}
|
||||
return (txPower - (10 * pathLoss * std::log10(distance_m)));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#include <vector>
|
||||
|
||||
class LogDistFastModel {
|
||||
|
||||
private:
|
||||
|
||||
std::vector<float> lut;
|
||||
|
||||
public:
|
||||
|
||||
LogDistFastModel() {
|
||||
lut.resize(2000);
|
||||
for (int i = 0; i < 2000; ++i) {
|
||||
lut[i] = std::log10(i/10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
float distanceToRssi(const float txPower, const float pathLoss, const float distance) const {
|
||||
if (distance <= 1) {return txPower;}
|
||||
return (txPower - (10 * pathLoss * lut[ (int) (distance*10) ]));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // LOGDISTANCEMODEL_H
|
||||
18
sensors/radio/model/WiFiModel.h
Normal file
18
sensors/radio/model/WiFiModel.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef WIFIMODEL_H
|
||||
#define WIFIMODEL_H
|
||||
|
||||
#include "../LocatedAccessPoint.h"
|
||||
|
||||
/**
|
||||
* interface for signal-strength prediction models
|
||||
*/
|
||||
class WiFiModel {
|
||||
|
||||
public:
|
||||
|
||||
/** get the given access-point's RSSI at the provided location */
|
||||
virtual float getRSSI(const LocatedAccessPoint& ap, const Point3 p) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif // WIFIMODEL_H
|
||||
31
sensors/radio/model/WiFiModelLogDist.h
Normal file
31
sensors/radio/model/WiFiModelLogDist.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef WIFIMODELLOGDIST_H
|
||||
#define WIFIMODELLOGDIST_H
|
||||
|
||||
#include "WiFiModel.h"
|
||||
#include "LogDistanceModel.h"
|
||||
|
||||
/**
|
||||
* signal-strength estimation using log-distance model
|
||||
*/
|
||||
class WiFiModelLogDist : public WiFiModel {
|
||||
|
||||
private:
|
||||
|
||||
float txp;
|
||||
float exp;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
WiFiModelLogDist(const float txp, const float exp) : txp(txp), exp(exp) {
|
||||
;
|
||||
}
|
||||
|
||||
/** 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));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // WIFIMODELLOGDIST_H
|
||||
Reference in New Issue
Block a user