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
This commit is contained in:
kazu
2016-09-16 19:30:04 +02:00
parent d910e88220
commit 075d8bb633
90 changed files with 4735 additions and 624 deletions

View File

@@ -2,9 +2,17 @@
#define ACCELEROMETERSENSORDUMMY_H
#include "../AccelerometerSensor.h"
#include "RandomSensor.h"
#include <random>
class AccelerometerSensorDummy : public AccelerometerSensor {
class AccelerometerSensorDummy : public RandomSensor<AccelerometerData, AccelerometerSensor> {
private:
/** hidden ctor */
AccelerometerSensorDummy() : RandomSensor(Timestamp::fromMS(10)) {
;
}
public:
@@ -14,13 +22,25 @@ public:
return acc;
}
void start() override {
//throw "todo";
protected:
std::minstd_rand gen;
std::uniform_real_distribution<float> distNoise = std::uniform_real_distribution<float>(-0.5, +0.5);
AccelerometerData getRandomEntry() override {
const Timestamp ts = Timestamp::fromRunningTime();
const float Hz = 1.6;
const float intensity = 2.0;
const float x = distNoise(gen);
const float y = distNoise(gen);
const float z = 9.81 + std::sin(ts.sec()*2*M_PI*Hz) * intensity + distNoise(gen);
return AccelerometerData(x,y,z);
}
void stop() override {
throw "todo";
}
};

View File

@@ -0,0 +1,43 @@
#ifndef BAROMETERSENSORDUMMY_H
#define BAROMETERSENSORDUMMY_H
#include "../BarometerSensor.h"
#include "RandomSensor.h"
#include <random>
class BarometerSensorDummy : public RandomSensor<BarometerData, BarometerSensor> {
private:
std::thread thread;
/** hidden ctor */
BarometerSensorDummy() : RandomSensor(Timestamp::fromMS(100)) {
;
}
public:
/** singleton access */
static BarometerSensorDummy& get() {
static BarometerSensorDummy baro;
return baro;
}
protected:
std::minstd_rand gen;
std::uniform_real_distribution<float> distNoise = std::uniform_real_distribution<float>(-0.09, +0.09);
BarometerData getRandomEntry() override {
const Timestamp ts = Timestamp::fromRunningTime();
const float hPa = 930 + std::sin(ts.sec()) * 0.5 + distNoise(gen);
return BarometerData(hPa);
}
};
#endif // BAROMETERSENSORDUMMY_H

View File

@@ -0,0 +1,48 @@
#ifndef GYROSCOPESENSORDUMMY_H
#define GYROSCOPESENSORDUMMY_H
#include "../GyroscopeSensor.h"
#include "RandomSensor.h"
#include <random>
class GyroscopeSensorDummy : public RandomSensor<GyroscopeData, GyroscopeSensor> {
private:
/** hidden ctor */
GyroscopeSensorDummy() : RandomSensor(Timestamp::fromMS(10)) {
;
}
public:
/** singleton access */
static GyroscopeSensorDummy& get() {
static GyroscopeSensorDummy gyro;
return gyro;
}
protected:
std::minstd_rand gen;
std::uniform_real_distribution<float> distNoise = std::uniform_real_distribution<float>(-0.1, +0.1);
GyroscopeData getRandomEntry() override {
const Timestamp ts = Timestamp::fromRunningTime();
const float Hz = 0.1;
const float intensity = 0.35;
const float x = distNoise(gen);
const float y = distNoise(gen);
const float z = std::sin(ts.sec()*2*M_PI*Hz) * intensity + distNoise(gen);
return GyroscopeData(x,y,z);
}
};
#endif // GYROSCOPESENSORDUMMY_H

View File

@@ -0,0 +1,56 @@
#ifndef RANDOMSENSOR_H
#define RANDOMSENSOR_H
#include <thread>
#include <Indoor/data/Timestamp.h>
#include <Indoor/Assertions.h>
template <typename Element, typename BaseClass> class RandomSensor : public BaseClass {
private:
std::thread thread;
bool running = false;
Timestamp interval;
public:
RandomSensor(const Timestamp interval) : interval(interval) {
;
}
void start() override {
Assert::isFalse(running, "sensor allready running!");
running = true;
thread = std::thread(&RandomSensor::run, this);
}
void stop() override {
Assert::isTrue(running, "sensor not yet running!");
running = false;
thread.join();
}
protected:
/** subclasses must provide a random entry here */
virtual Element getRandomEntry() = 0;
private:
void run() {
while(running) {
const Element rnd = getRandomEntry();
Sensor<Element>::informListeners(rnd);
std::this_thread::sleep_for(std::chrono::milliseconds(interval.ms()));
}
}
};
#endif // RANDOMSENSOR_H

View File

@@ -0,0 +1,36 @@
#ifndef SENSORFACTORYDUMMY_H
#define SENSORFACTORYDUMMY_H
#include "../SensorFactory.h"
#include "WiFiSensorDummy.h"
#include "AccelerometerSensorDummy.h"
#include "GyroscopeSensorDummy.h"
#include "BarometerSensorDummy.h"
/**
* sensor factory that provides sensors that fire dummy data
*/
class SensorFactoryDummy : public SensorFactory {
public:
WiFiSensor& getWiFi() override {
return WiFiSensorDummy::get();
}
AccelerometerSensor& getAccelerometer() override {
return AccelerometerSensorDummy::get();
}
GyroscopeSensor& getGyroscope() override {
return GyroscopeSensorDummy::get();
}
BarometerSensor& getBarometer() override {
return BarometerSensorDummy::get();
}
};
#endif // SENSORFACTORYDUMMY_H

View File

@@ -54,6 +54,12 @@ private:
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;
@@ -73,11 +79,11 @@ private:
const float y = cy + std::cos(deg) * rad;
// construct scan data
WiFiSensorData scan;
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(WiFiSensorDataEntry(ap.mac, rssi));
scan.entries.push_back(WiFiMeasurement(AccessPoint(ap.mac), rssi));
}
// call