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
YASMIN/sensors/dummy/WiFiSensorDummy.h
kazu 075d8bb633 a lot!!! of changes
added main menu
added debug display
many debug widgets for plotting live data
worked on android live sensors
added offline-data sensor feeding
some dummy data sensors
worked on the map display
added ui debug for grid-points, particles and weights
added a cool dude to display the estimation
added real filtering based on the Indoor components
c++11 fixes for android compilation
online and offline filtering support
new resampling technique for testing
map loading via dialog
2016-09-16 19:30:04 +02:00

99 lines
2.0 KiB
C++

#ifndef WIFISENSORDUMMY_H
#define WIFISENSORDUMMY_H
#include "../WiFiSensor.h"
#include <thread>
#include <Indoor/geo/Point3.h>
#include <Indoor/sensors/radio/model/LogDistanceModel.h>
#include <Indoor/grid/Grid.h>
#include <Indoor/grid/factory/v2/GridFactory.h>
class WiFiSensorDummy : public WiFiSensor {
private:
bool enabled;
public:
/** singleton access */
static WiFiSensorDummy& get() {
static WiFiSensorDummy wifi;
return wifi;
}
void start() override {
enabled = true;
std::thread t(&WiFiSensorDummy::simulate, this);
t.detach();
}
void stop() override {
enabled = false;
}
private:
struct DummyAP {
std::string mac;
Point2 pos;
DummyAP(const std::string mac, const Point2 pos) : mac(mac), pos(pos) {;}
};
void simulate() {
std::vector<DummyAP> aps;
aps.push_back(DummyAP("00:00:00:00:00:01", Point2(0, 0)));
aps.push_back(DummyAP("00:00:00:00:00:02", Point2(20, 0)));
aps.push_back(DummyAP("00:00:00:00:00:03", Point2(10, 20)));
aps.push_back(DummyAP("00:00:00:00:00:04", Point2(10, 30)));
aps.push_back(DummyAP("00:00:00:00:00:05", Point2(10, 40)));
aps.push_back(DummyAP("00:00:00:00:00:06", Point2(10, 50)));
aps.push_back(DummyAP("00:00:00:00:00:07", Point2(10, 60)));
aps.push_back(DummyAP("00:00:00:00:00:08", Point2(10, 70)));
aps.push_back(DummyAP("00:00:00:00:00:09", Point2(10, 80)));
float deg = 0;
while(enabled) {
// wait
std::this_thread::sleep_for(std::chrono::milliseconds(500));
// circle-run around center
deg += M_PI * 0.4;
const float cx = 10;
const float cy = 10;
const float rad = 5;
const float x = cx + std::sin(deg) * rad;
const float y = cy + std::cos(deg) * rad;
// construct scan data
WiFiMeasurements scan;
for (DummyAP& ap : aps) {
const float dist = ap.pos.getDistance(Point2(x, y));
const float rssi = LogDistanceModel::distanceToRssi(-40, 1.5, dist);
scan.entries.push_back(WiFiMeasurement(AccessPoint(ap.mac), rssi));
}
// call
informListeners(scan);
}
}
};
#endif // WIFISENSORDUMMY_H