Fuse Accelerometer, Gyroscope and magnetometer
Hi, I'm trying to fuse Accelerometer, Gyroscope and magnetometer.
I could do it between acc and gyro as explained in the documentation, but the app is crashing when trying to do it between three of them.
String[] buffers = new String[]{"gyro-buffer", "magn-buffer"};
gyroProducer.addRouteAsync(source ->
source.buffer().name("gyro-buffer")
).onSuccessTask(gyroTaskContinuation -> magnProducer.addRouteAsync(source ->
source.buffer().name("magn-buffer")
).onSuccessTask(accTaskContinuation -> accProducer.addRouteAsync(source ->
source.fuse(buffers).stream((Subscriber) (data, objects) -> {
Data[] values1 = data.value(Data[].class);
System.out.printf("acc = %s, gyro = %s, magn = %s%n", values1[0].value(Acceleration.class),
values1[1].value(AngularVelocity.class), values1[2].value(MagneticField.class));
})
))).continueWith(task -> {
streamRoute = task.getResult();
gyro.angularVelocity().start();
gyro.start();
accProducer.start();
accelerometer.start();
magnetometer.magneticField().start();
magnetometer.start();
return null;
});
Is it possible to fuse more than two sensor's data?
I appreciate any help you can give me!
Comments
Hi Eric, this is the line where the lib crashes when I execute that code, and this is the stacktrace: