Streaming from multiple MMRs
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
print(addr)
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:
e.set()
data_source = SensorFusionData.QUATERNION
max_connect_attempts = 5
try:
device = MetaWear(addr, hci_mac='hci0')
device.connect()
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))
exit(1)
try:
libmetawear.mbl_mw_sensor_fusion_set_mode(device.board, SensorFusionMode.NDOF)
libmetawear.mbl_mw_sensor_fusion_write_config(device.board)
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
e.wait()
except RuntimeError as err:
print(err)
finally:
libmetawear.mbl_mw_sensor_fusion_stop(device.board)
libmetawear.mbl_mw_sensor_fusion_clear_enabled_mask(device.board)
libmetawear.mbl_mw_datasignal_unsubscribe(processor)
libmetawear.mbl_mw_debug_disconnect(device.board)
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:
Connected
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?
Comments
100 hz is the max throughput for BLE... You can't go higher.
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?)
per antenna...read 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: https://mbientlab.com/tutorials/search.html?q=packer (Or is there any tutorial on the packer?)