SensorFusion Logging

Hi folks,

I am trying to log the quaternion and linear acceleration data from the sensor fusion. But I have some problem with downloading the sensor data from the board. I am using a MetaMotion R board and have modified the metawear sample Android app 3.5.0. The problem is that the process method in the MessageHandler is never called and I receive only a lot of unknown entries in receivedUnknownLogEntry. Here are the relevant codes:

Any suggestions are greatly appreciated. Thanks!
protected void setup() {
sensorFusion.configure()
.setMode(SensorFusion.Mode.NDOF)
.setAccRange(SensorFusion.AccRange.AR_16G)
.setGyroRange(SensorFusion.GyroRange.GR_2000DPS)
.commit();


if (srcIndex == 0) {
sensorFusion.routeData().fromQuaternions().log("Q").commit()
.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {

streamRouteManager= result;
result.setLogMessageHandler("Q", new RouteManager.MessageHandler() {
@Override
public void process(Message message) {
final Quaternion quaternion = message.getData(Quaternion.class);

LineData data = chart.getData();

data.addXValue(String.format(Locale.US, "%.2f", sampleCount * SAMPLING_PERIOD));
data.addEntry(new Entry(quaternion.w(), sampleCount), 0);
data.addEntry(new Entry(quaternion.x(), sampleCount), 1);
data.addEntry(new Entry(quaternion.y(), sampleCount), 2);
data.addEntry(new Entry(quaternion.z(), sampleCount), 3);

sampleCount++;
}
});


logModule.startLogging();
sensorFusion.start(SensorFusion.DataOutput.QUATERNION);
}
});

Comments

  • edited February 2017
    Implement the failure function in the CompletionHandler object and log the error message if any is received.  The code you have looks fine to me so the error could be from somewhere else.
  • Hi, Eric,

    Thanks for your reply. I have tried implementing the failure function. But nothing gets printed out. Also, the return value of setLogMessageHandler shows that it was successful. Do you have any idea of any other thing that could go wrong?

    Thanks!

    public void failure(Throwable error) {
    Log.e("Acceleratrion", "Error committing route", error);
    }
  • edited February 2017
    protected void downloadLog() {
        Log.i("MainActivity", String.format("Start downloading"));

    logModule.downloadLog(0.1f, new Logging.DownloadHandler() {
    @Override
    public void onProgressUpdate(int nEntriesLeft, int totalEntries) {
    Log.i("MainActivity", String.format("Progress= %d / %d", nEntriesLeft,
    totalEntries));
    }
    public void receivedUnhandledLogEntry(Message logMessage) {
    super.receivedUnhandledLogEntry(logMessage);
    Log.i("MainActivity", String.format("Unhandled message: %s", logMessage.toString()));
    }

    public void receivedUnknownLogEntry(byte logId, Calendar timestamp, byte[] data) {
    super.receivedUnknownLogEntry(logId, timestamp, data);
    String s = new String(data);
    Log.i("MainActivity", String.format("Unknown log entry: {id: %d, data: %s}", logId, Arrays.toString(data)));
    }
    });
    }

    02-10 15:45:03.306 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 3, data: [29, -72, 68, -72]}
    02-10 15:45:03.306 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 0, data: [22, -102, 127, 63]}
    02-10 15:45:03.306 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 1, data: [-103, -33, 67, 60]}
    02-10 15:45:03.307 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 2, data: [-34, 7, 95, 61]}
    02-10 15:45:03.307 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 3, data: [29, -72, 68, -72]}
    02-10 15:45:03.355 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 0, data: [22, -102, 127, 63]}
    02-10 15:45:03.355 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 1, data: [-103, -33, 67, 60]}
    02-10 15:45:03.359 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 2, data: [-34, 7, 95, 61]}
    02-10 15:45:03.359 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 3, data: [29, -72, 68, -72]}
    02-10 15:45:03.361 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 0, data: [22, -102, 127, 63]}
    02-10 15:45:03.361 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 1, data: [-103, -33, 67, 60]}
    02-10 15:45:03.361 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 2, data: [-34, 7, 95, 61]}
    02-10 15:45:03.362 5159-5159/com.mbientlab.metawear.app I/MainActivity: Unknown log entry: {id: 3, data: [29, -72, 68, -72]}
    02-10 15:45:03.497 5159-5159/com.mbientlab.metawear.app I/MainActivity: Progress= 0 / 434

  • edited February 2017
    The unknown log entry error function is executed if the API receives log data but doesn't know which route to send the log data to. This typically happens if you connect to a board that already has an active logger or you rebuild a route before removing the previous route. Are you removing the routes once you finish your logging?
  • I think I found the problem. It might be that I stop the sensor fusion model before downloading the data, which might remove the routes.
  • Ah that is correct, removing a route before the log download will cause the unknown log entry to be fired.
This discussion has been closed.