diff --git a/Controller.cpp b/Controller.cpp index c765807..5b6f52d 100644 --- a/Controller.cpp +++ b/Controller.cpp @@ -16,6 +16,7 @@ #include #include +#include #include @@ -28,11 +29,13 @@ #include "sensors/dummy/SensorFactoryDummy.h" #include "sensors/android/SensorFactoryAndroid.h" #include "sensors/offline/SensorFactoryOffline.h" +#include "sensors/SensorWriter.h" #include "tools/calibration/WiFiCalibrationDataModel.h" #include "nav/NavController.h" + Controller::Controller() { // OpenGL setup @@ -51,13 +54,29 @@ Controller::Controller() { //SensorFactory::set(new SensorFactoryOffline(Settings::Data::getOfflineDir() + "bergwerk/path3/nexus/vor/1454782562231.csv")); //SensorFactory::set(new SensorFactoryOffline(Settings::Data::getOfflineDir() + "/bergwerk/path4/nexus/rueck/1454776724285_rueck.csv")); - SensorFactory::set(new SensorFactoryOffline(Settings::Data::getOfflineDir() + "/bergwerk/path4/nexus/vor/1454776525797.csv")); + //SensorFactory::set(new SensorFactoryOffline(Settings::Data::getOfflineDir() + "/bergwerk/path4/nexus/vor/1454776525797.csv")); + + // live data on the smartphone + if (1 == 1) { + + // use android's sensors + SensorFactory::set(new SensorFactoryAndroid()); + + // write them to file?? + //const std::string file = Settings::Data::getRecordsDir() + "/" + std::to_string(Timestamp::fromUnixTime().ms()) + ".csv"; + //SensorWriter* writer = new SensorWriter(); + //writer->start(file); + + // start the sensors + SensorFactory::get().getAccelerometer().start(); + SensorFactory::get().getGyroscope().start(); + SensorFactory::get().getBarometer().start(); + SensorFactory::get().getWiFi().start(); + SensorFactory::get().getGPS().start(); + SensorFactory::get().getCompass().start(); + + } -// SensorFactory::set(new SensorFactoryAndroid()); -// SensorFactory::get().getAccelerometer().start(); -// SensorFactory::get().getGyroscope().start(); -// SensorFactory::get().getBarometer().start(); -// SensorFactory::get().getWiFi().start(); // create the main window @@ -126,13 +145,13 @@ void buildGridOnce(Grid* grid, Floorplan::IndoorMap* map, const std: WiFiCalibrationDataModel mdl(fpFile); Assert::isFalse(mdl.getFingerprints().empty(), "no fingerprints available!"); - WiFiOptimizer opt(map, Settings::WiFiModel::vg_calib); + WiFiOptimizer::LogDistCeiling opt(map, Settings::WiFiModel::vg_calib); for (const WiFiFingerprint& fp : mdl.getFingerprints()) { opt.addFingerprint(fp); } - const std::vector res = opt.optimizeAll(); + const WiFiOptimizer::LogDistCeiling::APParamsList res = opt.optimizeAll(opt.NONE); WiFiGridEstimator::estimate(*grid, wifiModel, Settings::smartphoneAboveGround); - for (const WiFiOptimizer::APParamsMAC& ap : res) { + for (const WiFiOptimizer::LogDistCeiling::APParamsMAC& ap : res.get()) { const WiFiModelLogDistCeiling::APEntry entry(ap.params.getPos(), ap.params.txp, ap.params.exp, ap.params.waf); wifiModel.addAP(ap.mac, entry); } diff --git a/Settings.h b/Settings.h index 1319c91..304a916 100644 --- a/Settings.h +++ b/Settings.h @@ -80,11 +80,11 @@ namespace Settings { // qDebug(folder.c_str()); // return folder; //return "/storage/sdcard1/YASMIN/"; - std::string f1 = "/storage/sdcard1/YASMIN/"; - std::string f2 = "/sdcard/YASMIN/"; + const std::string f1 = "/storage/sdcard1/YASMIN/"; + const std::string f2 = "/sdcard/YASMIN/"; if (QFile(f1.c_str()).exists()) {return f1;} if (QFile(f2.c_str()).exists()) {return f2;} - throw Exception("data folder missing"); + throw Exception("data folder missing. one of those:\n" + f1 + "\n" + f2); #else //return "/home/toni/Documents/programme/localization/YASMIN/YASMIN_DATA/"; return "/apps/android/workspace/YASMIN_DATA/"; @@ -100,6 +100,10 @@ namespace Settings { return getRoot() + "offline/"; } + static inline std::string getRecordsDir() { + return getRoot() + "records/"; + } + } } diff --git a/ipin/StepLoggerWrapperAndroid.h b/ipin/StepLoggerWrapperAndroid.h index 0c6560c..7a342fb 100644 --- a/ipin/StepLoggerWrapperAndroid.h +++ b/ipin/StepLoggerWrapperAndroid.h @@ -48,7 +48,7 @@ private: /** call java */ void log(const double x, const double y, const double z) { -#ifdef ANDROID +#ifdef _ANDROID //Log::add("SLWA", "calling android with lon/lat/floor"); double rounded_z = std::round(z); diff --git a/sensors/CompassSensor.h b/sensors/CompassSensor.h new file mode 100644 index 0000000..c1dc35c --- /dev/null +++ b/sensors/CompassSensor.h @@ -0,0 +1,12 @@ +#ifndef COMPASSSENSOR_H +#define COMPASSSENSOR_H + +#include "Sensor.h" +#include + +class CompassSensor : public Sensor { + +}; + + +#endif // COMPASSSENSOR_H diff --git a/sensors/GPSSensor.h b/sensors/GPSSensor.h new file mode 100644 index 0000000..c62d92a --- /dev/null +++ b/sensors/GPSSensor.h @@ -0,0 +1,11 @@ +#ifndef GPSSENSOR_H +#define GPSSENSOR_H + +#include "Sensor.h" +#include + +class GPSSensor : public Sensor { + +}; + +#endif // GPSSENSOR_H diff --git a/sensors/SensorFactory.h b/sensors/SensorFactory.h index d7acbd1..4bdcb18 100644 --- a/sensors/SensorFactory.h +++ b/sensors/SensorFactory.h @@ -20,6 +20,14 @@ #include "android/BarometerSensorAndroid.h" #include "dummy/BarometerSensorDummy.h" +#include "GPSSensor.h" +#include "android/GPSSensorAndroid.h" +#include "dummy/GPSSensorDummy.h" + +#include "CompassSensor.h" +#include "android/CompassSensorAndroid.h" +#include "dummy/CompassSensorDummy.h" + #include "StepSensor.h" #include "TurnSensor.h" #include "ActivitySensor.h" @@ -39,13 +47,13 @@ public: /** set the to-be-used sensor-fatory */ static void set(SensorFactory* fac) { - Assert::isNull(*getPtr(), "set() was already called. currentely this is not intended"); + Assert::isNull(*getPtr(), "SensorFactory::set() was already called. currentely this is not intended"); *getPtr() = fac; } /** get the currently configured sensory factory */ static SensorFactory& get() { - Assert::isNotNull(*getPtr(), "call set() first to set an actual factory instance!"); + Assert::isNotNull(*getPtr(), "call SensorFactory::set() first to set an actual factory instance!"); return **getPtr(); } @@ -63,6 +71,13 @@ public: /** get the Barometer sensor */ virtual BarometerSensor& getBarometer() = 0; + /** get the compass sensor */ + virtual CompassSensor& getCompass() = 0; + + /** get the gps sensor */ + virtual GPSSensor& getGPS() = 0; + + /** get the Step sensor */ StepSensor& getSteps() { static StepSensor steps(getAccelerometer()); diff --git a/sensors/SensorWriter.h b/sensors/SensorWriter.h new file mode 100644 index 0000000..9a686ec --- /dev/null +++ b/sensors/SensorWriter.h @@ -0,0 +1,101 @@ +#ifndef SENSORWRITER_H +#define SENSORWRITER_H + +#include "AccelerometerSensor.h" +#include "GyroscopeSensor.h" +#include "BarometerSensor.h" +#include "StepSensor.h" +#include "TurnSensor.h" +#include "WiFiSensor.h" +#include "ActivitySensor.h" +#include "GPSSensor.h" +#include "CompassSensor.h" +#include "SensorFactory.h" + +#include + +/** + * receives live sensor data + * writes it to a file + */ +class SensorWriter : + public SensorListener, + public SensorListener, + public SensorListener, +// public SensorListener, +// public SensorListener, +// public SensorListener, + public SensorListener, + public SensorListener, + public SensorListener { + +private: + + Offline::FileWriter writer; + bool active = false; + +public: + + /** empty ctor */ + SensorWriter() { + + // attach as listener to all sensors we want to store + SensorFactory::get().getAccelerometer().addListener(this); + SensorFactory::get().getGyroscope().addListener(this); + SensorFactory::get().getBarometer().addListener(this); +// SensorFactory::get().getActivity().addListener(this); +// SensorFactory::get().getSteps().addListener(this); +// SensorFactory::get().getTurns().addListener(this); + SensorFactory::get().getWiFi().addListener(this); + SensorFactory::get().getCompass().addListener(this); + SensorFactory::get().getGPS().addListener(this); + + } + + + + void start(const std::string& file) { + writer.open(file); + active = true; + } + + void stop() { + active = false; + writer.close(); + } + +public: + + virtual void onSensorData(Sensor* , const Timestamp ts, const AccelerometerData& data) override { + if (!active) {return;} + writer.add(ts, data); + } + + virtual void onSensorData(Sensor* , const Timestamp ts, const GyroscopeData& data) override { + if (!active) {return;} + writer.add(ts, data); + } + + virtual void onSensorData(Sensor* , const Timestamp ts, const BarometerData& data) override { + if (!active) {return;} + writer.add(ts, data); + } + + virtual void onSensorData(Sensor* , const Timestamp ts, const WiFiMeasurements& data) override { + if (!active) {return;} + writer.add(ts, data); + } + + virtual void onSensorData(Sensor* , const Timestamp ts, const GPSData& data) override { + if (!active) {return;} + writer.add(ts, data); + } + + virtual void onSensorData(Sensor* , const Timestamp ts, const CompassData& data) override { + if (!active) {return;} + writer.add(ts, data); + } + +}; + +#endif // SENSORWRITER_H diff --git a/sensors/android/AccelerometerSensorAndroid.h b/sensors/android/AccelerometerSensorAndroid.h index 210b647..1632856 100644 --- a/sensors/android/AccelerometerSensorAndroid.h +++ b/sensors/android/AccelerometerSensorAndroid.h @@ -1,7 +1,6 @@ #ifndef ACCELEROMETERSENSORANDROID_H #define ACCELEROMETERSENSORANDROID_H - #ifdef ANDROID #include diff --git a/sensors/android/CompassSensorAndroid.h b/sensors/android/CompassSensorAndroid.h new file mode 100644 index 0000000..a9a9c31 --- /dev/null +++ b/sensors/android/CompassSensorAndroid.h @@ -0,0 +1,63 @@ +#ifndef COMPASSSENSORANDROID_H +#define COMPASSSENSORANDROID_H + +#ifdef ANDROID + +#include + +#include "../CompassSensor.h" + +#include + +class CompassSensorAndroid : public CompassSensor { + +private: + + QCompass compass; + + /** hidden ctor. use singleton */ + CompassSensorAndroid() { + ; + } + + bool started = false; + +public: + + /** singleton access */ + static CompassSensorAndroid& get() { + static CompassSensorAndroid compass; + return compass; + } + + void start() override { + + if (started) {return;} + started = true; + + auto onSensorData = [&] () { + CompassData data( + compass.reading()->azimuth(), + compass.reading()->calibrationLevel() + ); + informListeners(data); + }; + + compass.connect(&compass, &QCompass::readingChanged, onSensorData); + compass.start(); + + } + + bool isRunning() const override { + return started; + } + + void stop() override { + throw "TODO"; + } + +}; + +#endif + +#endif // COMPASSSENSORANDROID_H diff --git a/sensors/android/GPSSensorAndroid.h b/sensors/android/GPSSensorAndroid.h new file mode 100644 index 0000000..b5629ed --- /dev/null +++ b/sensors/android/GPSSensorAndroid.h @@ -0,0 +1,74 @@ +#ifndef GPSSENSORANDROID_H +#define GPSSENSORANDROID_H + +#ifdef ANDROID + +#include + +#include "../GPSSensor.h" + +#include + +class GPSSensorAndroid : public GPSSensor { + +private: + + QGeoPositionInfoSource* source; + + /** hidden ctor. use singleton */ + GPSSensorAndroid() { + + source = QGeoPositionInfoSource::createDefaultSource(nullptr); + return; + + } + + bool started = false; + +public: + + /** singleton access */ + static GPSSensorAndroid& get() { + static GPSSensorAndroid gps; + return gps; + } + + void start() override { + + if (started) {return;} + started = true; + + auto onPositionData = [&] (const QGeoPositionInfo& update) { + + GPSData data( + //Timestamp::ms(update.timestamp().toMSecsSinceEpoch()), + Timestamp::fromRunningTime(), + update.coordinate().latitude(), + update.coordinate().longitude(), + update.coordinate().altitude() + ); + + informListeners(data); + + }; + + if (source) { + source->connect(source, &QGeoPositionInfoSource::positionUpdated, onPositionData); + source->startUpdates(); + } + + } + + bool isRunning() const override { + return started; + } + + void stop() override { + throw "TODO"; + } + +}; + +#endif // ANDROID + +#endif // GPSSENSORANDROID_H diff --git a/sensors/android/SensorFactoryAndroid.h b/sensors/android/SensorFactoryAndroid.h index 454e71a..8729c02 100644 --- a/sensors/android/SensorFactoryAndroid.h +++ b/sensors/android/SensorFactoryAndroid.h @@ -9,6 +9,8 @@ #include "AccelerometerSensorAndroid.h" #include "GyroscopeSensorAndroid.h" #include "BarometerSensorAndroid.h" +#include "CompassSensorAndroid.h" +#include "GPSSensorAndroid.h" /** * sensor factory that provides real hardware sensors from @@ -34,6 +36,14 @@ public: return BarometerSensorAndroid::get(); } + CompassSensor& getCompass() override { + return CompassSensorAndroid::get(); + } + + GPSSensor& getGPS() override { + return GPSSensorAndroid::get(); + } + }; #endif diff --git a/sensors/dummy/CompassSensorDummy.h b/sensors/dummy/CompassSensorDummy.h new file mode 100644 index 0000000..eaf77b6 --- /dev/null +++ b/sensors/dummy/CompassSensorDummy.h @@ -0,0 +1,43 @@ +#ifndef COMPASSSENSORDUMMY_H +#define COMPASSSENSORDUMMY_H + +#include "../CompassSensor.h" +#include "RandomSensor.h" +#include + +class CompassSensorDummy : public RandomSensor { + +private: + + std::thread thread; + + /** hidden ctor */ + CompassSensorDummy() : RandomSensor(Timestamp::fromMS(100)) { + ; + } + +public: + + /** singleton access */ + static CompassSensorDummy& get() { + static CompassSensorDummy compass; + return compass; + } + +protected: + + std::minstd_rand gen; + std::uniform_real_distribution distNoise = std::uniform_real_distribution(-0.07, +0.07); + + CompassData getRandomEntry() override { + + const Timestamp ts = Timestamp::fromRunningTime(); + + const float azimuth = 0 + std::sin(ts.sec()) * 0.5 + distNoise(gen); + return CompassData(azimuth); + + } + +}; + +#endif // COMPASSSENSORDUMMY_H diff --git a/sensors/dummy/GPSSensorDummy.h b/sensors/dummy/GPSSensorDummy.h new file mode 100644 index 0000000..5d8ae83 --- /dev/null +++ b/sensors/dummy/GPSSensorDummy.h @@ -0,0 +1,46 @@ +#ifndef GPSSENSORDUMMY_H +#define GPSSENSORDUMMY_H + + +#include "../GPSSensor.h" +#include "RandomSensor.h" +#include + +class GPSSensorDummy : public RandomSensor { + +private: + + std::thread thread; + + /** hidden ctor */ + GPSSensorDummy() : RandomSensor(Timestamp::fromMS(1000)) { + ; + } + +public: + + /** singleton access */ + static GPSSensorDummy& get() { + static GPSSensorDummy gps; + return gps; + } + +protected: + + std::minstd_rand gen; + std::uniform_real_distribution distNoise = std::uniform_real_distribution(-0.09, +0.09); + + GPSData getRandomEntry() override { + + const Timestamp ts = Timestamp::fromRunningTime(); + const float lat = 49.7773992; + const float lon = 9.9627029; + const float alt = 100; + return GPSData(ts, lat, lon, alt); + + } + +}; + + +#endif // GPSSENSORDUMMY_H diff --git a/sensors/dummy/SensorFactoryDummy.h b/sensors/dummy/SensorFactoryDummy.h index 2af30f1..3d4911c 100644 --- a/sensors/dummy/SensorFactoryDummy.h +++ b/sensors/dummy/SensorFactoryDummy.h @@ -7,6 +7,8 @@ #include "AccelerometerSensorDummy.h" #include "GyroscopeSensorDummy.h" #include "BarometerSensorDummy.h" +#include "GPSSensorDummy.h" +#include "CompassSensorDummy.h" /** * sensor factory that provides sensors that fire dummy data @@ -31,6 +33,14 @@ public: return BarometerSensorDummy::get(); } + CompassSensor& getCompass() override { + return CompassSensorDummy::get(); + } + + GPSSensor& getGPS() override { + return GPSSensorDummy::get(); + } + }; #endif // SENSORFACTORYDUMMY_H diff --git a/sensors/offline/AllInOneSensor.h b/sensors/offline/AllInOneSensor.h index 21001f8..956a993 100644 --- a/sensors/offline/AllInOneSensor.h +++ b/sensors/offline/AllInOneSensor.h @@ -7,11 +7,16 @@ #include "../AccelerometerSensor.h" #include "../GyroscopeSensor.h" #include "../BarometerSensor.h" +#include "../CompassSensor.h" +#include "../GPSSensor.h" + #include +#include class AllInOneSensor : public WiFiSensor, public AccelerometerSensor, public GyroscopeSensor, public BarometerSensor, - public OfflineAndroidListener { + public CompassSensor, public GPSSensor, + public Offline::Listener { private: @@ -74,6 +79,18 @@ protected: BarometerSensor::informListeners(ts, data); } + virtual void onGPS(const Timestamp _ts, const GPSData data) override { + const Timestamp ts = relativeTS(_ts); + handbrake(ts); + GPSSensor::informListeners(ts, data); + } + + virtual void onCompass(const Timestamp _ts, const CompassData data) override { + const Timestamp ts = relativeTS(_ts); + handbrake(ts); + CompassSensor::informListeners(ts, data); + } + private: Timestamp baseTS; diff --git a/sensors/offline/SensorFactoryOffline.h b/sensors/offline/SensorFactoryOffline.h index bbde418..8bba373 100644 --- a/sensors/offline/SensorFactoryOffline.h +++ b/sensors/offline/SensorFactoryOffline.h @@ -38,6 +38,14 @@ public: return allInOne; } + CompassSensor& getCompass() override { + return allInOne; + } + + GPSSensor& getGPS() override { + return allInOne; + } + }; #endif // SENSORFACTORYOFFLINE_H diff --git a/ui/debug/PlotGPS.cpp b/ui/debug/PlotGPS.cpp new file mode 100644 index 0000000..49c1c57 --- /dev/null +++ b/ui/debug/PlotGPS.cpp @@ -0,0 +1,37 @@ +#include "PlotGPS.h" +#include + +PlotGPS::PlotGPS(QWidget *parent) : QWidget(parent) { + + setMinimumWidth(32); + setMinimumHeight(96); + +} + +void PlotGPS::add(const Timestamp ts, const GPSData& data) { + (void) ts; + this->gpsData = data; +} + +void PlotGPS::paintEvent(QPaintEvent* evt) { + + (void) evt; + QPainter p(this); + + // frame + p.fillRect(0,0,width(),height(),QColor(255,255,255,192)); + p.setPen(Qt::black); + p.drawRect(0,0,width()-1,height()-1); + + // turn [relative] + const QPen pen(Qt::black); + p.setPen(pen); + p.drawText(4, 1*12, QString::number(gpsData.tsReceived.ms())); + p.drawText(4, 2*12, QString::number(gpsData.lat)); + p.drawText(4, 3*12, QString::number(gpsData.lon)); + p.drawText(4, 4*12, QString::number(gpsData.alt)); + p.drawText(4, 5*12, QString::number(gpsData.accuracy)); + + p.end(); + +} diff --git a/ui/debug/PlotGPS.h b/ui/debug/PlotGPS.h new file mode 100644 index 0000000..cdafffb --- /dev/null +++ b/ui/debug/PlotGPS.h @@ -0,0 +1,32 @@ +#ifndef PLOTGPS_H +#define PLOTGPS_H + + +#include +#include "../sensors/GPSSensor.h" + +#include + +class PlotGPS : public QWidget { + + Q_OBJECT + +private: + + GPSData gpsData; + +public: + + explicit PlotGPS(QWidget *parent = 0); + + void add(const Timestamp ts, const GPSData& data); + +signals: + +public slots: + + void paintEvent(QPaintEvent*); + +}; + +#endif // PLOTGPS_H diff --git a/ui/debug/PlotTurns.cpp b/ui/debug/PlotTurns.cpp index 3b94e59..d3966af 100644 --- a/ui/debug/PlotTurns.cpp +++ b/ui/debug/PlotTurns.cpp @@ -17,7 +17,16 @@ PlotTurns::PlotTurns(QWidget *parent) : QWidget(parent) { void PlotTurns::add(const Timestamp ts, const TurnData& data) { (void) ts; - this->data = data; + this->turnData = data; + static int i = 0; + if (++i % 4 == 0) { + QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection); + } +} + +void PlotTurns::add(const Timestamp ts, const CompassData& data) { + (void) ts; + this->compassData = data; static int i = 0; if (++i % 4 == 0) { QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection); @@ -35,17 +44,26 @@ void PlotTurns::paintEvent(QPaintEvent* evt) { const float cx = width() / 2; const float cy = height() / 2; - const float x1 = cx + std::cos(data.radSinceStart-M_PI_2) * s1; - const float y1 = cy + std::sin(data.radSinceStart-M_PI_2) * s1; - p.fillRect(0,0,width(),height(),QColor(255,255,255,192)); p.setPen(Qt::black); p.drawRect(0,0,width()-1,height()-1); - const QPen pen(Qt::black, 2); - p.setPen(pen); + // turn [relative] + const float x1 = cx + std::cos(turnData.radSinceStart-M_PI_2) * s1; + const float y1 = cy + std::sin(turnData.radSinceStart-M_PI_2) * s1; + const QPen pen1(Qt::black, 2); + p.setPen(pen1); p.drawLine(cx, cy, x1, y1); + // compass [absolute] + if (compassData.isValid()) { + const float x2 = cx + std::cos(compassData.azimuth) * s1; + const float y2 = cy + std::sin(compassData.azimuth) * s1; + const QPen pen2(Qt::gray, 2); + p.setPen(pen2); + p.drawLine(cx, cy, x2, y2); + } + p.end(); } diff --git a/ui/debug/PlotTurns.h b/ui/debug/PlotTurns.h index 6cc3027..cf23b06 100644 --- a/ui/debug/PlotTurns.h +++ b/ui/debug/PlotTurns.h @@ -3,6 +3,8 @@ #include #include "../sensors/TurnSensor.h" +#include "../sensors/CompassSensor.h" + #include class PlotTurns : public QWidget { @@ -11,7 +13,8 @@ class PlotTurns : public QWidget { private: - TurnData data; + TurnData turnData; + CompassData compassData; public: @@ -19,7 +22,7 @@ public: void add(const Timestamp ts, const TurnData& data); - //QSize sizeHint() const {return QSize(96, 96);} + void add(const Timestamp ts, const CompassData& data); signals: diff --git a/ui/debug/SensorDataWidget.cpp b/ui/debug/SensorDataWidget.cpp index 9e8c14e..52037b9 100644 --- a/ui/debug/SensorDataWidget.cpp +++ b/ui/debug/SensorDataWidget.cpp @@ -7,6 +7,7 @@ #include "../sensors/SensorFactory.h" #include "PlotTurns.h" +#include "PlotGPS.h" #include "PlotWiFiScan.h" #include "../Settings.h" @@ -196,14 +197,17 @@ SensorDataWidget::SensorDataWidget(QWidget* parent) : QWidget(parent) { plotBaro = new PlotBaro(this); plotTurn = new PlotTurns(this); plotWiFi = new PlotWiFiScan(this); + plotGPS = new PlotGPS(this); // layout setup lay = new QGridLayout(this); lay->addWidget(plotGyro, 0, 0, 1, 4); lay->addWidget(plotAcc, 1, 0, 1, 4); lay->addWidget(plotBaro, 2, 0, 1, 4); + lay->addWidget(plotTurn, 3, 0, 1, 1); - lay->addWidget(plotWiFi, 3, 1, 1, 3); + lay->addWidget(plotGPS, 3, 1, 1, 1); + lay->addWidget(plotWiFi, 3, 2, 1, 2); // lay->setRowStretch(0, 1); // lay->setRowStretch(1, 1); @@ -221,6 +225,8 @@ SensorDataWidget::SensorDataWidget(QWidget* parent) : QWidget(parent) { SensorFactory::get().getTurns().addListener(this); SensorFactory::get().getWiFi().addListener(this); SensorFactory::get().getActivity().addListener(this); + SensorFactory::get().getCompass().addListener(this); + SensorFactory::get().getGPS().addListener(this); } @@ -257,6 +263,16 @@ void SensorDataWidget::onSensorData(Sensor* sensor, const Timestamp ts ((PlotTurns*)plotTurn)->add(ts, data); } +void SensorDataWidget::onSensorData(Sensor* sensor, const Timestamp ts, const CompassData& data) { + (void) sensor; + ((PlotTurns*)plotTurn)->add(ts, data); +} + +void SensorDataWidget::onSensorData(Sensor* sensor, const Timestamp ts, const GPSData& data) { + (void) sensor; + ((PlotGPS*)plotGPS)->add(ts, data); +} + void SensorDataWidget::onSensorData(Sensor* sensor, const Timestamp ts, const WiFiMeasurements& data) { (void) sensor; ((PlotWiFiScan*)plotWiFi)->add(ts, data); diff --git a/ui/debug/SensorDataWidget.h b/ui/debug/SensorDataWidget.h index 54d0d4a..61e8b22 100644 --- a/ui/debug/SensorDataWidget.h +++ b/ui/debug/SensorDataWidget.h @@ -13,6 +13,8 @@ #include "../sensors/TurnSensor.h" #include "../sensors/WiFiSensor.h" #include "../sensors/ActivitySensor.h" +#include "../sensors/GPSSensor.h" +#include "../sensors/CompassSensor.h" class PlotWidget; class QGridLayout; @@ -26,7 +28,9 @@ class SensorDataWidget : public SensorListener, public SensorListener, public SensorListener, - public SensorListener { + public SensorListener, + public SensorListener, + public SensorListener { Q_OBJECT @@ -43,18 +47,21 @@ public: void onSensorData(Sensor* sensor, const Timestamp ts, const TurnData& data) override; void onSensorData(Sensor* sensor, const Timestamp ts, const WiFiMeasurements& data) override; void onSensorData(Sensor* sensor, const Timestamp ts, const ActivityData& data) override; + void onSensorData(Sensor* sensor, const Timestamp ts, const GPSData& data) override; + void onSensorData(Sensor* sensor, const Timestamp ts, const CompassData& data) override; private: PlotWidget* plotGyro; PlotWidget* plotAcc; PlotWidget* plotBaro; + QWidget* plotTurn; QWidget* plotWiFi; + QWidget* plotGPS; QGridLayout* lay; - }; #endif // SENSORDATAWIDGET_H diff --git a/ui/debug/plot/PlottWidget.h b/ui/debug/plot/PlottWidget.h index 6c4d84a..119c368 100644 --- a/ui/debug/plot/PlottWidget.h +++ b/ui/debug/plot/PlottWidget.h @@ -2,6 +2,7 @@ #define PLOTTI_H #include +#include "../misc/fixc11.h" #include "Plot.h" /** widget to render one plot */ diff --git a/yasmin.pro b/yasmin.pro index dd0e86b..2c74380 100644 --- a/yasmin.pro +++ b/yasmin.pro @@ -9,6 +9,7 @@ QT += qml opengl svg ANDROID { QT += androidextras QT += sensors + QT += positioning #http://stackoverflow.com/questions/28391685/opencv-with-hard-float-support-for-android#28393545 # wasn't faster... and seems dangerous :P @@ -78,7 +79,8 @@ SOURCES += \ ui/debug/InfoWidget.cpp \ ui/map/3D/MapView3D.cpp \ ui/map/2D/MapView2D.cpp \ - tools/calibration/WiFiCalibrationScanDialog.cpp + tools/calibration/WiFiCalibrationScanDialog.cpp \ + ui/debug/PlotGPS.cpp RESOURCES += qml.qrc @@ -183,7 +185,15 @@ HEADERS += \ ipin/IPINHelper.h \ nav/NavControllerListener.h \ ipin/StepLoggerWrapper.h \ - ipin/StepLoggerWrapperAndroid.h + ipin/StepLoggerWrapperAndroid.h \ + sensors/GPSSensor.h \ + sensors/android/GPSSensorAndroid.h \ + sensors/CompassSensor.h \ + sensors/android/CompassSensorAndroid.h \ + sensors/dummy/CompassSensorDummy.h \ + sensors/dummy/GPSSensorDummy.h \ + ui/debug/PlotGPS.h \ + sensors/SensorWriter.h DISTFILES += \ android-sources/src/MyActivity.java \