diff --git a/Controller.cpp b/Controller.cpp index 2541e39..b33a728 100644 --- a/Controller.cpp +++ b/Controller.cpp @@ -51,9 +51,9 @@ Controller::Controller() : sl(scaler) { //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")); -// SensorFactory::set(new SensorFactoryAndroid()); +SensorFactory::set(new SensorFactoryAndroid()); // SensorFactory::get().getAccelerometer().start(); // SensorFactory::get().getGyroscope().start(); // SensorFactory::get().getBarometer().start(); diff --git a/Settings.h b/Settings.h index 2832ba7..c403a35 100644 --- a/Settings.h +++ b/Settings.h @@ -13,7 +13,7 @@ namespace Settings { namespace IMU { const float turnSigma = 1.5; // 3.5 const float stepLength = 0.80; - const float stepSigma = 0.10; + const float stepSigma = 0.20; } const float smartphoneAboveGround = 1.3; @@ -33,7 +33,7 @@ namespace Settings { } namespace WiFiModel { - constexpr float sigma = 11.0; + constexpr float sigma = 13.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; diff --git a/_android/src/MyActivity.java b/_android/src/MyActivity.java index 62c4dda..85e3b79 100644 --- a/_android/src/MyActivity.java +++ b/_android/src/MyActivity.java @@ -1,6 +1,7 @@ package indoor.java; import android.os.Bundle; +import android.view.WindowManager; import org.qtproject.qt5.android.bindings.QtActivity; public class MyActivity extends QtActivity { @@ -13,9 +14,13 @@ public class MyActivity extends QtActivity { @Override public void onCreate(Bundle savedState) { + MyActivity.act = this; super.onCreate(savedState); + // prevent power-safe? + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + // IPIN2016 stepLogger = new StepLoggerClient(this); diff --git a/_android/src/WiFi.java b/_android/src/WiFi.java index 450d7f3..47b5b37 100644 --- a/_android/src/WiFi.java +++ b/_android/src/WiFi.java @@ -50,7 +50,7 @@ public class WiFi { // start the first scan triggerOneScan(); - return 0; + return 1337; } diff --git a/nav/Filter.h b/nav/Filter.h index 47384c1..49df991 100644 --- a/nav/Filter.h +++ b/nav/Filter.h @@ -215,11 +215,14 @@ public: const MyObservation observation = _observation; // vap-grouping + const int numAP1 = observation.wifi.entries.size(); const WiFiMeasurements wifiObs = vg.group(_observation.wifi); + const int numAP2 = wifiObs.entries.size(); + + Log::add("Filter", "VAP: " + std::to_string(numAP1) + " -> " + std::to_string(numAP2)); for (K::Particle& p : particles) { - // WiFi free //const double pWiFi = wiFiProbability.getProbability(p.state.position.inMeter()+person, observation.currentTime, vg.group(observation.wifi)); @@ -227,9 +230,12 @@ public: const MyGridNode& node = grid->getNodeFor(p.state.position); const double pWiFi = wiFiProbability.getProbability(node, observation.currentTime, wifiObs); + //Log::add("xxx", std::to_string(observation.currentTime.ms()) + "_" + std::to_string(wifiObs.entries[0].ts.ms())); + const double pStair = getStairProb(p, observation.activity); const double pGPS = 1; const double prob = pWiFi * pGPS * pStair; + p.weight *= prob; // NOTE: keeps the weight returned by the transition step! //p.weight = prob; // does NOT keep the weights returned by the transition step sum += p.weight; diff --git a/sensors/android/WiFiSensorAndroid.h b/sensors/android/WiFiSensorAndroid.h index 1160e85..40c37b8 100644 --- a/sensors/android/WiFiSensorAndroid.h +++ b/sensors/android/WiFiSensorAndroid.h @@ -28,9 +28,12 @@ public: void start() override { + // do NOT start twice! + if (started) {return;} + // start scanning int res = QAndroidJniObject::callStaticMethod("indoor/java/WiFi", "start", "()I"); - if (res != 0) {throw Exception("error while starting WiFi");} + if (res != 1337) {throw Exception("error while starting WiFi");} started = true; } @@ -49,6 +52,9 @@ public: // to-be-constructed sensor data WiFiMeasurements sensorData; + // tag all scan-entries with the current app runtime + const Timestamp curTS = Timestamp::fromRunningTime(); + // parse each mac->rssi entry for (int i = 0; i < (int)data.length(); i += 17+1+2) { const std::string bssid = data.substr(i, 17); @@ -56,7 +62,7 @@ public: const int8_t pad1 = data[i+18]; const int8_t pad2 = data[i+19]; if (pad1 != 0 || pad2 != 0) {Debug::error("padding error within WiFi scan result");} - sensorData.entries.push_back(WiFiMeasurement(AccessPoint(bssid), rssi)); + sensorData.entries.push_back(WiFiMeasurement(AccessPoint(bssid), rssi, curTS)); } // call listeners diff --git a/tools/calibration/WiFiCalibrationScanDialog.h b/tools/calibration/WiFiCalibrationScanDialog.h index 2999e11..840a708 100644 --- a/tools/calibration/WiFiCalibrationScanDialog.h +++ b/tools/calibration/WiFiCalibrationScanDialog.h @@ -28,7 +28,7 @@ private: QProgressBar* barProg; struct Scan { - const int numRecords = 10; + const int numRecords = 30; int recordsDone = 0; } scan; diff --git a/ui/LoggerUI.h b/ui/LoggerUI.h index b91beb2..319fa09 100644 --- a/ui/LoggerUI.h +++ b/ui/LoggerUI.h @@ -11,7 +11,7 @@ class LoggerUI : public Logger { private: InfoWidget* iw; - + const int numLines = 5; std::vector lines; public: @@ -24,7 +24,7 @@ public: void add(const std::string& str, const bool nl) override { lines.back() += QString(str.c_str()); if (nl) {lines.push_back("");} - while(lines.size() > 4) {lines.erase(lines.begin());} + while(lines.size() > numLines) {lines.erase(lines.begin());} QString qs = getStr(); QMetaObject::invokeMethod(iw, "showLog", Qt::QueuedConnection, Q_ARG(const QString&, qs)); QApplication::processEvents(); diff --git a/ui/map/2D/MapView2D.cpp b/ui/map/2D/MapView2D.cpp index e0bc644..d183f10 100644 --- a/ui/map/2D/MapView2D.cpp +++ b/ui/map/2D/MapView2D.cpp @@ -158,10 +158,12 @@ void MapView2D::mouseReleaseEvent(QMouseEvent* evt) { const Point2 p1(evt->x(), evt->y()); + // fingerprint node pressed? + const int fpSize = UIHelper::isLarge(this->parent()) ? (40) : (25); int idx = 0; for (const Point2 p2 : wifiCalib->getNodes()) { const float dist = p1.getDistance(p2); - if (dist < 25) { wifiCalib->selectNode(idx); emit update(); break; } + if (dist < fpSize) { wifiCalib->selectNode(idx); emit update(); break; } ++idx; }