probably bug at sensor fusion beta-03

Hi Eric,

I think there is probably a bug at sensor fusion by configurate the mode.

source code of configuration the sensor fusion:
boardHandRight.connectAsync().onSuccessTask(task -> {
sensorFusionHandRight = boardHandRight.getModule(SensorFusionBosch.class);
sensorFusionHandRight.configure().mode(SensorFusionBosch.Mode.NDOF).
accRange(SensorFusionBosch.AccRange.AR_2G).
gyroRange(SensorFusionBosch.GyroRange.GR_500DPS).commit();
return sensorFusionHandRight.eulerAngles().addRoute(source -> {
source.log((msg, env) -> {
record.getHandRightData().addEuler(msg.timestamp(), msg.value(EulerAngle.class));
Log.i("HAND RIGHT", "EULER " + msg.formattedTimestamp() + msg.value(EulerAngle.class));
});
});
});
and start the logging:
ledHandRight.editPattern(Led.Color.BLUE);
ledHandRight.play();
logModuleHandRight.clearEntries();
logModuleHandRight.start(false);
sensorFusionHandRight.eulerAngles().start();
sensorFusionHandRight.start(); // At this Line I have the problems
Here the message:
12-14 12:18:41.864 31188-31188/com.gaitapp.steinmetzer.gaitapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gaitapp.steinmetzer.gaitapp, PID: 31188
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.mbientlab.metawear.module.SensorFusionBosch$Mode.ordinal()' on a null object reference
at com.mbientlab.metawear.impl.SensorFusionBoschImpl.start(SensorFusionBoschImpl.java:491)
at com.gaitapp.steinmetzer.gaitapp.fragments.InsoleFragment$7.onClick(InsoleFragment.java:358)
at android.view.View.performClick(View.java:5698)
at android.view.View$PerformClick.run(View.java:22570)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7231)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I look also in the source code from the sample app beta-03. In my Opinion you don't update this code to the beta version. Here the link:
https://github.com/mbientlab/Metawear-SampleAndroidApp/blob/3.0_beta/app/src/main/java/com/mbientlab/metawear/app/SensorFusionFragment.java

Thank you for helping.

Best reguards
Tobias

Comments

  • Sorry, that class should not be on the beta branch at the moment since, as you have pointed out, the code has not been updated yet.  We do have a demo app using a quaternion stream to rotate a cube that has working sensor fusion code, you can check that out here.  

    As for the null pointer exception, I have never encountered an npe when calling start after committing a configuration profile.  Can you check that the sensor fusion demo app linked above works for you?
  • I tested the cube demo. All works fine.
    But in this demo you use the beta-01. In my project i use the beta-03. In this version you modified many class names. I think there is propably a mistake. Because in beta-03 I can only select the class SensorFusionBosch and not the super class SensorFusion.
  • The cube demo was updated to use beta-03 a few days ago.
  • Sorry, my mistake. I checked the demo again and they run.

    I found a mistake in my code too but not the main mistake. In the last days I try some stuff but nothing work for me. Now I have build a new sampleapp based on your starter project.

    Here my sourcecode: Link

    If I stream the data the app run perfect, but if I want log the data nothing work. I hope you can help me.

  • The addRoute function is asynchronous, you need to use the Continuation object to check if the operation failed and to add the next route at the appropriate time.
  • edited January 2017

    Hi Eric,

    thank you for your fast support! Now the source code work very fine.

    P.S. version 3.x.x of the api works very well
This discussion has been closed.