Android Streaming Issue

edited March 2016 in Android
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;
                        }
                    });

        }
    });

Comments

    1. Does the accelerometer function as you expect with the sample app?
    2. Does the sample code given in the documentation work?
    3. What exactly is wrong with the data on the Android side?  Is the data being is off by +1g the only issue?
    The sample code you provided is overly complicated.  I don't see the point of having both streamRouteManager and routeManagerResult.  It is much cleaner to compact eveything into one route.
  • That code was from the sample app, so not sure how to answer in order.

    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.
  • Your OP suggests that the raw data you were receiving is wrong thus I need to know if both 1) the MetaWear app and 2) the sample code from the documentation work with your accelerometer and Android device.  Assuming, both are reporting the correct raw data, then we need to look at how you're using the library.  As I said in my previous post, compact everything into one route i.e. only one call to routeData.  You can attach multiple completion handlers if needed.  This is exactly how the sample app sets up the routes for the accelerometer, gyro, and magnetometer.
  • edited March 2016
    Ok - we ran a couple of tests with the sample app. I posted images and csv files if you want to review:
    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.
  • edited March 2016
    What are the inconsistencies you are seeing?  Again, I can take an educated guess but you need to provide me with more context and explain what is wrong with the Android data compared to the iOS data.  I'm not sure what a RION meter is.
  • edited March 2016
    This is being run on a device that has very consistent positive and negative peaks, as shown in the IOS graph. The data from the Android app is showing some inconsistent "peaks". You will see that some are way off from the other peaks - much lower/ closer to zero g. If you were to overlay the graphs they should be the same with very consistent peak values. A RION meter is a wired piezo-accelerometer device that measures g forces and distance and is very accurate. We have confirmed that the acceleration measurements are not the device characteristics changing through the use of both the IOS code example and the RION meter measurements.

    The issue comes up in post-processing through an FFT library and incorrect frequency values are calculated due to the inconsistent peak values.


  • edited March 2016
    It appears that ble packets are not reaching the Android device, which is odd considering you say everything was working with the old API. A quick way to check is to stream and log the accelerometer and do a diff on the data received; ideally you should get an exact match.

    accelModule.routeData().fromAxes().stream("acc_stream").log("acc_log").commit()
  • edited March 2016
    I'll try that. Sorry, I forgot that we were using logging with the previous Android API - not streaming.
  • edited March 2016
    I was trying to get the logging functionality to work and ran into a separate issue with that. I posted in a new thread:
    http://community.mbientlab.com/discussion/1545/android-logging

This discussion has been closed.