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;
}
}

Comments

  • You can't stream that much data simultaneously.  Use a limiter to reduce the data throughput.
  • What kind of data rates can be supported.  I limited to 10hz and the second sensor is still never getting a single callback.  We eventually need to support three
  • Does the 2nd ever sensor stream data?  You probably just have to restart the board.

    The typical rule of thumb is 100Hz total data throughput.  You will also need to set the ble connection parameters to support streaming that much data.
  • I am using sensor fusion as opposed to the accelerometer, etc.. directly.  How do I configure that to stream at high frequency.

  • You can't.  As I said, you just need to set the ble connection parameters as described in the link.
  • I have made both these changes (see below) and still having no success getting data from two sensors simultaneously.  This is 2 sensors at 10 HZ so well below 100 HZ combined. We have tried wth many different combinations of sensors and get either - none getting data, 1 receiving data at the correct rate and the other only getting data approximately once a second, or 1 receiving data at the correct rate and the other not at all. In addition, since making these changes I can no longer stop the monitoring and start them again (this used to work).  Now after stopping them once, I never get data on any of the sensors even though addRouteAsync appears to complete correctly:  Here is my code:
    sensorFusion.eulerAngles().addRouteAsync(source ->  {source.limit(100);
    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();

    final Settings settings = mMWBoard.getModule(Settings.class);
    settings.editBleConnParams()
    .maxConnectionInterval(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? 11.25f : 7.5f)
    .commit();

    }
    public void stopMonitoring() {
    if (mStreamRoute != null) {
    mStreamRoute.remove();
    mStreamRoute = null;
    }
    sensorFusion.eulerAngles().stop();
    sensorFusion.stop();
    }
  • Stream the limiter, not the source.

    source.limit(100).stream(...)
  • Ok  I made that change but it has made no difference to my issues.  Still most of the time the second sensor connected never receives a data callback and if it does work, as soon as it is stopped once it will not restart.
  • Asus Zenpad 10  Android 6.0   I'm happy to share the project but obviously can't post the whole thing here - how do I get it to you.  We have reset the boards and can stream one sensor through the Metabase app but do not see a way to stream more than one at a time.  Am I missing how you would do that?
  • Put it on GitHub or a public file sharing site.

    The settings page has an option to enable streaming from 2 devices.  You can see a screenshot of it in the app store page.
  • I will have to see if my client is ok with me posting the source publicly.  They may not be.  Is there somewhere I can email it?  Or can we set up something private we can give you a link to?

    I did enable the multiple devices in the Metabase App and I get the same behavior when I try to connect two sensors   One sensor works correctly but as soon as I enable two it gives the message that they are configured correctly and ready to start logging data but the number of samples stays at zero.
  • I also tried on an Nexus phone I have running Android 5.1.1. and have the same behavior.  One sensor works fine.  Second sensor I get no data samples.
  • We cannot provide private help unless under a support contract.  You can inquire about such services by contacting MbientLab directly (http://mbientlab.com/contact/).

    One more app you can try is the multi mw tutorial app (https://github.com/mbientlab/MetaWear-Tutorial-Android/tree/master/multimw).

    Which Nexus device are you using?  Streaming from 2 devices with MetaBase works fine with the Nexus 5 (4.4), 6 (6.0) & 9 (7.1.1) along with virtual machines running the Android x86 build (6.0 and 7.1).
  • The multi metawear app does not stream any motion data - only orientation,  I attempted to modify it to show Euler angles instead of orientation a few weeks back and it also does not work,

    The Nexus is a Nexus 4 which is an older device.  The tablet however is a brand new modern tablet (Asus ZenPad 10).   Two sensors with your MetaBase app definitely do not work at all.  I get no data samples if more than one sensor is connected.   This is with any combination of the multiple sensors I have - it is not always the same two sensors.  The sensors stream fine on iOS.
  • My point is to check if your Android device can even maintain connection with multiple devices.  Since the multimw app is not streaming data at 100Hz, you should at least be able to stream button presses and orientation changes from multiple devices without any problems.

    I dug up the Galaxy S4 phone (April 2013) running 5.0.1 and I can stream quaternions from 2 devices.  At this point, I can only surmise that the Android devices you are testing with cannot connect to or maintain a stable connection with multiple devices.
  • We can stream orientation changes on both these devices no problem.   As soon as I switch to motion data it stops working.   What tablets have you tested on in-house that you can steam euler angles from three sensors?   It would not be great for us to have to buy new hardware but if that is what we have to do.  But I don't want to purchase something else that will not work. 
  • The only tablet we have is a Nexus 9 which works fine.  Does your Android device have to be a tablet?
  • It does need to be a tablet for our purposes - we need the larger screen
  • Can you try a Nexus 9?
Sign In or Register to comment.