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

135
Controller.cpp Normal file
View File

@@ -0,0 +1,135 @@
#include "Controller.h"
#include "ui/map/MapView.h"
#include "ui/menu/MainMenu.h"
#include "ui/MainWindow.h"
#include "ui/dialog/LoadSetupDialog.h"
#include "ui/debug/SensorDataWidget.h"
#include <Indoor/grid/factory/v2/GridFactory.h>
#include <Indoor/grid/factory/v2/Importance.h>
#include <Indoor/floorplan/v2/Floorplan.h>
#include <Indoor/floorplan/v2/FloorplanReader.h>
#include <Indoor/Assertions.h>
#include "sensors/dummy/SensorFactoryDummy.h"
#include "sensors/android/SensorFactoryAndroid.h"
#include "sensors/offline/SensorFactoryOffline.h"
#include "nav/NavController.h"
Controller::Controller() {
// OpenGL setup
// MUST happen before anything gets visible (= gets initialized)
QSurfaceFormat format;
format.setDepthBufferSize(16);
QSurfaceFormat::setDefaultFormat(format);
// configure the to-be-used sensor factory
//SensorFactory::set(new SensorFactoryDummy());
//SensorFactory::set(new SensorFactoryOffline("/apps/android/workspace/YASMIN_DATA/offline/gyroacctestingfrank/nexus6/kleinerKreis_216steps_6runden_telefongerade.csv"));
//SensorFactory::set(new SensorFactoryOffline("/apps/android/workspace/YASMIN_DATA/offline/gyroacctestingfrank/s3mini/kleinerKreis_225steps_6runden_telefongerade.csv"));
//SensorFactory::set(new SensorFactoryOffline("/apps/android/workspace/YASMIN_DATA/offline/gyroacctestingfrank/s4/kleinerKreis_220steps_6runden_telefongeneigt.csv"));
SensorFactory::set(new SensorFactoryOffline("/apps/android/workspace/YASMIN_DATA/offline/bergwerk/path4/nexus/vor/1454776525797.csv"));
mainWindow = new MainWindow();
Assert::isTrue(connect(mainWindow->getMainMenu(), &MainMenu::onLoadButton, this, &Controller::onLoadButton), "connect() failed");
Assert::isTrue(connect(mainWindow->getMainMenu(), &MainMenu::onDebugButton, this, &Controller::onDebugButton), "connect() failed");
Assert::isTrue(connect(mainWindow->getMainMenu(), &MainMenu::onStartButton, this, &Controller::onStartButton), "connect() failed");
Assert::isTrue(connect(mainWindow->getMainMenu(), &MainMenu::onTransparentButton, this, &Controller::onTransparentButton), "connect() failed");
Assert::isTrue(connect(mainWindow->getMainMenu(), &MainMenu::onCameraButton, this, &Controller::onCameraButton), "connect() failed");
// order is important! otherwise OpenGL fails!
mainWindow->show();
// start all sensors
SensorFactory::get().getAccelerometer().start();
SensorFactory::get().getGyroscope().start();
SensorFactory::get().getBarometer().start();
SensorFactory::get().getWiFi().start();
}
MapView* Controller::getMapView() const {
return mainWindow->getMapView();
}
void buildGridOnce(Grid<MyGridNode>* grid, Floorplan::IndoorMap* map, const std::string& saveFile) {
GridFactory<MyGridNode> gf(*grid);
gf.build(map);
Importance::addImportance(*grid);
std::ofstream out(saveFile, std::ofstream::binary);
grid->write(out);
out.close();
}
void Controller::onLoadButton() {
// pick a map to load
QDir dir = LoadSetupDialog::pickSetupFolder();
// cancelled?
if (dir.path() == ".") { return; }
QFile fMap(dir.path() + "/map.xml");
QFile fGrid(dir.path() + "/grid.dat");
Assert::isTrue(fMap.exists(), "map.xml missing");
//Assert::isTrue(fGrid.exists(), "grid.dat missing");
fMap.open(QIODevice::ReadOnly);
QString str = QString(fMap.readAll());
im = Floorplan::Reader::readFromString(str.toStdString());
const std::string sGrid = fGrid.fileName().toStdString();
std::ifstream inp(sGrid, std::ifstream::binary);
//Assert::isTrue(inp.good(), "failed to open grid.dat");
// create a new, empty grid
if (grid) {delete grid; grid = nullptr;}
grid = new Grid<MyGridNode>(20);
// grid.dat empty? -> build one and save it
if (!inp.good() || (inp.peek()&&0) || inp.eof()) {
buildGridOnce(grid, im, sGrid);
} else {
grid->read(inp);
}
// create a new navigator
if (nav) {delete nav; nav = nullptr;}
nav = new NavController(this, grid, im);
getMapView()->setMap(im);
getMapView()->showGridImportance(grid);
}
void Controller::onDebugButton() {
mainWindow->getSensorDataWidget()->setVisible( !mainWindow->getSensorDataWidget()->isVisible() );
}
void Controller::onStartButton() {
nav->start();
}
void Controller::onTransparentButton() {
mainWindow->getMapView()->toggleRenderMode();
}
void Controller::onCameraButton() {
nav->toggleCamera();
}