Metamotion r IMU calibration

I have the Metamotion r and i am fusioning with IMUPlus mode. 

What i have noticed is that the first time i connected to the board it saved the initial position of the board 
and when i close and open the app and connect back the initial reference will be from that position.

When i reset the board from the app and i make the first connection the board gets the new initial position where it was when
the first connection happen after the reset.

My question is there a way to force this functionality every time i connect to the board? Without having to reset the board.
It is something like calibration i can achieve with this.

Thank you,
Jim

Comments

  • Are you restarting and/or reconfiguring the sensor fusion algorithm upon connecting?  What is the code being executed prior to closing the app and after connecting to the board?
  • When i am connection i am running 

    public void sample(boolean isChecked) throws Exception {
    if (isChecked) {
    isStopped = false;
    // stream quaternion values from the board
    fusionModule.routeData().fromQuaternions().stream("quaternion").commit()
    .onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
    @Override
    public void success(RouteManager result) {
    result.subscribe("quaternion", new RouteManager.MessageHandler() {
    @Override
    public void process(Message msg) {
    //Log.i("example", msg.getData(SensorFusion.Quaternion.class).toString());
    SensorFusion.Quaternion quaternion = msg.getData(SensorFusion.Quaternion.class);
    for (IFusionSubscriber subscriber : subscribers) {
    try {
    subscriber.notified(quaternion);
    } catch (Exception ex) {
    logger.error("An error occurred", ex);
    }

    }

    }
    });
    fusionModule.start(SensorFusion.DataOutput.QUATERNION);
    }
    });
    } else {
    try {
    fusionModule.stop();
    } catch(Exception ex) {
    ex.printStackTrace();
    }

    isStopped = true;
    }

    }
    Is the board caching a starting point from the first run until reset?
  • The sensor fusion algorithm resets its internal state when you change configuration or start the algorithm.  Are you configuring the algorithm elsewhere (don't see code to set mode to IMUPlus) and stopping the algorithm before closing the app?



  • In the same Class with the above code i have his:

    public static FusionWrapper getInstance(MetaWearBoard.Module board) throws Exception {
    if (null == board) {
    logger.error("An error occured", "Null passed for board in FusionWrapper");
    throw new Exception("Null passed for board");
    }
    fusionModule = (SensorFusion) board;
    fusionModule.configure()
    .setMode(SensorFusion.Mode.IMU_PLUS)
    .setAccRange(SensorFusion.AccRange.AR_16G)
    .commit();
    if (null == instance) {
    instance = new FusionWrapper();
    }
    return instance;
    }

    And in my activity i have this to initialize the fusion:
    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
    // Typecast the binder to the service's LocalBinder class
    mwBoard = ((MetaWearBleService.LocalBinder) service).getMetaWearBoard(device);
    mwBoard.setConnectionStateHandler(connectionHandler);
    if (mwBoard == null || !mwBoard.isConnected()) {
    accel_switch.setEnabled(false);
    } else {
    accel_switch.setEnabled(true);
    try {
    fusionWrapper = FusionWrapper.getInstance(mwBoard.getModule(SensorFusion.class));
    } catch (Exception ex) {
    logger.error("An Error Occurred", ex);
    }
    }
    invalidateOptionsMenu();

    }

    When a menu item is pressed i close the algorithm like this:

    case R.id.disconnect_menu:
    if (accel_switch.isChecked()) {
    accel_switch.setChecked(false);
    } else {
    if (fusionWrapper.isStopped()) {
    mwBoard.setConnectionStateHandler(null);
    mwBoard.disconnect();
    accel_switch.setEnabled(false);
    invalidateOptionsMenu();
    }

    }
    return true;
    My problem is when i start the algorithm it has a predefined starting location 
    but if i reset the board from the menu when i first run the algorithm it takes
    the current board location as starting and then calculates the orientation from there and this is what i want.
    If i close the application run it again and whatever i do except the reset the predifined location stays the same.
    Also Metawear r has a button to start and close? because the battery is always connected. To open it i have to connect it with a pc and then stays opened.

    Thank you,
    Jim
  • After doing some testing and talking with the firmware dev, you will have to reset the board to reset the position.

    The board is always powered on when a power source is attached.
  • Thank you for the info, one last question:

    If i connect the board in my pc with a cable and then disconnect it how much time the board says open without connecting to it?

    Thanks,
    Jim
  • I'm not sure what you mean by "stays open without connecting to it".  Assuming you mean how long the battery lasts, that depends on the use case.  The board can advertise as an iBeacon or measure temperature every 30 minutes for months but running motion sensors (acc, gyro, mag) will drain the battery in days.
This discussion has been closed.