This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/sensors/radio/WiFiProbabilityFree.h
FrankE a203305628 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
2016-08-29 19:02:32 +02:00

76 lines
1.6 KiB
C++

#ifndef WIFIPROBABILITYFREE_H
#define WIFIPROBABILITYFREE_H
#include "WiFiProbability.h"
#include "model/WiFiModel.h"
#include "../../math/Distributions.h"
#include <unordered_map>
/**
* compare WiFi-Measurements within predictions of a given model.
* predictions are just based on the distance to the access-point.
*/
class WiFiObserverFree : public WiFiProbability {
private:
const float sigma = 8.0f;
const float sigmaPerSecond = 1.5f;
/** the RSSI prediction model */
WiFiModel& model;
/** the map's floorplan */
Floorplan::IndoorMap* map;
public:
WiFiObserverFree(const float sigma, WiFiModel& model) : sigma(sigma), model(model) {
}
double getProbability(const Point3& pos, const Timestamp curTime, const WiFiMeasurements& obs) const {
double prob = 1.0;
// process each measured AP
for (const WiFiMeasurement& entry : obs.entries) {
// get the model's RSSI (if possible!)
const float modelRSSI = model.getRSSI(entry.getAP().getMAC(), pos);
// NaN? -> AP not known to the model -> skip
if (modelRSSI != modelRSSI) {continue;}
// the scan's RSSI
const float scanRSSI = entry.getRSSI();
// the measurement's age
const Timestamp age = curTime - entry.getTimestamp();
// sigma grows with measurement age
const float sigma = this->sigma + this->sigmaPerSecond * age.sec();
// update probability
prob *= Distribution::Normal<double>::getProbability(modelRSSI, sigma, scanRSSI);
}
return prob;
}
template <typename Node> double getProbability(const Node& n, const Timestamp curTime, const WiFiMeasurements& obs, const int age_ms = 0) const {
throw "todo??";
}
};
#endif // WIFIPROBABILITYFREE_H