Sensor Fuser of all MMC data

Hello there,

I'm attempting to stream essentially all of the data from the MMC at 100hz. I read in one of the forum posts that the device can't stream faster than 100hz, so if I want to subscribe to both accelerometer gyro, and mag, for example, the output would only be at 33hz from each, is that correct?

I'd like to set up the fuser example example with accel, gyro, mag, sensorfusion(quaternion), temperature, and baro to get them all reporting data as fast as possible.

The quaternion and gyro values seem to be corrupted when they print when I do this. Am I missing something here? For example since sensorfusion needs the accel/gyro/mag data, can it not be fused with those to subscribe to?

class State:
    def __init__(self, device):
        self.device = device
        self.callback = cbindings.FnVoid_VoidP_DataP(self.data_handler)
        self.processor = None

    def data_handler(self, ctx, data):
        values = parse_value(data, n_elem = 3)
        # print(data)
        print(values)
        # print("acc: {}, gyro: {}, quaternion: {}".format(values[0], values[1]), values[2])

    def setup(self):
        libmetawear.mbl_mw_settings_set_connection_parameters(self.device.board, 7.5, 7.5, 0, 6000)
        sleep(1.5)

        e = Event()

        def processor_created(context, pointer):
            self.processor = pointer
            e.set()
        fn_wrapper = cbindings.FnVoid_VoidP_VoidP(processor_created)

        acc = libmetawear.mbl_mw_acc_get_acceleration_data_signal(self.device.board)
        gyro = libmetawear.mbl_mw_gyro_bmi160_get_rotation_data_signal(self.device.board)
        quaternion = libmetawear.mbl_mw_sensor_fusion_get_data_signal(self.device.board, cbindings.SensorFusionData.QUATERNION);

        signals = (c_void_p * 2)()
        signals[0] = gyro
        signals[1] = quaternion
        libmetawear.mbl_mw_dataprocessor_fuser_create(acc, signals, 2, None, fn_wrapper)
        e.wait()

        libmetawear.mbl_mw_datasignal_subscribe(self.processor, None, self.callback)

    def start(self):

        libmetawear.mbl_mw_gyro_bmi160_enable_rotation_sampling(self.device.board)
        libmetawear.mbl_mw_acc_enable_acceleration_sampling(self.device.board)
        libmetawear.mbl_mw_sensor_fusion_set_mode(self.device.board, cbindings.SensorFusionMode.NDOF);
        libmetawear.mbl_mw_sensor_fusion_set_acc_range(self.device.board, cbindings.SensorFusionAccRange._8G)
        libmetawear.mbl_mw_sensor_fusion_set_gyro_range(self.device.board, cbindings.SensorFusionGyroRange._2000DPS)
        libmetawear.mbl_mw_sensor_fusion_write_config(self.device.board)
        libmetawear.mbl_mw_sensor_fusion_enable_data(self.device.board, cbindings.SensorFusionData.QUATERNION);

        libmetawear.mbl_mw_gyro_bmi160_start(self.device.board)
        libmetawear.mbl_mw_acc_start(self.device.board)
        libmetawear.mbl_mw_sensor_fusion_start(self.device.board);
