started to add ble functions
added ble as sensor to java and c++ added sensorlistener for ble added ble to observation and onDataSensor in filter started to work on ble fingerprints for optimization
This commit is contained in:
@@ -80,6 +80,7 @@ Controller::Controller() {
|
||||
SensorFactory::get().getWiFi().start();
|
||||
SensorFactory::get().getGPS().start();
|
||||
SensorFactory::get().getCompass().start();
|
||||
SensorFactory::get().getBLE().start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Settings {
|
||||
|
||||
namespace WiFiModel {
|
||||
|
||||
constexpr float sigma = 8.0; //TODO: im Museum hatten wir 8.0
|
||||
constexpr float sigma = 10.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 = -45;
|
||||
|
||||
111
_android/src/BLE.java
Normal file
111
_android/src/BLE.java
Normal file
@@ -0,0 +1,111 @@
|
||||
package indoor.java;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.le.BluetoothLeScanner;
|
||||
import android.bluetooth.le.ScanCallback;
|
||||
import android.bluetooth.le.ScanFilter;
|
||||
import android.bluetooth.le.ScanSettings;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
public class BLE {
|
||||
|
||||
private static Activity act;
|
||||
private static BluetoothAdapter bt = null;
|
||||
private static BluetoothLeScanner scanner = null;
|
||||
private static ScanCallback mLeScanCallback;
|
||||
private static ScanSettings mLeSettings;
|
||||
private static final List<ScanFilter> mLeFilter = new ArrayList<>();
|
||||
|
||||
/** called when a scan is completed successfully */
|
||||
public static native void onScanComplete(final byte[] result);
|
||||
|
||||
/**
|
||||
* start bluetooth scanning in the background.
|
||||
* will call onScanComplete() once a scan is available
|
||||
*/
|
||||
public static int start() {
|
||||
|
||||
Log.d("ble", "start()");
|
||||
|
||||
MyActivity act = MyActivity.act;
|
||||
|
||||
// sanity check
|
||||
if (!act.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
|
||||
Toast.makeText(act, "Bluetooth-LE not supported!", Toast.LENGTH_SHORT).show();
|
||||
return 1338;
|
||||
}
|
||||
|
||||
Log.d("ble", "Sanity Checks");
|
||||
|
||||
// Initializes a Bluetooth adapter. For API level 18 and above, get a reference to
|
||||
// BluetoothAdapter through BluetoothManager.
|
||||
final BluetoothManager mgr = (BluetoothManager) act.getSystemService(Context.BLUETOOTH_SERVICE);
|
||||
bt = mgr.getAdapter();
|
||||
|
||||
Log.d("ble", "BLE Mangaer Start");
|
||||
|
||||
// create the scanner
|
||||
scanner = bt.getBluetoothLeScanner();
|
||||
|
||||
// set the ble settings
|
||||
mLeSettings = new ScanSettings.Builder()
|
||||
.setReportDelay(0)
|
||||
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
|
||||
.setNumOfMatches(ScanSettings.MATCH_NUM_MAX_ADVERTISEMENT)
|
||||
.build();
|
||||
|
||||
//mLeFilter.add(new ScanFilter.Builder().setServiceUuid(new ParcelUuid(UUID.fromString("fda50693-a4e2-4fb1-afcf-c6eb07647825"))).build());
|
||||
|
||||
// and attach the callback
|
||||
mLeScanCallback = new ScanCallback() {
|
||||
@Override public void onScanResult(int callbackType, android.bluetooth.le.ScanResult result) {
|
||||
//Log.d("ble", result.getDevice() + " " + result.getRssi());
|
||||
|
||||
final byte[] rst = serialize(result);
|
||||
BLE.onScanComplete(rst);
|
||||
}
|
||||
|
||||
// @Override public void onBatchScanResults(List<android.bluetooth.le.ScanResult> results){
|
||||
|
||||
// for(android.bluetooth.le.ScanResult result : results){
|
||||
// Log.d("ble2", result.getDevice() + " " + result.getRssi());
|
||||
|
||||
// final byte[] rst = serialize(result);
|
||||
// BLE.onScanComplete(rst);
|
||||
// }
|
||||
// }
|
||||
};
|
||||
|
||||
if(bt == null){
|
||||
Toast.makeText(act, "Bluetooth-LE not supported!", Toast.LENGTH_SHORT).show();
|
||||
return 1338;
|
||||
}
|
||||
scanner.startScan(mLeFilter, mLeSettings, mLeScanCallback);
|
||||
|
||||
return 1337;
|
||||
}
|
||||
|
||||
/** convert the given scan-result to a binary byte[] representation */
|
||||
private static byte[] serialize(final android.bluetooth.le.ScanResult res) {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
baos.write(res.getDevice().getAddress().getBytes());
|
||||
baos.write((byte)res.getRssi());
|
||||
baos.write((byte)0);
|
||||
baos.write((byte)0);
|
||||
} catch (final Exception e) {;}
|
||||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +43,7 @@ class Controller;
|
||||
|
||||
class NavController :
|
||||
public SensorListener<AccelerometerData>,
|
||||
public SensorListener<BeaconMeasurement>,
|
||||
public SensorListener<GyroscopeData>,
|
||||
public SensorListener<BarometerData>,
|
||||
public SensorListener<WiFiMeasurements>,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define STATE_H
|
||||
|
||||
#include <Indoor/sensors/radio/WiFiMeasurements.h>
|
||||
#include <Indoor/sensors/beacon/BeaconMeasurements.h>
|
||||
#include <Indoor/sensors/gps/GPSData.h>
|
||||
#include <Indoor/sensors/activity/Activity.h>
|
||||
|
||||
@@ -11,6 +12,9 @@ struct MyObservation {
|
||||
/** wifi measurements */
|
||||
WiFiMeasurements wifi;
|
||||
|
||||
/** ble measurements */
|
||||
BeaconMeasurements ble;
|
||||
|
||||
/** gps measurements */
|
||||
GPSData gps;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "NodeResampling.h"
|
||||
#include "../Settings.h"
|
||||
|
||||
#include <../misc/fixc11.h>
|
||||
#include <omp.h>
|
||||
#include <future>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../ui/map/2D/MapView2D.h"
|
||||
#include "../ui/debug/InfoWidget.h"
|
||||
|
||||
#include "../Controller.h"
|
||||
#include "../../Controller.h"
|
||||
|
||||
Q_DECLARE_METATYPE(const void*)
|
||||
|
||||
@@ -57,6 +57,7 @@ GridBased::NavControllerGrid::NavControllerGrid(Controller* mainController, Floo
|
||||
SensorFactory::get().getSteps().addListener(this);
|
||||
SensorFactory::get().getTurns().addListener(this);
|
||||
SensorFactory::get().getActivity().addListener(this);
|
||||
SensorFactory::get().getBLE().addListener(this);
|
||||
|
||||
}
|
||||
|
||||
@@ -73,6 +74,7 @@ void GridBased::NavControllerGrid::start() {
|
||||
SensorFactory::get().getGyroscope().start();
|
||||
SensorFactory::get().getBarometer().start();
|
||||
SensorFactory::get().getWiFi().start();
|
||||
SensorFactory::get().getBLE().start();
|
||||
|
||||
#ifndef ANDROID
|
||||
// #include <valgrind/callgrind.h>
|
||||
@@ -127,6 +129,13 @@ void GridBased::NavControllerGrid::onSensorData(Sensor<GPSData>* sensor, const T
|
||||
gotSensorData(ts);
|
||||
}
|
||||
|
||||
void GridBased::NavControllerGrid::onSensorData(Sensor<BeaconMeasurement>* sensor, const Timestamp ts, const BeaconMeasurement& data) {
|
||||
(void) sensor;
|
||||
(void) ts;
|
||||
//Log::add("Beacon", "MAC: " + data.getBeacon().getMAC().asString() + "RSSI: " + std::to_string(data.getRSSI()));
|
||||
gotSensorData(ts);
|
||||
}
|
||||
|
||||
void GridBased::NavControllerGrid::onSensorData(Sensor<StepData>* sensor, const Timestamp ts, const StepData& data) {
|
||||
(void) sensor;
|
||||
(void) ts;
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace GridBased {
|
||||
|
||||
void onSensorData(Sensor<WiFiMeasurements>* sensor, const Timestamp ts, const WiFiMeasurements& data) override;
|
||||
|
||||
void onSensorData(Sensor<BeaconMeasurement>* sensor, const Timestamp ts, const BeaconMeasurement& data) override;
|
||||
|
||||
void onSensorData(Sensor<GPSData>* sensor, const Timestamp ts, const GPSData& data) override;
|
||||
|
||||
void onSensorData(Sensor<StepData>* sensor, const Timestamp ts, const StepData& data) override ;
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace MeshBased {
|
||||
NM::NavMeshRandom<NM::NavMeshTriangle> rnd = mesh->getRandom();
|
||||
|
||||
for (SMC::Particle<MyState>& p : particles) {
|
||||
p.state.loc = rnd.draw();
|
||||
p.state.pos = rnd.draw();
|
||||
p.state.heading = Heading(distHead(gen)); // random heading
|
||||
p.weight = 1.0 / particles.size(); // equal weight
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace MeshBased {
|
||||
NM::NavMeshWalkParams<NM::NavMeshTriangle> params;
|
||||
params.heading = p.state.heading + ctrl.turnSinceLastTransition_rad + dHeading.draw();
|
||||
params.numSteps = ctrl.numStepsSinceLastTransition;
|
||||
params.start = p.state.loc;
|
||||
params.start = p.state.pos;
|
||||
|
||||
params.stepSizes.stepSizeFloor_m = dStepSizeFloor.draw();
|
||||
params.stepSizes.stepSizeStair_m = dStepSizeStair.draw();
|
||||
@@ -129,7 +129,7 @@ namespace MeshBased {
|
||||
|
||||
// assign back to particle's state
|
||||
p.weight *= res.probability;
|
||||
p.state.loc = res.location;
|
||||
p.state.pos = res.location;
|
||||
p.state.heading = res.heading;
|
||||
}
|
||||
|
||||
@@ -150,16 +150,16 @@ namespace MeshBased {
|
||||
switch (act) {
|
||||
|
||||
case Activity::WALKING:
|
||||
if (p.state.loc.tria->getType() == (int) NM::NavMeshType::FLOOR_INDOOR) {return kappa;}
|
||||
if (p.state.loc.tria->getType() == (int) NM::NavMeshType::DOOR) {return kappa;}
|
||||
if (p.state.loc.tria->getType() == (int) NM::NavMeshType::STAIR_LEVELED) {return kappa;}
|
||||
if (p.state.pos.tria->getType() == (int) NM::NavMeshType::FLOOR_INDOOR) {return kappa;}
|
||||
if (p.state.pos.tria->getType() == (int) NM::NavMeshType::DOOR) {return kappa;}
|
||||
if (p.state.pos.tria->getType() == (int) NM::NavMeshType::STAIR_LEVELED) {return kappa;}
|
||||
{return 1-kappa;}
|
||||
|
||||
case Activity::WALKING_UP:
|
||||
case Activity::WALKING_DOWN:
|
||||
if (p.state.loc.tria->getType() == (int) NM::NavMeshType::STAIR_SKEWED) {return kappa;}
|
||||
if (p.state.loc.tria->getType() == (int) NM::NavMeshType::STAIR_LEVELED) {return kappa;}
|
||||
if (p.state.loc.tria->getType() == (int) NM::NavMeshType::ELEVATOR) {return kappa;}
|
||||
if (p.state.pos.tria->getType() == (int) NM::NavMeshType::STAIR_SKEWED) {return kappa;}
|
||||
if (p.state.pos.tria->getType() == (int) NM::NavMeshType::STAIR_LEVELED) {return kappa;}
|
||||
if (p.state.pos.tria->getType() == (int) NM::NavMeshType::ELEVATOR) {return kappa;}
|
||||
{return 1-kappa;}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace MeshBased {
|
||||
for (size_t i = 0; i < particles.size(); ++i) {
|
||||
SMC::Particle<MyState>& p = particles[i];
|
||||
|
||||
const double pWifi = wifiProbability.getProbability(p.state.loc.pos, observation.currentTime, wifiObs);
|
||||
const double pWifi = wifiProbability.getProbability(p.state.pos.pos, observation.currentTime, wifiObs);
|
||||
const double pStair = getStairProb(p, observation.activity);
|
||||
const double pGPS = 1;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include <Indoor/smc/filtering/resampling/ParticleFilterResamplingPercent.h>
|
||||
#include <Indoor/smc/filtering/resampling/ParticleFilterResamplingKDE.h>
|
||||
//#include <Indoor/smc/filtering/resampling/ParticleFilterResamplingKDE.h>
|
||||
|
||||
//#ifndef ANDROID
|
||||
//#include <valgrind/callgrind.h>
|
||||
@@ -47,11 +47,11 @@ MeshBased::NavControllerMesh::NavControllerMesh(Controller* mainController, Floo
|
||||
|
||||
|
||||
// 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::ParticleFilterResamplingKDE<MyState, NM::NavMeshTriangle>> resample(new SMC::ParticleFilterResamplingKDE<MyState, NM::NavMeshTriangle>(navMesh, 0.2, Point2(1,1)));
|
||||
//std::unique_ptr<SMC::ParticleFilterResamplingKLD<MyState>> resample(new SMC::ParticleFilterResamplingKLD<MyState>());
|
||||
//std::unique_ptr<SMC::ParticleFilterResamplingPercent<MyState>> resample(new SMC::ParticleFilterResamplingPercent<MyState>(0.95));
|
||||
//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));
|
||||
@@ -76,6 +76,7 @@ MeshBased::NavControllerMesh::NavControllerMesh(Controller* mainController, Floo
|
||||
SensorFactory::get().getSteps().addListener(this);
|
||||
SensorFactory::get().getTurns().addListener(this);
|
||||
SensorFactory::get().getActivity().addListener(this);
|
||||
SensorFactory::get().getBLE().addListener(this);
|
||||
|
||||
// hacky.. but we need to call this one from the main thread!
|
||||
//mainController->getMapView()->showParticles(pf->getParticles());
|
||||
@@ -97,6 +98,7 @@ void MeshBased::NavControllerMesh::start() {
|
||||
SensorFactory::get().getGyroscope().start();
|
||||
SensorFactory::get().getBarometer().start();
|
||||
SensorFactory::get().getWiFi().start();
|
||||
SensorFactory::get().getBLE().start();
|
||||
|
||||
//#ifndef ANDROID
|
||||
// // #include <valgrind/callgrind.h>
|
||||
@@ -145,6 +147,13 @@ void MeshBased::NavControllerMesh::onSensorData(Sensor<WiFiMeasurements>* sensor
|
||||
gotSensorData(ts);
|
||||
}
|
||||
|
||||
void MeshBased::NavControllerMesh::onSensorData(Sensor<BeaconMeasurement>* sensor, const Timestamp ts, const BeaconMeasurement& data) {
|
||||
(void) sensor;
|
||||
(void) ts;
|
||||
curObs.ble.add(data);
|
||||
gotSensorData(ts);
|
||||
}
|
||||
|
||||
void MeshBased::NavControllerMesh::onSensorData(Sensor<GPSData>* sensor, const Timestamp ts, const GPSData& data) {
|
||||
(void) sensor;
|
||||
(void) ts;
|
||||
@@ -263,7 +272,7 @@ void MeshBased::NavControllerMesh::debugActivity(const ActivityData& activity)
|
||||
|
||||
//lastEst = curEst;
|
||||
MyState sCurEst = pf->updateEvaluationOnly(curObs);
|
||||
curEst.pos_m = sCurEst.loc.pos;
|
||||
curEst.pos_m = sCurEst.pos.pos;
|
||||
curEst.head = sCurEst.heading;
|
||||
|
||||
// inform listeners about the new estimation
|
||||
@@ -283,7 +292,7 @@ void MeshBased::NavControllerMesh::debugActivity(const ActivityData& activity)
|
||||
|
||||
//lastEst = curEst;
|
||||
MyState sCurEst = pf->update(&curCtrl, curObs);
|
||||
curEst.pos_m = sCurEst.loc.pos;
|
||||
curEst.pos_m = sCurEst.pos.pos;
|
||||
curEst.head = sCurEst.heading;
|
||||
|
||||
// inform listeners about the new estimation
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace MeshBased {
|
||||
|
||||
void onSensorData(Sensor<WiFiMeasurements>* sensor, const Timestamp ts, const WiFiMeasurements& data) override;
|
||||
|
||||
void onSensorData(Sensor<BeaconMeasurement>* sensor, const Timestamp ts, const BeaconMeasurement& data) override;
|
||||
|
||||
void onSensorData(Sensor<GPSData>* sensor, const Timestamp ts, const GPSData& data) override;
|
||||
|
||||
void onSensorData(Sensor<StepData>* sensor, const Timestamp ts, const StepData& data) override;
|
||||
|
||||
@@ -9,56 +9,56 @@ namespace MeshBased {
|
||||
|
||||
struct MyState {
|
||||
|
||||
NM::NavMeshLocation<NM::NavMeshTriangle> loc;
|
||||
NM::NavMeshLocation<NM::NavMeshTriangle> pos;
|
||||
Heading heading;
|
||||
|
||||
/** ctor */
|
||||
MyState() : loc(), heading(0) {
|
||||
MyState() : pos(), heading(0) {
|
||||
;
|
||||
}
|
||||
|
||||
/** ctor */
|
||||
MyState(NM::NavMeshLocation<NM::NavMeshTriangle> loc, Heading h) : loc(loc), heading(h) {
|
||||
MyState(NM::NavMeshLocation<NM::NavMeshTriangle> loc, Heading h) : pos(loc), heading(h) {
|
||||
;
|
||||
}
|
||||
|
||||
MyState& operator += (const MyState& o) {
|
||||
loc.pos += o.loc.pos;
|
||||
pos.pos += o.pos.pos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
MyState& operator /= (const float val) {
|
||||
loc.pos /= val;
|
||||
pos.pos /= val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
MyState operator * (const float val) const {
|
||||
MyState copy = *this;
|
||||
copy.loc.pos = copy.loc.pos * val;
|
||||
copy.pos.pos = copy.pos.pos * val;
|
||||
return copy;
|
||||
}
|
||||
|
||||
float getX(){
|
||||
return loc.pos.x;
|
||||
return pos.pos.x;
|
||||
}
|
||||
|
||||
float getY() {
|
||||
return loc.pos.y;
|
||||
return pos.pos.y;
|
||||
}
|
||||
|
||||
float getZ() {
|
||||
return loc.pos.z;
|
||||
return pos.pos.z;
|
||||
}
|
||||
|
||||
void setPosition(Point3 pos){
|
||||
loc.pos = pos;
|
||||
void setPosition(Point3 other){
|
||||
pos.pos = other;
|
||||
}
|
||||
|
||||
float getBinValue(const int dim) const {
|
||||
switch (dim) {
|
||||
case 0: return this->loc.pos.x;
|
||||
case 1: return this->loc.pos.y;
|
||||
case 2: return this->loc.pos.z;
|
||||
case 0: return this->pos.pos.x;
|
||||
case 1: return this->pos.pos.y;
|
||||
case 2: return this->pos.pos.z;
|
||||
case 3: return this->heading.getRAD();
|
||||
}
|
||||
throw "cant find this value within the bin";
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "linux/WiFiSensorLinux.h"
|
||||
#include "android/WiFiSensorAndroid.h"
|
||||
|
||||
#include "BLESensor.h"
|
||||
#include "android/BLESensorAndroid.h"
|
||||
|
||||
#include "AccelerometerSensor.h"
|
||||
#include "dummy/AccelerometerSensorDummy.h"
|
||||
#include "android/AccelerometerSensorAndroid.h"
|
||||
@@ -77,6 +80,9 @@ public:
|
||||
/** get the gps sensor */
|
||||
virtual GPSSensor& getGPS() = 0;
|
||||
|
||||
/** get the bluetooth low energy sensor */
|
||||
virtual BLESensor& getBLE() = 0;
|
||||
|
||||
|
||||
/** get the Step sensor */
|
||||
StepSensor& getSteps() {
|
||||
|
||||
@@ -49,7 +49,6 @@ public:
|
||||
SensorFactory::get().getWiFi().addListener(this);
|
||||
SensorFactory::get().getCompass().addListener(this);
|
||||
SensorFactory::get().getGPS().addListener(this);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef TURNSENSOR_H
|
||||
#define TURNSENSOR_H
|
||||
|
||||
#include <Indoor/sensors/imu/PoseDetection.h>
|
||||
#include <Indoor/sensors/imu/TurnDetection.h>
|
||||
#include "AccelerometerSensor.h"
|
||||
#include "GyroscopeSensor.h"
|
||||
|
||||
18
sensors/android/BLESensorAndroid.cpp
Normal file
18
sensors/android/BLESensorAndroid.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifdef ANDROID
|
||||
|
||||
#include "BLESensorAndroid.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
/** called after each successful WiFi scan */
|
||||
JNIEXPORT void JNICALL Java_indoor_java_BLE_onScanComplete(JNIEnv* env, jobject jobj, jbyteArray arrayID) {
|
||||
(void) env; (void) jobj;
|
||||
jsize length = env->GetArrayLength(arrayID);
|
||||
jbyte* data = env->GetByteArrayElements(arrayID, 0);
|
||||
std::string str((char*)data, length);
|
||||
env->ReleaseByteArrayElements(arrayID, data, JNI_ABORT);
|
||||
BLESensorAndroid::get().handle(str);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "../SensorFactory.h"
|
||||
|
||||
#include "BLESensorAndroid.h"
|
||||
#include "WiFiSensorAndroid.h"
|
||||
#include "AccelerometerSensorAndroid.h"
|
||||
#include "GyroscopeSensorAndroid.h"
|
||||
@@ -44,6 +45,10 @@ public:
|
||||
return GPSSensorAndroid::get();
|
||||
}
|
||||
|
||||
BLESensor& getBLE() override {
|
||||
return BLESensorAndroid::get();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
4
tools/calibration/BLECalibrationDataModel.h
Normal file
4
tools/calibration/BLECalibrationDataModel.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef BLECALIBRATIONDATAMODEL_H
|
||||
#define BLECALIBRATIONDATAMODEL_H
|
||||
|
||||
#endif // BLECALIBRATIONDATAMODEL_H
|
||||
@@ -16,7 +16,7 @@
|
||||
/**
|
||||
* show a dialog to perform a WiFiScan
|
||||
*/
|
||||
class WiFiCalibrationScanDialog : public QObject, public SensorListener<WiFiMeasurements> {
|
||||
class WiFiCalibrationScanDialog : public QObject, public SensorListener<WiFiMeasurements>, public SensorListener<BeaconMeasurement> {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
@@ -34,6 +34,7 @@ private:
|
||||
|
||||
/** the measurements model to fill with scan-entries */
|
||||
WiFiFingerprint& model;
|
||||
//BeaconFingerprint& blemodel;
|
||||
|
||||
public:
|
||||
|
||||
@@ -95,6 +96,15 @@ private:
|
||||
QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
//tmp stuff
|
||||
virtual void onSensorData(Sensor<BeaconMeasurement>* sensor, const Timestamp ts, const BeaconMeasurement& data) override {
|
||||
(void) sensor;
|
||||
(void) ts;
|
||||
|
||||
|
||||
QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
}
|
||||
|
||||
for (const auto p : particles) {
|
||||
const Point3 pt(p.state.loc.pos.x, p.state.loc.pos.y, p.state.loc.pos.z);
|
||||
const Point3 pt(p.state.pos.pos.x, p.state.pos.pos.y, p.state.pos.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);
|
||||
|
||||
@@ -29,7 +29,7 @@ protected:
|
||||
if (floor->atHeight > r.clip.aboveHeight_m) {return;}
|
||||
|
||||
for (const Floorplan::FloorObstacle* obs : floor->obstacles) {
|
||||
const Floorplan::FloorObstacleLine* line = dynamic_cast<const Floorplan::FloorObstacleLine*>(obs);
|
||||
const Floorplan::FloorObstacleWall* line = dynamic_cast<const Floorplan::FloorObstacleWall*>(obs);
|
||||
if (line) {drawObstacle(qp, s, line);}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,11 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
static inline QPen getPen(Floorplan::Material mat, Floorplan::ObstacleType type) {
|
||||
static inline QPen getPen(Floorplan::Material mat, Floorplan::ObstacleType type, int thickness) {
|
||||
using namespace Floorplan;
|
||||
QPen pen; pen.setColor(Qt::darkGray);
|
||||
if (mat == Material::CONCRETE) {pen.setWidth(3);}
|
||||
if (mat == Material::CONCRETE) {pen.setWidth(thickness);}
|
||||
if (mat == Material::DRYWALL) {pen.setWidth(thickness); pen.setColor(Qt::gray);}
|
||||
if (mat == Material::GLASS) {pen.setStyle(Qt::PenStyle::DotLine);}
|
||||
if (type == ObstacleType::HANDRAIL) {pen.setStyle(Qt::PenStyle::DashLine);}
|
||||
if (type == ObstacleType::UNKNOWN) {pen.setColor(Qt::red); pen.setWidth(5);}
|
||||
@@ -63,10 +64,10 @@ private:
|
||||
return pen;
|
||||
}
|
||||
|
||||
void drawObstacle(QPainter& qp, const Scaler2D& s, const Floorplan::FloorObstacleLine* line) {
|
||||
void drawObstacle(QPainter& qp, const Scaler2D& s, const Floorplan::FloorObstacleWall* line) {
|
||||
const Point2 pt1 = s.mapToScreen(line->from);
|
||||
const Point2 pt2 = s.mapToScreen(line->to);
|
||||
qp.setPen(getPen(line->material, line->type));
|
||||
qp.setPen(getPen(line->material, line->type, static_cast<int>(s.mToPX(line->thickness_m))));
|
||||
qp.drawLine(pt1.x, pt1.y, pt2.x, pt2.y);
|
||||
}
|
||||
|
||||
|
||||
11
yasmin.pro
11
yasmin.pro
@@ -60,7 +60,8 @@ INCLUDEPATH += \
|
||||
OTHER_FILES += \
|
||||
_android/src/WiFi.java \
|
||||
_android/src/MyActivity.java \
|
||||
_android/AndroidManifest.xml
|
||||
_android/AndroidManifest.xml \
|
||||
_android/src/BLE.java
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
@@ -84,7 +85,8 @@ SOURCES += \
|
||||
ui/debug/PlotGPS.cpp \
|
||||
nav/NavController.cpp \
|
||||
nav/mesh/NavControllerMesh.cpp \
|
||||
nav/grid/NavControllerGrid.cpp
|
||||
nav/grid/NavControllerGrid.cpp \
|
||||
sensors/android/BLESensorAndroid.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
|
||||
@@ -113,6 +115,7 @@ HEADERS += \
|
||||
sensors/android/AccelerometerSensorAndroid.h \
|
||||
sensors/android/GyroscopeSensorAndroid.h \
|
||||
sensors/android/BarometerSensorAndroid.h \
|
||||
sensors/android/BLESensorAndroid.h \
|
||||
sensors/dummy/AccelerometerSensorDummy.h \
|
||||
sensors/dummy/GyroscopeSensorDummy.h \
|
||||
sensors/dummy/BarometerSensorDummy.h \
|
||||
@@ -203,7 +206,9 @@ HEADERS += \
|
||||
nav/grid/RegionalResampling.h \
|
||||
nav/Observation.h \
|
||||
nav/grid/State.h \
|
||||
nav/CurEst.h
|
||||
nav/CurEst.h \
|
||||
sensors/BLESensor.h \
|
||||
tools/calibration/BLECalibrationDataModel.h
|
||||
|
||||
DISTFILES += \
|
||||
android-sources/src/MyActivity.java \
|
||||
|
||||
Reference in New Issue
Block a user