Android Streaming Issue
I updated my Android code to the new API and am having an issue with data streaming at 100Hz. It is fine with IOS code, but the same settings in Android give weird results. I have links to two graphs showing readings from the IOS code and readings from the Android code.
IOS_Graph
Android_Graph
These are both raw data, same settings at 100Hz streaming.
Here is the Android code I'm using to collect the data:
final AsyncOperation<RouteManager> routeManagerResult= accelModule.routeData().fromAxes().stream(STREAM_KEY).commit();
routeManagerResult.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
accelModule.enableAxisSampling();
accelModule.start();
accelModule.routeData().fromAxes().stream("accel_stream").commit()
.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(final RouteManager result) {
streamRouteManager = result;
result.subscribe("accel_stream", new RouteManager.MessageHandler() {
@Override
public void process(Message msg) {
axisData = msg.getData(CartesianFloat.class);
float y = axisData.y();
if (accSamples.size() < 1024) {
//Add to acc arraylist
accSamples.add(y);
} else {
//Perform Calculations
}
}
});
}
@Override
public void failure(Throwable error) {
Log.e("test", "Error committing route", error);
//accelSetup = false;
}
});
}
});
IOS_Graph
Android_Graph
These are both raw data, same settings at 100Hz streaming.
Here is the Android code I'm using to collect the data:
final AsyncOperation<RouteManager> routeManagerResult= accelModule.routeData().fromAxes().stream(STREAM_KEY).commit();
routeManagerResult.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
accelModule.enableAxisSampling();
accelModule.start();
accelModule.routeData().fromAxes().stream("accel_stream").commit()
.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(final RouteManager result) {
streamRouteManager = result;
result.subscribe("accel_stream", new RouteManager.MessageHandler() {
@Override
public void process(Message msg) {
axisData = msg.getData(CartesianFloat.class);
float y = axisData.y();
if (accSamples.size() < 1024) {
//Add to acc arraylist
accSamples.add(y);
} else {
//Perform Calculations
}
}
});
}
@Override
public void failure(Throwable error) {
Log.e("test", "Error committing route", error);
//accelSetup = false;
}
});
}
});
This discussion has been closed.
Comments
It works, it is just recording inaccurate results that wasn't happening with the methods from the previous API using callbacks and the IOS methods. We are calculating distances and the discrepancy is causing an exponential issue with the distance related calculations.
MWSampleAppResults1.png
MWSampleAppResults2.png
Accelerometer_20160314-131910462.csv
Accelerometer_20160314-131939419.csv
Graphs are with y axis at 8g, 100Hz.
IOS app and a RION meter did not record the inconsistencies shown.
I'm working on your other request for the code from the documentation. Should have that later today.
The issue comes up in post-processing through an FFT library and incorrect frequency values are calculated due to the inconsistent peak values.
accelModule.routeData().fromAxes().stream("acc_stream").log("acc_log").commit()
http://community.mbientlab.com/discussion/1545/android-logging