Sensor Fusion Calibration Getting Reset

Hi,

We recently added sensor fusion calibration to our workflow. It seems that the sensor would behave normally for a while after calibrated, and then it would unexpectedly timeout and disconnect. If we read the calibration status again after that, it would revert to unreliable state, and we need to do calibration again. Is this expected behavior? How long should the calibration state hold?

We get to reproduce the calibration reset by just connecting and reconnecting to the sensor for a few times without logging or streaming.

  1. Connect
  2. Configure sensor fusion
  3. Read calibration state. If accuracy unreliable, calibrate and store calibration state.
  4. Disconnect
  5. Repeat From 1.

Comments

  • We used the logic from
    https://github.com/mbientlab/MetaWear-SDK-Python/blob/master/examples/calibrate.py
    as example for our iOS implementation.

  • Are you sure it's just a disconnect and not reset?

    If you run the calibrate.py script multiple times with the same board, it should instantly report high accuracy after the first pass.

  • We use mbl_mw_debug_disconnect(device.board) when the sensor is connected.
    Yes, the first few reconnects, the board will return HIGH_ACCURACY instantly, but after a while (5 ~ 10 disconnect - reconnects) it will become UNRELIABLE again.

  • @rlin,
    Can you confirm that after the disconnects you did not drop the sensors (this would affect calibration).
    Can you also confirm that you have not attempted a re-calibration sequence by holding the sensors as desribed here: https://mbientlab.com/tutorials/Calibration.html
    I want to rule out possibilities.
    Also can you post support evidence of this? Can you post your logs of the calibration register stream?

  • @Laura said:
    @rlin,
    Can you confirm that after the disconnects you did not drop the sensors (this would affect calibration).

    Drop the sensor as having impact force on the sensor? No, the sensor is sitting stationary on flat surface.

    Can you also confirm that you have not attempted a re-calibration sequence by holding the sensors as desribed here: https://mbientlab.com/tutorials/Calibration.html

    After the calibration, the subsequent connection do one read of mbl_mw_sensor_fusion_calibration_state_data_signal, and if the reading is high accuracy, I just sleep 1s and do a disconnect for the testing.

    I want to rule out possibilities.
    Also can you post support evidence of this? Can you post your logs of the calibration register stream?

    Do you mean the result from mbl_mw_sensor_fusion_calibration_state_data_signal?
    When the reset is happening, the BLE connection seems to be in a weird state. Call to mbl_mw_sensor_fusion_calibration_state_data_signal after connect would throw a disconnect completion source error with error NSError domain: "CBErrorDomain" - code: 6, The connection has timed out unexpectedly. But the device.isConnectedAndSetup will still return true. Hope this will provide more insight?

  • Please post a stream of the calibration_state_data_signal as it changes and your BLE logs if possible.

  • Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,0,gyroscope,0,magnetometer,0
    Calibration: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,0,gyroscope,0,magnetometer,0
    accelrometer,0,gyroscope,2,magnetometer,0
    accelrometer,0,gyroscope,3,magnetometer,0
    accelrometer,0,gyroscope,3,magnetometer,0
    accelrometer,0,gyroscope,3,magnetometer,0
    accelrometer,0,gyroscope,3,magnetometer,2
    accelrometer,0,gyroscope,3,magnetometer,2
    accelrometer,0,gyroscope,3,magnetometer,2
    accelrometer,0,gyroscope,3,magnetometer,2
    accelrometer,0,gyroscope,3,magnetometer,2
    accelrometer,0,gyroscope,3,magnetometer,2
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,0,gyroscope,3,magnetometer,3
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_sensor_fusion_write_calibration_data
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    Connecting
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,3,gyroscope,3,magnetometer,3
    mbl_mw_debug_disconnect
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    disconnect error: "The connection has timed out unexpectedly."
    
  • I created mock up app that should reproduce the problem.
    It will connect and calibrate the device if it's unreliable.
    If you do disconnect/connect a few times after device is calibrated, you will see the exception message with disconnect.

  • I am not sure I understand the issue here, you can just attempt to reconnectvafter:
    disconnect error: "The connection has timed out unexpectedly."
    In fact, your app should automatically re-try / re-connect if there is a conn failure.

  • edited February 2019

    The problem is after "The connection has timed out unexpectedly.", the sensor calibration state reverts to unreliable after reconnect. It seems the calibration data is being cleared when this happens every time.

    In addition, the connection error never occurs if we don't save calibration data to sensor with the same code, but happens consistently if we do. So we suspect this is not a normal behavior.

  • edited February 2019

    Is there any reason you didn't post that part of your stream (this info is missing from your Feb 25th post)? Can you send us the script to replicate this?

  • Hi Laura,

    I attached a simple iOS app that replicate this in the previous post (CalibrationTest.zip).

    I missed the last segment when I copied. That part of the stream is similar except calibration state went back to 0,0,0.
    Here is the segment after the disconnect error.

    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    disconnect error: "The connection has timed out unexpectedly."
    Connecting
    Connected
    After Connect: mbl_mw_sensor_fusion_calibration_state_data_signal
    accelrometer,0,gyroscope,0,magnetometer,0
    
  • Can this bug be confirmed?

  • No, I have not run across any calibration issues so far.

    I suspect that in your case, the board is resetting. You can check this by using a boot time macro to turn on the led.:

    libmetawear.mbl_mw_macro_record(device.board, 1)
    pattern= LedPattern(pulse_duration_ms=1000, high_time_ms=500, high_intensity=16, low_intensity=16, repeat_count=5)
    libmetawear.mbl_mw_led_write_pattern(device.board, byref(pattern), LedColor.BLUE)
    libmetawear.mbl_mw_led_play(device.board)
    create_voidp_int(lambda fn: libmetawear.mbl_mw_macro_end_record(device.board, None, fn), event = e)
    
  • Hi Eric,
    Yes, the board is resetting.
    Do you know what's causing the board to be resetting?
    If I don't save the calibration data to the board, it never resets itself.
    When I do save the calibration, the board resets itself after a few re-connections.

  • You don't need to continually write the calibration data. Once it is calibrated, write it once (combine with a macro if you want it done automatically on boot).

  • Calibration macro helps, but that doesn't solve all the problems.
    One side effect when unintentional reboot happens is sensor name would also get reset.
    It's hard to find the right sensor when there are multiple sensors and multiple iPads. We swap devices with sensors in some use cases, so remembering sensor on device doesn't help solve that problem.

  • Use the macro to also set the sensor name on boot.

  • If we set the sensor name with a macro on boot, what will happen if a user tries to rename the device again? Will the name be set twice or the new macro will overwrite previous one? I don't find a function to erase a specific macro beside erasing all macros, which will also erase the calibration macro.
    Thanks for helping out.

  • Macros are just stored commands, executed in the order they were programmed; there is no macro "overwriting".

    You will have to erase all macros in order to change device name. Just read the calibration data before erasing the macros.

  • Have a question regarding erasing macros, I know we need to disconnect to erase macros, but do I have to do:
    1. Erase all macros
    2. Disconnect
    3. Re-connect
    4. Set new macros

    Or can I do the following:
    1. Erase all macros
    2. Set new macros
    3. Disconnect

  • @rlin said:
    Have a question regarding erasing macros, I know we need to disconnect to erase macros, but do I have to do:
    1. Erase all macros
    2. Disconnect
    3. Re-connect
    4. Set new macros

    Or can I do the following:
    1. Erase all macros
    2. Set new macros
    3. Disconnect

    The former.

Sign In or Register to comment.