added gps support
added compass support added ui elements for gps and compass added support for writing sensor data
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <Indoor/floorplan/v2/FloorplanHelper.h>
|
||||
|
||||
#include <Indoor/sensors/radio/WiFiGridEstimator.h>
|
||||
#include <Indoor/sensors/radio/setup/WiFiOptimizerLogDistCeiling.h>
|
||||
|
||||
#include <Indoor/Assertions.h>
|
||||
|
||||
@@ -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<MyGridNode>* 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<WiFiOptimizer::APParamsMAC> 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);
|
||||
}
|
||||
|
||||
10
Settings.h
10
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/";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
12
sensors/CompassSensor.h
Normal file
12
sensors/CompassSensor.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef COMPASSSENSOR_H
|
||||
#define COMPASSSENSOR_H
|
||||
|
||||
#include "Sensor.h"
|
||||
#include <Indoor/sensors/imu/CompassData.h>
|
||||
|
||||
class CompassSensor : public Sensor<CompassData> {
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // COMPASSSENSOR_H
|
||||
11
sensors/GPSSensor.h
Normal file
11
sensors/GPSSensor.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef GPSSENSOR_H
|
||||
#define GPSSENSOR_H
|
||||
|
||||
#include "Sensor.h"
|
||||
#include <Indoor/sensors/gps/GPSData.h>
|
||||
|
||||
class GPSSensor : public Sensor<GPSData> {
|
||||
|
||||
};
|
||||
|
||||
#endif // GPSSENSOR_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());
|
||||
|
||||
101
sensors/SensorWriter.h
Normal file
101
sensors/SensorWriter.h
Normal file
@@ -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 <Indoor/sensors/offline/FileWriter.h>
|
||||
|
||||
/**
|
||||
* receives live sensor data
|
||||
* writes it to a file
|
||||
*/
|
||||
class SensorWriter :
|
||||
public SensorListener<AccelerometerData>,
|
||||
public SensorListener<GyroscopeData>,
|
||||
public SensorListener<BarometerData>,
|
||||
// public SensorListener<ActivityData>,
|
||||
// public SensorListener<StepData>,
|
||||
// public SensorListener<TurnData>,
|
||||
public SensorListener<WiFiMeasurements>,
|
||||
public SensorListener<GPSData>,
|
||||
public SensorListener<CompassData> {
|
||||
|
||||
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<AccelerometerData>* , const Timestamp ts, const AccelerometerData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<GyroscopeData>* , const Timestamp ts, const GyroscopeData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<BarometerData>* , const Timestamp ts, const BarometerData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<WiFiMeasurements>* , const Timestamp ts, const WiFiMeasurements& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<GPSData>* , const Timestamp ts, const GPSData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<CompassData>* , const Timestamp ts, const CompassData& data) override {
|
||||
if (!active) {return;}
|
||||
writer.add(ts, data);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SENSORWRITER_H
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef ACCELEROMETERSENSORANDROID_H
|
||||
#define ACCELEROMETERSENSORANDROID_H
|
||||
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <sstream>
|
||||
|
||||
63
sensors/android/CompassSensorAndroid.h
Normal file
63
sensors/android/CompassSensorAndroid.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef COMPASSSENSORANDROID_H
|
||||
#define COMPASSSENSORANDROID_H
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "../CompassSensor.h"
|
||||
|
||||
#include <QtSensors/QCompass>
|
||||
|
||||
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
|
||||
74
sensors/android/GPSSensorAndroid.h
Normal file
74
sensors/android/GPSSensorAndroid.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef GPSSENSORANDROID_H
|
||||
#define GPSSENSORANDROID_H
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "../GPSSensor.h"
|
||||
|
||||
#include <QtPositioning>
|
||||
|
||||
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
|
||||
@@ -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
|
||||
|
||||
43
sensors/dummy/CompassSensorDummy.h
Normal file
43
sensors/dummy/CompassSensorDummy.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef COMPASSSENSORDUMMY_H
|
||||
#define COMPASSSENSORDUMMY_H
|
||||
|
||||
#include "../CompassSensor.h"
|
||||
#include "RandomSensor.h"
|
||||
#include <random>
|
||||
|
||||
class CompassSensorDummy : public RandomSensor<CompassData, CompassSensor> {
|
||||
|
||||
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<float> distNoise = std::uniform_real_distribution<float>(-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
|
||||
46
sensors/dummy/GPSSensorDummy.h
Normal file
46
sensors/dummy/GPSSensorDummy.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef GPSSENSORDUMMY_H
|
||||
#define GPSSENSORDUMMY_H
|
||||
|
||||
|
||||
#include "../GPSSensor.h"
|
||||
#include "RandomSensor.h"
|
||||
#include <random>
|
||||
|
||||
class GPSSensorDummy : public RandomSensor<GPSData, GPSSensor> {
|
||||
|
||||
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<float> distNoise = std::uniform_real_distribution<float>(-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
|
||||
@@ -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
|
||||
|
||||
@@ -7,11 +7,16 @@
|
||||
#include "../AccelerometerSensor.h"
|
||||
#include "../GyroscopeSensor.h"
|
||||
#include "../BarometerSensor.h"
|
||||
#include "../CompassSensor.h"
|
||||
#include "../GPSSensor.h"
|
||||
|
||||
#include <Indoor/sensors/offline/OfflineAndroid.h>
|
||||
#include <Indoor/sensors/offline/Listener.h>
|
||||
|
||||
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;
|
||||
|
||||
@@ -38,6 +38,14 @@ public:
|
||||
return allInOne;
|
||||
}
|
||||
|
||||
CompassSensor& getCompass() override {
|
||||
return allInOne;
|
||||
}
|
||||
|
||||
GPSSensor& getGPS() override {
|
||||
return allInOne;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // SENSORFACTORYOFFLINE_H
|
||||
|
||||
37
ui/debug/PlotGPS.cpp
Normal file
37
ui/debug/PlotGPS.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "PlotGPS.h"
|
||||
#include <QPainter>
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
32
ui/debug/PlotGPS.h
Normal file
32
ui/debug/PlotGPS.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef PLOTGPS_H
|
||||
#define PLOTGPS_H
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
#include "../sensors/GPSSensor.h"
|
||||
|
||||
#include <Indoor/data/Timestamp.h>
|
||||
|
||||
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
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include "../sensors/TurnSensor.h"
|
||||
#include "../sensors/CompassSensor.h"
|
||||
|
||||
#include <Indoor/data/Timestamp.h>
|
||||
|
||||
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:
|
||||
|
||||
|
||||
@@ -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<TurnData>* sensor, const Timestamp ts
|
||||
((PlotTurns*)plotTurn)->add(ts, data);
|
||||
}
|
||||
|
||||
void SensorDataWidget::onSensorData(Sensor<CompassData>* sensor, const Timestamp ts, const CompassData& data) {
|
||||
(void) sensor;
|
||||
((PlotTurns*)plotTurn)->add(ts, data);
|
||||
}
|
||||
|
||||
void SensorDataWidget::onSensorData(Sensor<GPSData>* sensor, const Timestamp ts, const GPSData& data) {
|
||||
(void) sensor;
|
||||
((PlotGPS*)plotGPS)->add(ts, data);
|
||||
}
|
||||
|
||||
void SensorDataWidget::onSensorData(Sensor<WiFiMeasurements>* sensor, const Timestamp ts, const WiFiMeasurements& data) {
|
||||
(void) sensor;
|
||||
((PlotWiFiScan*)plotWiFi)->add(ts, data);
|
||||
|
||||
@@ -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<ActivityData>,
|
||||
public SensorListener<StepData>,
|
||||
public SensorListener<TurnData>,
|
||||
public SensorListener<WiFiMeasurements> {
|
||||
public SensorListener<WiFiMeasurements>,
|
||||
public SensorListener<GPSData>,
|
||||
public SensorListener<CompassData> {
|
||||
|
||||
|
||||
Q_OBJECT
|
||||
@@ -43,18 +47,21 @@ public:
|
||||
void onSensorData(Sensor<TurnData>* sensor, const Timestamp ts, const TurnData& data) override;
|
||||
void onSensorData(Sensor<WiFiMeasurements>* sensor, const Timestamp ts, const WiFiMeasurements& data) override;
|
||||
void onSensorData(Sensor<ActivityData>* sensor, const Timestamp ts, const ActivityData& data) override;
|
||||
void onSensorData(Sensor<GPSData>* sensor, const Timestamp ts, const GPSData& data) override;
|
||||
void onSensorData(Sensor<CompassData>* 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
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define PLOTTI_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "../misc/fixc11.h"
|
||||
#include "Plot.h"
|
||||
|
||||
/** widget to render one plot */
|
||||
|
||||
14
yasmin.pro
14
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 \
|
||||
|
||||
Reference in New Issue
Block a user