[{x : -0.325, y : 1.106, z : 0.938}, {w : 0.857, x : 0.430, y : 0.000, z : -604462909807314587353088.000}, {x : -1742.256, y : 605.122, z : 865.000}]
[{x : -0.279, y : 0.952, z : 0.899}, {w : 0.857, x : 0.426, y : 0.000, z : 524288.000}, {x : 1985.854, y : 1767.744, z : -291.707}]
[{x : -0.128, y : 0.759, z : 0.735}, {w : 0.859, x : 0.418, y : 0.000, z : -32.000}, {x : -1766.281, y : 1268.537, z : -1765.183}]
[{x : -0.011, y : 0.590, z : 0.622}, {w : 0.861, x : 0.406, y : 0.000, z : 0.000}, {x : 1857.500, y : 113.415, z : 940.915}]
[{x : -0.036, y : 0.495, z : 0.569}, {w : 0.863, x : 0.393, y : 0.000, z : 0.000}, {x : 0.000, y : 0.000, z : 0.000}]
[{x : -0.067, y : 0.511, z : 0.509}, {w : 0.866, x : 0.380, y : 0.000, z : 0.000}, {x : 619.268, y : -1135.671, z : 984.207}]
[{x : -0.057, y : 0.594, z : 0.406}, {w : 0.869, x : 0.368, y : 0.000, z : -36028797018963968.000}, {x : -776.281, y : 1174.878, z : -957.805}]
[{x : -0.058, y : 0.679, z : 0.386}, {w : 0.871, x : 0.356, y : 0.000, z : 8796093022208.000}, {x : 1990.854, y : 1798.964, z : 1080.061}]
[{x : -0.041, y : 0.752, z : 0.411}, {w : 0.872, x : 0.345, y : 0.000, z : -0.000}, {x : -275.610, y : 1768.049, z : 1976.464}]
[{x : -0.010, y : 0.843, z : 0.427}, {w : 0.872, x : 0.335, y : 0.000, z : 633825300114114700748351602688.000}, {x : -670.366, y : 1081.219, z : 789.085}]
[{x : -0.010, y : 0.873, z : 0.515}, {w : 0.871, x : 0.329, y : 0.000, z : -0.000}, {x : 1994.451, y : -1229.329, z : 1684.207}]
[{x : -0.037, y : 0.893, z : 0.660}, {w : 0.869, x : 0.328, y : 0.000, z : -0.000}, {x : 1991.890, y : 1049.695, z : 998.110}]
[{x : -0.052, y : 0.924, z : 0.763}, {w : 0.866, x : 0.332, y : 0.000, z : 0.000}, {x : 1738.537, y : 1081.219, z : -67.500}]
[{x : -0.135, y : 1.163, z : 1.537}, {w : 0.862, x : 0.338, y : 0.000, z : -2417851639229258349412352.000}, {x : 272.866, y : 7.134, z : -198.476}]
[{x : 0.172, y : 0.849, z : 0.895}, {w : 0.857, x : 0.344, y : 0.000, z : -32.000}, {x : 1238.902, y : 877.988, z : -28.659}]
[{x : 0.122, y : 0.754, z : 0.490}, {w : 0.854, x : 0.343, y : 0.000, z : 633825300114114700748351602688.000}, {x : -148.415, y : -963.659, z : 865.915}]

Additionally We're hoping to do this with three MMC parts. Do we run into the same limitations when using multiple parts, for example if we connect and subscribe to two devices, can we only hope for a maximum of 50hz from the fused data for each?

Comments

  • I'm attempting to stream essentially all of the data from the MMC at 100hz. I read in one of the forum posts that the device can't stream faster than 100hz, so if I want to subscribe to both accelerometer gyro, and mag, for example, the output would only be at 33hz from each, is that correct?

    Yes, that is correct.

    I'd like to set up the fuser example example with accel, gyro, mag, sensorfusion(quaternion), temperature, and baro to get them all reporting data as fast as possible.

    Because sensor fusion comes out at 100Hz only, you have to use our dataprocessors to downsample it to 25Hz and then do accel, gyro, and mag at 25Hz. This is not recommended. Normally you use sensor fusion OR raw sensor data.

  • Laura,

    Thanks for the prompt response. To clarify one more point, if I were to only stream raw sensor data (acc, gryo, mag) and used the fuser method, would I be able to get that data at 100hz, or since there are three streams involved, is it still only 33hz?

  • edited March 26

    You can push the data rates a little bit with the fuser but not much.
    Honestly the mag is slow so you should sample that slowly and try to fuse the acc + gyro as fast as possible
    Try things out and see what works.

  • edited March 30

    I'm trying to get my head around this as well. After looking at the fuser implementation in the C++ library source, I think I understand where you're coming from, Laura, but would like to confirm. Does the fuser's behavior of combining packet data occur on the computer consuming the BLE packets, rather than on the MMC itself?

    If so, it makes sense that--since the different data sources themselves aren't combined before being sent over BLE (i.e. accel data, gyro data, and mag data are each sent in their own packet)--there's still the same packet rate limitation as if the fuser wasn't used (100Hz by default, split among all sources).

    With that in mind, it seems like the only way to get data in this thread's scenario at the desired rate from multiple sensors would be to use the packed output mode for accel and gyro. They could then each sample at 100Hz but only send packets at around 33Hz. The magnetometer could be packed or not; it looks like its maximum effective sample rate at the highest power mode is only 20Hz, with most modes being only 10Hz.

  • The Fuser is on the MMC itself. But there are limitations.

Sign In or Register to comment.