Sensor Fusion data from multiple sensors
I'm trying to get Euler Angle data from multiple sensors at the same time. One sensor works fine. When I add a second sensor, the handler for the second sensor never gets called at all. The first does for a short time but then just stops responding. Relevant code:
public class DoorSensor {
public DoorSensor(BluetoothDevice btd, MetaWearBoard mwBoard, Context context) {
mSensor = btd;
mSensorID = mSensor.getAddress();
mMWBoard = mwBoard;
mContext = context;
sensorFusion = mMWBoard.getModule(SensorFusionBosch.class);
setup();
}
public void startMonitoring() {
sensorFusion.eulerAngles().addRouteAsync(source -> source.stream((data, env) -> {
mLastAngle = data.value(EulerAngles.class);
})).continueWith(task -> {
mStreamRoute = task.getResult();
sensorFusion.eulerAngles().start();
sensorFusion.start();
return null;
});
}
protected void setup() {
sensorFusion.configure()
.mode(Mode.NDOF)
.accRange(SensorFusionBosch.AccRange.AR_16G)
.gyroRange(GyroRange.GR_2000DPS)
.commit();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_START_BLE_SCAN:
MainActivity.lastBTDevice = data.getParcelableExtra(edu.osu.pulseofor.ScannerActivity.EXTRA_DEVICE);
MetaWearBoard mwBoard= ((BtleService.LocalBinder) MainActivity.mServiceBinder).getMetaWearBoard(lastBTDevice);
DoorSensor doorSensor = new DoorSensor(lastBTDevice, mwBoard, getActivity());
mDoorSensors.put(lastBTDevice, doorSensor);
mConnectedBTDevices.add(lastBTDevice);
break;
}
}
This discussion has been closed.
Comments
source.limit(100).stream(...)