app geht. optimierung spinnt noch weng

This commit is contained in:
toni
2018-07-17 14:59:39 +02:00
parent e6ede27212
commit 2bb3fb8f82
8 changed files with 90 additions and 47 deletions

View File

@@ -190,13 +190,14 @@ void buildGridOnce(Grid<MyGridNode>* grid, Floorplan::IndoorMap* map, const std:
}
void buildWiFiModelOnce(WiFiModel* wifiModel, Floorplan::IndoorMap* map, const std::string& fpFile, const std::string& wifiModelFile){
WiFiModel* buildWiFiModelOnce(Floorplan::IndoorMap* map, const std::string& fpFile, const std::string& wifiModelFile){
// ask questions
const QMessageBox::StandardButton replyWiFiFP = QMessageBox::question(nullptr, "WiFi", "Use Fingerprints for WiFiCalibration?\n\nYes: Use fingerprints and num-optimize AP-Params\nNo: Use APs from the map.xml (pos+params)", QMessageBox::Yes|QMessageBox::No);
WiFiModel* wifiModel = new WiFiModelLogDistCeiling(map);
// WiFi setup
wifiModel = new WiFiModelLogDistCeiling(map);
if (replyWiFiFP == QMessageBox::Yes) {
std::ifstream inp(wifiModelFile, std::ifstream::binary);
@@ -225,6 +226,8 @@ void buildWiFiModelOnce(WiFiModel* wifiModel, Floorplan::IndoorMap* map, const s
// load WiFiModel from file. The factory will create the correct instance
//WiFiModel->loadXML(setup.wifiModel);
WiFiModelFactory fac(map);
if(wifiModel){delete wifiModel;}
wifiModel = fac.loadXML(wifiModelFile);
}
@@ -236,6 +239,7 @@ void buildWiFiModelOnce(WiFiModel* wifiModel, Floorplan::IndoorMap* map, const s
Assert::isFalse(wifiModel->getAllAPs().empty(), "no AccessPoints stored within the map.xml");
}
return wifiModel;
}
@@ -327,11 +331,12 @@ void Controller::loadNavMesh(QDir dir) {
const std::string sWiFiFP = fWiFiFP.fileName().toStdString();
const std::string sWiFiModel = fWiFiModel.fileName().toStdString();
buildWiFiModelOnce(wifiModel, im, sWiFiFP, sWiFiModel);
wifiModel = buildWiFiModelOnce(im, sWiFiFP, sWiFiModel);
// create navmesh
if (navMesh) {delete navMesh; navMesh = nullptr;}
NM::NavMeshSettings settings;
navMesh = new NM::NavMesh<NM::NavMeshTriangle>();
NM::NavMeshFactory<NM::NavMeshTriangle> fac(navMesh, settings);
fac.build(im);
@@ -344,8 +349,8 @@ void Controller::loadNavMesh(QDir dir) {
getMapView3D()->setMap(im);
getMapView2D()->setMap(wifiCalib, im);
getMapView3D()->showGridImportance(grid);
getMapView2D()->showGridImportance(grid);
//getMapView3D()->showGridImportance(grid);
//getMapView2D()->showGridImportance(grid);
getMapView3D()->setVisible(false);

View File

@@ -10,7 +10,7 @@
namespace Settings {
const int numParticles = 5000;
const int numParticles = 2500;
namespace IMU {
const float turnSigma = 1.5; // 3.5
@@ -39,11 +39,11 @@ namespace Settings {
namespace WiFiModel {
constexpr float sigma = 13.0; //TODO: im Museum hatten wir 8.0
constexpr float sigma = 8.0; //TODO: im Museum hatten wir 8.0
/** if the wifi-signal-strengths are stored on the grid-nodes, this needs a grid rebuild! */
constexpr float TXP = -48;
constexpr float EXP = 2.5;
constexpr float TXP = -45;
constexpr float EXP = 2.3;
constexpr float WAF = -5.0;
// how to perform VAP grouping. see
@@ -88,7 +88,10 @@ namespace Settings {
std::string tried;
QDir dStorage("/storage");
QStringList lst = dStorage.entryList();
lst.append("/sdcard/YASMIN/");
lst.append("sdcard/YASMIN/");
lst.append("emulated/0");
//TODO: THIS IS A MESS, PURE CHAOS xD
// try each potential folder
for (const QString subfolder : lst) {

View File

@@ -193,7 +193,7 @@ namespace MeshBased {
const double pStair = getStairProb(p, observation.activity);
const double pGPS = 1;
const double prob = pWifi * pStair * pGPS;
const double prob = pWifi; // * pStair * pGPS;
p.weight *= prob;
if (p.weight != p.weight) {throw Exception("nan");}

View File

@@ -42,9 +42,9 @@ MeshBased::NavControllerMesh::NavControllerMesh(Controller* mainController, Floo
//std::unique_ptr<SMC::ParticleFilterEstimationOrderedWeightedAverage<MyState>> estimation(new SMC::ParticleFilterEstimationOrderedWeightedAverage<MyState>(0.5));
// resampling
//std::unique_ptr<SMC::ParticleFilterResamplingSimple<MyState>> resample(new SMC::ParticleFilterResamplingSimple<MyState>());
std::unique_ptr<SMC::ParticleFilterResamplingSimple<MyState>> resample(new SMC::ParticleFilterResamplingSimple<MyState>());
//std::unique_ptr<SMC::ParticleFilterResamplingPercent<MyState>> resample(new SMC::ParticleFilterResamplingPercent<MyState>(0.05));
std::unique_ptr<SMC::ParticleFilterResamplingSimpleImpoverishment<MeshBased::MyState, NM::NavMeshTriangle>> resample(new SMC::ParticleFilterResamplingSimpleImpoverishment<MeshBased::MyState, NM::NavMeshTriangle>());
//std::unique_ptr<SMC::ParticleFilterResamplingSimpleImpoverishment<MeshBased::MyState, NM::NavMeshTriangle>> resample(new SMC::ParticleFilterResamplingSimpleImpoverishment<MeshBased::MyState, NM::NavMeshTriangle>());
// eval and transition
std::unique_ptr<SMC::ParticleFilterEvaluation<MyState, MyObservation>> eval(new MeshBased::PFEval(wifiModel));
@@ -218,16 +218,17 @@ void MeshBased::NavControllerMesh::gotSensorData(const Timestamp ts) {
// as the difference is slightly above the 500ms, calculate the error and incorporate it into the next one
const Timestamp err = diff - Settings::Filter::updateEvery;
lastTransition = curObs.currentTime - err;
lastTransition = curObs.currentTime;
const Timestamp ts1 = Timestamp::fromUnixTime();
filterUpdate();
const Timestamp ts2 = Timestamp::fromUnixTime();
const Timestamp tsDiff = ts2-ts1;
const QString filterTime = QString::number(tsDiff.ms());
const QString filterTime = QString::number(diff.ms());
avgSum += tsDiff.ms(); ++avgCount;
//Log::add("xxx", "ts:" + std::to_string(curObs.currentTime.ms()) + " avg:" + std::to_string(avgSum/avgCount));
QMetaObject::invokeMethod(mainController->getInfoWidget(), "showFilterTime", Qt::QueuedConnection, Q_ARG(const QString&, filterTime));
return true;
} else {

View File

@@ -11,6 +11,11 @@
#include "../nav/grid/Node.h"
#include "../nav/Observation.h"
#include "../nav/grid/State.h"
#include "../nav/mesh/State.h"
#include <type_traits>
/**
* debug color points
*/
@@ -59,13 +64,13 @@ public:
}
/** NOTE: must be called from Qt's main thread! */
template <typename T> void setFromParticles(const std::vector<SMC::Particle<T>>& particles) {
void setFromParticles(const std::vector<SMC::Particle<GridBased::MyState>>& particles){
points.clear();
// group particles by grid-point
std::unordered_map<GridPoint, float> weights;
for (const SMC::Particle<T>& p : particles) {
for (const SMC::Particle<GridBased::MyState>& p : particles) {
const GridPoint gp = p.state.position;
if (weights.find(gp) != weights.end()) {continue;}
weights[gp] += p.weight;
@@ -92,6 +97,27 @@ public:
}
void setFromParticles(const std::vector<SMC::Particle<MeshBased::MyState>>& particles){
points.clear();
float min = +INFINITY;
float max = -INFINITY;
for (const auto p : particles){
if (p.weight > max) {max = p.weight;}
if (p.weight < min) {min = p.weight;}
}
for (const auto p : particles) {
const Point3 pt(p.state.loc.pos.x, p.state.loc.pos.y, p.state.loc.pos.z);
const float prob = (p.weight-min) / (max-min);
float h = 0.66 - (prob*0.66); // 0.66 is blue on the HSV-scale
const QColor color = QColor::fromHsvF(h, 1, 1);
points.push_back(PT(pt, color));
}
}
protected:
void doRender(QPainter& qp, const Scaler2D& s, const RenderParams2D& r) override {

View File

@@ -115,6 +115,10 @@ void MapView2D::showParticles(const std::vector<SMC::Particle<GridBased::MyState
this->colorPoints->setFromParticles(*particles);
}
void MapView2D::showParticles(const std::vector<SMC::Particle<MeshBased::MyState>>* particles) {
this->colorPoints->setFromParticles(*particles);
}
void MapView2D::setCurrentEstimation(const Point3 pos_m, const Point3 dir) {
(void) dir;
setRenderHeight(pos_m.z);

View File

@@ -13,6 +13,7 @@
#include <Indoor/geo/Point3.h>
#include "nav/grid/State.h"
#include "nav/mesh/State.h"
namespace Floorplan {
class IndoorMap;
@@ -101,13 +102,16 @@ public:
/** NOTE: must be called from Qt's main thread! */
Q_INVOKABLE void showParticles(const void* particles) {
showParticles((const std::vector<SMC::Particle<GridBased::MyState>>*) particles);
showParticles((const std::vector<SMC::Particle<MeshBased::MyState>>*) particles);
}
/** NOTE: must be called from Qt's main thread! */
void showParticles(const std::vector<SMC::Particle<GridBased::MyState>>* particles);
/** NOTE: must be called from Qt's main thread! */
void showParticles(const std::vector<SMC::Particle<MeshBased::MyState>>* particles);
/** set the currently estimated position */
void setCurrentEstimation(const Point3 pos, const Point3 dir);

View File

@@ -22,7 +22,7 @@ ANDROID {
#QMAKE_CXXFLAGS += -mtune=cortex-a57
#QMAKE_CFLAGS += -mtune=cortex-a57
#QMAKE_CXXFLAGS += -O3
#QMAKE_CXXFLAGS += -O2
#QMAKE_CFLAGS += -O3
#QMAKE_CXXFLAGS_DEBUG -= -O2