SensorFusion problem

Hello,

I am trying to use the SensorFusion module, but I get the following error: 

W/System.err: com.mbientlab.metawear.UnsupportedModuleException: Module 'SensorFusion' not supported for this firmware version
W/System.err:     at com.mbientlab.metawear.impl.DefaultMetaWearBoard.getModule(DefaultMetaWearBoard.java:8568)
W/System.err:     at com.mbientlab.metawear.starter.DeviceSetupActivityFragment.onServiceConnected(DeviceSetupActivityFragment.java:154)
W/System.err:     at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1335)
W/System.err:     at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1352)
W/System.err:     at android.os.Handler.handleCallback(Handler.java:739)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err:     at android.os.Looper.loop(Looper.java:158)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7229)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

I am using the Meta Motion R board with firmware ver. 1.3.3. I have used the sample Metawear Android app and it works without problems, i.e. it opens the SensorFusion module without giving the error. Therefore I am very sure it's not a problem related to board or firmware.

My code for opening the SensorFusion module looks like this:

public class DeviceSetupActivityFragment extends Fragment implements ServiceConnection {
    private MetaWearBoard mwBoard= null;

private SensorFusion sensorFusionModule;
...
    @Override
public void onServiceConnected(ComponentName name, IBinder service) {
mwBoard = ((MetaWearBleService.LocalBinder) service).getMetaWearBoard(settings.getBtDevice());

try {
sensorFusionModule = mwBoard.getModule(SensorFusion.class);
}
catch (UnsupportedModuleException e)
{
e.printStackTrace();
}

if (sensorFusionModule != null) {
sensorFusionModule.configure()
.setMode(SensorFusion.Mode.NDOF)
.setAccRange(SensorFusion.AccRange.AR_2G)
.setGyroRange(SensorFusion.GyroRange.GR_500DPS)
.commit();

sensorFusionModule.routeData().fromQuaternions().stream("sensor_fusion_stream").commit()
.onComplete(onCompleteSensorFusionHandler);
}
}
...
}

Why do I get this error?
Please help, I'm going crazy because of this problem!!!

Comments

  • edited March 2017
    Assuming you are using Android API v2.8.8, can you set a breakpoint at the getModule function and step through it to determine which operand of the boolean "and" expression fails at this line of code:
  • When I step through the code I get that the value of moduleInfo.containsKey(InfoRegister.SENSOR_FUSION.moduleOpcode() evaluates to false so both the first and second operand fails...

    The size of the moduleInfo HashMap is only 24... but when I step through the same code in the sample MetaWear Android App the size of moduleInfo is 25!

    if (moduleInfo.containsKey(InfoRegister.SENSOR_FUSION.moduleOpcode()) && moduleInfo.get(InfoRegister.SENSOR_FUSION.moduleOpcode()).present()) {


  • Ok, I think i know what's going on.  I presume you have used the starter template with your board, then updated the api dependency for sensor fusion support.  You'll need to clear the app cache with app settings or call clearCachedState from your app.
  • Yes that's exactly what I did!  

    I don't know what caused the error? But I've changed the applicationID in the build.gradle file, and now it works!!

    Should I always call clearCachedState?

    Thanks for excellent support!!
  • You only needed it in this case to remove cached information about the board from the previous API.
This discussion has been closed.