- worked on about everything - grid walker using plugable modules - wifi models - new distributions - worked on geometric data-structures - added typesafe timestamps - worked on grid-building - added sensor-classes - added sensor analysis (step-detection, turn-detection) - offline data reader - many test-cases
78 lines
1.8 KiB
C++
78 lines
1.8 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 LIVE (exact) predictions
|
|
* just based on the distance to the access-point
|
|
*/
|
|
class WiFiObserverFree : public WiFiProbability {
|
|
|
|
private:
|
|
|
|
const float sigma = 8.0f;
|
|
|
|
const float sigmaPerSecond = 1.5f;
|
|
|
|
WiFiModel& model;
|
|
std::unordered_map<MACAddress, LocatedAccessPoint> aps;
|
|
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));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
double getProbability(const Point3& pos, const Timestamp curTime, const WiFiMeasurements& obs) const {
|
|
|
|
double prob = 1.0;
|
|
|
|
for (const WiFiMeasurement& entry : obs.entries) {
|
|
|
|
auto it = aps.find(entry.getAP().getMAC());
|
|
|
|
// AP is unknown
|
|
if (it == aps.end()) {continue;}
|
|
|
|
// get the AP
|
|
const LocatedAccessPoint& ap = it->second;
|
|
|
|
// model and scan rssi
|
|
const float modelRSSI = model.getRSSI(ap, pos);
|
|
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
|