Possible Bug in fuse feature (Android)

I'm trying to fuse the linear acceleration data with quaternion data in a MetaMotionR sensor (Android SDK 3.7.1, HW 0.3, Firmware 1.4.4 updated yesterday), and I'm getting an ArrayIndexOutOfBounds when streaming.

From the Java side, the device is configured with the following code:

sensorFusion.quaternion()
    .addRouteAsync(source ->
        source.buffer().name("quaternion")
    )
    .onSuccessTask(ignored->sensorFusion.linearAcceleration().addRouteAsync(source -> {
        source.fuse("quaternion").stream((data, env)->{
            // Do things
        });
    }));

The exception I'm getting is the following:

W/BluetoothGatt: Unhandled exception in callback
    java.lang.ArrayIndexOutOfBoundsException: src.length=17 srcPos=12 dst.length=16 dstPos=0 length=16
        at java.lang.System.arraycopy(System.java:525)
        at com.mbientlab.metawear.impl.ArrayData.createMessage(ArrayData.java:77)
        at com.mbientlab.metawear.impl.StreamedDataConsumer.lambda$addDataHandler$4(StreamedDataConsumer.java:155)
        at com.mbientlab.metawear.impl.-$$Lambda$StreamedDataConsumer$b3JFDLkGI0Pi2mtR2I-nobGuhUc.onResponseReceived(Unknown Source:4)
        at com.mbientlab.metawear.impl.JseMetaWearBoard.lambda$null$17(JseMetaWearBoard.java:796)
        at com.mbientlab.metawear.impl.-$$Lambda$JseMetaWearBoard$OnC0yYpmZcKMMHqzlWEtJ-kw-x8.onChange(Unknown Source:2)
        at com.mbientlab.metawear.android.BtleService$1.onCharacteristicChanged(BtleService.java:179)
        at android.bluetooth.BluetoothGatt$1$8.run(BluetoothGatt.java:443)
        at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:725)
        at android.bluetooth.BluetoothGatt.-wrap0(Unknown Source:0)
        at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:437)
        at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:184)
        at android.os.Binder.execTransact(Binder.java:698)

Seeing the code on ArrayData.java, the exception is thrown at this point:

byte[] portion = new byte[value.state.attributes.length()];
System.arraycopy(data, offset, portion, 0, portion.length);

I've tried to debug the code and it seems that data variable contains only the data which comes from on of the sensor but not from the another, so is not possible to copy adicional bytes from data to portion once the first sensor data has been copied.

Can you help me?

Thanks in advance

Comments

  • You cannot fuse linear acc with quaternion data. The API should have returned an exception here rather than allow it through.

  • Thanks Eric,

    I have not seen anything about this in the documentation, does this mean the sensor fusion components (quaternion, linear acceleration, etc) cannot be fused?

  • They can, just not with each other.

Sign In or Register to comment.