Streaming from multiple MMRs

edited October 2019 in Python

I have two MMRs that I want to connect to my Ubuntu 18.04 Laptop's integrated BT. This is my script to connect and run the ndof-mode:

#! /usr/bin/python

from mbientlab.metawear import MetaWear, libmetawear, parse_value
from mbientlab.metawear.cbindings import SensorFusionData, SensorFusionMode, FnVoid_VoidP_DataP
from mbientlab.warble import WarbleException
from threading import Event
import sys
from time import time

count = 0
e = Event()

imu_id = 1
addr = 'F8:A3:30:FB:EA:57'

if len(sys.argv) > 1:
    addr = "C3:25:9F:99:7D:B9"
    imu_id = 2

start_time = None

def handle_notification(ctx, data):
    global count, imu_id, start_time
    # print(count)
    if not start_time:
        start_time = time()

    count += 1

    if count % 50 == 0:
        dt = time()-start_time
        print("%.1f FPS" % (count/dt))
        # start_time = None

    if count > 500:

data_source = SensorFusionData.QUATERNION

max_connect_attempts = 5

    device = MetaWear(addr, hci_mac='hci0')
    libmetawear.mbl_mw_settings_set_connection_parameters(device.board, 7.5, 7.5, 0, 6000)
except WarbleException as err:
    print('reattempting after warble exception: {}'.format(err))

    libmetawear.mbl_mw_sensor_fusion_set_mode(device.board, SensorFusionMode.NDOF)
    processor = libmetawear.mbl_mw_sensor_fusion_get_data_signal(device.board, data_source)
    wrapped_handler = FnVoid_VoidP_DataP(handle_notification)
    libmetawear.mbl_mw_datasignal_subscribe(processor, None, wrapped_handler)
    libmetawear.mbl_mw_sensor_fusion_enable_data(device.board, data_source)
    libmetawear.mbl_mw_sensor_fusion_start(device.board)  # Line that causes segfault


except RuntimeError as err:


If I activate only on MMR, I get the data with 100Hz, however as soon as I start the second MMR, the datarate of the first on drops:

Services disconvered
Characteristics discovered
Descriptors found
100.1 FPS
95.3 FPS
100.0 FPS
97.5 FPS

<-- Second IMU is started at this time
56.2 FPS
42.6 FPS
36.5 FPS
39.6 FPS
42.5 FPS
45.0 FPS

Descriptors found
100.1 FPS
100.0 FPS
100.0 FPS
100.0 FPS
100.0 FPS
100.0 FPS
100.0 FPS
100.0 FPS
100.0 FPS
100.0 FPS

Is there a demo-program in Python that shows how to run multiple MMRs?


  • 100 hz is the max throughput for BLE... You can't go higher.

  • edited October 2019

    Per device? Or for all connections together? (And why is the MetaBase-App offering a streaming rate of 200Hz if 100Hz is the max throughput?)

  • edited October 2019

    per up on bluetooth and your hardware capabilities asap.
    Logging can go up to 800Hz.
    Streaming is capped by Bluetooth.

  • And the 200Hz in the app then only refers to the sampling rate on the sensor, but the data itself is packed into a smaller number of BTLE-packages?

  • See fuser in the tutorials.
    Our first rule of this forum is to read the tutorials first.

  • I spent most of the day reading the tutorials. Isn't the fuser used to merge data from multiple sensors in a package? In this case, I want to merge multiple datapoints from the same sensor (!) into a package. So I think the packer would be the thing. And of course I read all of the tutorials about using the packer: (Or is there any tutorial on the packer?)

Sign In or Register to comment.