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:
110
sensors/offline/AllInOneSensor.h
Normal file
110
sensors/offline/AllInOneSensor.h
Normal file
@@ -0,0 +1,110 @@
|
||||
#ifndef ALLINONESENSOR_H
|
||||
#define ALLINONESENSOR_H
|
||||
|
||||
#include "Settings.h"
|
||||
#include <string>
|
||||
#include "../WiFiSensor.h"
|
||||
#include "../AccelerometerSensor.h"
|
||||
#include "../GyroscopeSensor.h"
|
||||
#include "../BarometerSensor.h"
|
||||
#include <Indoor/sensors/offline/OfflineAndroid.h>
|
||||
|
||||
class AllInOneSensor :
|
||||
public WiFiSensor, public AccelerometerSensor, public GyroscopeSensor, public BarometerSensor,
|
||||
public OfflineAndroidListener {
|
||||
|
||||
private:
|
||||
|
||||
std::string file;
|
||||
bool running = false;
|
||||
std::thread thread;
|
||||
|
||||
public:
|
||||
|
||||
AllInOneSensor(const std::string& file) : file(file) {
|
||||
;
|
||||
}
|
||||
|
||||
void start() {
|
||||
if (running) {return;}
|
||||
running = true;
|
||||
thread = std::thread(&AllInOneSensor::run, this);
|
||||
}
|
||||
|
||||
void stop() {
|
||||
if (!running) {return;}
|
||||
running = false;
|
||||
thread.join();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void onGyroscope(const Timestamp _ts, const GyroscopeData data) override {
|
||||
const Timestamp ts = relativeTS(_ts);
|
||||
handbrake(ts);
|
||||
GyroscopeSensor::informListeners(ts, data);
|
||||
}
|
||||
|
||||
virtual void onAccelerometer(const Timestamp _ts, const AccelerometerData data) override {
|
||||
const Timestamp ts = relativeTS(_ts);
|
||||
handbrake(ts);
|
||||
AccelerometerSensor::informListeners(ts, data);
|
||||
}
|
||||
|
||||
virtual void onGravity(const Timestamp ts, const AccelerometerData data) override {
|
||||
(void) ts;
|
||||
(void) data;
|
||||
}
|
||||
|
||||
virtual void onWiFi(const Timestamp _ts, const WiFiMeasurements data) override {
|
||||
const Timestamp ts = relativeTS(_ts);
|
||||
handbrake(ts);
|
||||
WiFiMeasurements copy = data;
|
||||
for (WiFiMeasurement& m : copy.entries) {m.ts = ts;} // make each timestmap also relative
|
||||
WiFiSensor::informListeners(ts, copy);
|
||||
}
|
||||
|
||||
virtual void onBarometer(const Timestamp _ts, const BarometerData data) override {
|
||||
const Timestamp ts = relativeTS(_ts);
|
||||
handbrake(ts);
|
||||
BarometerSensor::informListeners(ts, data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Timestamp baseTS;
|
||||
Timestamp relativeTS(const Timestamp ts) {
|
||||
if (baseTS.isZero()) {baseTS = ts;}
|
||||
return ts - baseTS;
|
||||
}
|
||||
|
||||
/** handbrake for the offline-parser to ensure realtime events */
|
||||
Timestamp startSensorTS;
|
||||
Timestamp startSystemTS;
|
||||
|
||||
void handbrake(const Timestamp ts) {
|
||||
if (startSensorTS.isZero()) {startSensorTS = ts;}
|
||||
if (startSystemTS.isZero()) {startSystemTS = Timestamp::fromUnixTime();}
|
||||
const Timestamp runtimeOfflineData = ts - startSensorTS;;
|
||||
const Timestamp runtimeSystemTime = (Timestamp::fromUnixTime() - startSystemTS) * Settings::offlineSensorSpeedup;
|
||||
const Timestamp diff = (runtimeOfflineData - runtimeSystemTime);
|
||||
if (diff > Timestamp::fromMS(0)) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(diff.ms()));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* file-parsing runs in a background thread
|
||||
* the parsing is manually slowed down via handbrake()
|
||||
* which blocks during the event callbacks
|
||||
*/
|
||||
void run() {
|
||||
OfflineAndroid parser;
|
||||
parser.parse(file, this);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // ALLINONESENSOR_H
|
||||
43
sensors/offline/SensorFactoryOffline.h
Normal file
43
sensors/offline/SensorFactoryOffline.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef SENSORFACTORYOFFLINE_H
|
||||
#define SENSORFACTORYOFFLINE_H
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "../SensorFactory.h"
|
||||
#include "AllInOneSensor.h"
|
||||
#include <Indoor/sensors/offline/OfflineAndroid.h>
|
||||
|
||||
/**
|
||||
* factory class that provides sensors that fire events from offline data
|
||||
*/
|
||||
class SensorFactoryOffline : public SensorFactory {
|
||||
|
||||
private:
|
||||
|
||||
AllInOneSensor allInOne;
|
||||
|
||||
public:
|
||||
|
||||
SensorFactoryOffline(const std::string& file) : allInOne(file) {
|
||||
;
|
||||
}
|
||||
|
||||
WiFiSensor& getWiFi() override {
|
||||
return allInOne;
|
||||
}
|
||||
|
||||
AccelerometerSensor& getAccelerometer() override {
|
||||
return allInOne;
|
||||
}
|
||||
|
||||
GyroscopeSensor& getGyroscope() override {
|
||||
return allInOne;
|
||||
}
|
||||
|
||||
BarometerSensor& getBarometer() override {
|
||||
return allInOne;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SENSORFACTORYOFFLINE_H
|
||||
Reference in New Issue
Block a user