Difficulty using data processors
I am trying to stream around 100 x,y,z data from the accelerometer prior and after a switch trigger. I am trying to use this code for this purpose:
final byte sampleSize= 100;I am not able to get any data from any axis when I try this. On the other hand, if I use only 1 axis, I am able to get the data. I don't think this would be a problem with the output rate because I am using just 25 for that. Can you suggest what I should do to resolve this issue?
final String streamKeyX= "x_axis_event_data";
final String streamKeyY= "y_axis_event_data";
final String streamKeyZ= "z_axis_event_data";
accelCtrllr.routeData().fromXAxis()
.process(new Sample(sampleSize))
.process(streamKeyX, new Passthrough(Passthrough.Mode.COUNT, (short) 0))
.stream(streamKeyX)
.commit().onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
result.subscribe(streamKeyX, new RouteManager.MessageHandler() {
@Override
public void process(Message message) {
Log.i("X Axis", "" + message.getData(Float.class));
}
});
}
});
accelCtrllr.routeData().fromYAxis()
.process(new Sample(sampleSize))
.process(streamKeyY, new Passthrough(Passthrough.Mode.COUNT, (short) 0))
.stream(streamKeyY)
.commit().onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
result.subscribe(streamKeyY, new RouteManager.MessageHandler() {
@Override
public void process(Message msg) {
Log.i("Y Axis", "" + msg.getData(Float.class));
}
});
}
});
accelCtrllr.routeData().fromZAxis()
.process(new Sample(sampleSize))
.process(streamKeyZ, new Passthrough(Passthrough.Mode.COUNT, (short) 0))
.stream(streamKeyZ)
.commit().onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
result.subscribe(streamKeyZ, new RouteManager.MessageHandler() {
@Override
public void process(Message msg) {
Log.i("Z Axis", "" + msg.getData(Float.class));
}
});
}
});
switchModule.routeData().fromSensor().monitor(new DataSignal.ActivityHandler() {
@Override
public void onSignalActive(Map<String, DataProcessor> processors, DataSignal.DataToken token) {
processors.get(streamKeyX).setState(new Passthrough.State((short) (sampleSize * 2)));
processors.get(streamKeyY).setState(new Passthrough.State((short) (sampleSize * 2)));
processors.get(streamKeyZ).setState(new Passthrough.State((short) (sampleSize * 2)));
}
}).commit();
This discussion has been closed.
Comments
I have tried using this app in Android Kitkat, Lollipop, Marshmallow. None of them worked.
I am using the RG board with firmware version 1.0.4.
Can we use some math functions (sum, avg, etc.) to lower the number? Basically, we are trying to save/stream 1 sec prior and 1 sec after an event (100Hz freq). If this is not possible with current setup, is there something we can do (custom firmware for example) to achieve this?
Thanks,
Vinod.
I have been trying out various stuff and it looked like I cannot even log X axis, y axis and z axis separately. So, I am trying to do something like this Since the Passthrough process cannot be used with the Axes data, I am trying to add a time filter that will allow the data to be logged 1 second after the button click. But I am getting a Null Pointer Exception saying:
java.lang.NullPointerException: Attempt to invoke interface method 'void com.mbientlab.metawear.module.DataProcessor.modifyConfiguration(com.mbientlab.metawear.DataSignal$ProcessorConfig)' on a null object reference
Can you help me resolve this issue?
Can you tell me if there is any other filter that can hold 200 odd xyz data prior to the trigger? Or atleast break down the xyz data within the routeData().fromAxes() method?
Later on when I stop the scanning, after a couple of seconds, the board automatically disconnects from the app and then gives out this error before re-connecting itself :
ExampleActivity﹕ Error connecting
java.lang.RuntimeException: onConnectionStateChanged reported non-zero status: 8
at com.mbientlab.metawear.MetaWearBleService$2$2.run(MetaWearBleService.java:909)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
After starting the scanning and waiting for around 20 seconds, the board is automatically disconnecting and giving me this output.
to get 3 axes working with sample size of 50. Next, in our
application we need both gyro and accel data with the same spec. Is there any customization of
the board that we can do to achieve that? I am assuming that the current board supports only upto a limited number of data entries in the sample filter due to which we are having this error(maybe the memory issues of the queue). Is it possible to customize the board to increase the capacity of this? Or is there any other way to solve this?