UWP Quaternions Not Updating


I have the Sensor Fusion algorithm up and running on my MetaMotion R through a UWP app. However, even when I'm constantly twisting and turning the sensor around, the outputted quaternions sometimes remains the same values for around 5 seconds long (sometimes even longer). There is also a noticeable lag between rotation and output of quaternions even when the algorithm seems to work. 

Any help would be greatly appreciated.



  • Hi Eric,

    I actually already have this. The line for my connection parameters is the following:

    mbl_mw_settings_set_connection_parameters(cppBoard, 2F, 7.5F, 0, 5000);

    Do you have anything else I could try?

  • Also, sometimes when I run my program, I get an error on the line 

    mbl_mw_connection_notify_char_changed(cppBoard, response, (byte)response.Length);

    "System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

    This will happen occasionally without changes to my code, and I can't figured out. It is not solved by unpairing and repairing to the sensor.

  • 2 is not a valid connection interval value.  Call the function with the sample parameters as in the code I linked.

    How are you configuring the sensor fusion algorithm?  It's likely the acc and gyro settings are not properly set for your spe

    As another check, use the MetaHub app and see if you are seeing the same issues.
  • Eric,

    I tried changing the settings to those that you suggested and it seemed to keep the app from failing. Thanks!

    I tried to use MetaHub, and the text below the sensor never turns green as it does in my Sensor Fusion app. When I try selecting my sensor I get the following error:

    "Error, timed out while initializing the board. Do you want to retry with the currently selected board?" 

    Now, when I go back to my sensor fusion application I get an error on the line

    `var initResult = await board.Initialize();`

    with the following message:

    System.UnauthorizedAccessException occurred
      Message=Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
      Source=<Cannot evaluate the exception source>
       at Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService.GetCharacteristics(Guid characteristicUuid)
       at MbientLab.MetaWear.Template.MetaWearBoard.<Initialize>d__14.MoveNext() in C:\Users\Dan\Desktop\Angle Sensor Project\MetaWear-UwpStarter-master\CS Template\MetaWearBoard.cs:line 112
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at MbientLab.MetaWear.Template.MainPage.<pairedDevices_SelectionChanged>d__3.MoveNext() in C:\Users\Dan\Desktop\Angle Sensor Project\MetaWear-UwpStarter-master\CS Template\MainPage.xaml.cs:line 88

    Here's the code for my implementation of sensor fusion:

    `mbl_mw_settings_set_connection_parameters(cppBoard, 7.5F, 7.5F, 0, 6000);
                mbl_mw_sensor_fusion_set_mode(cppBoard, SensorFusion.Mode.NDOF);
                mbl_mw_sensor_fusion_set_acc_range(cppBoard, SensorFusion.AccRange.AR_4G);


                IntPtr fusionsAccSignal = mbl_mw_sensor_fusion_get_data_signal(cppBoard, SensorFusion.Data.QUATERION); //this line works

                mbl_mw_datasignal_subscribe(fusionsAccSignal, fusionAccHandler);
                mbl_mw_sensor_fusion_enable_data(cppBoard, SensorFusion.Data.QUATERION);
  • Try re-pairing the board to your Win10 device.  It sounds like for whatever reason, your app no longer has access permission to the board.

    As mentioned in my previous post, you'll have to configure the acc and gyro settings for your use case.  You currently have configured the acc range, which may not be high enough, and have yet to configure the gyro range.
  • Hi Eric,

    Sorry about the late reply. Adjusting the gyro range with the following line worked for me:

    mbl_mw_sensor_fusion_set_gyro_range(cppBoard, SensorFusion.GyroRange.GR_2000DPS);

    Thank you for that advice. Regarding the errors, this seems to happen when I exit the UWP program without hitting "Stop" in my program to call mbl_mw_sensor_fusion_stop. This is of course by prevented by always hitting stop.

    Thank you for all your help Eric!

This discussion has been closed.