Erratic sensor fusion data when using accounter count

Hi all,

I am trying to use the accounter (count mode) to get sample counts from my sensor fusion data packets to be able to better reconstruct the timestamps. I referred to the tutorials and example code and am able to get the packet number but my output values become very erratic when implementing this. I tried to use the count mode with raw acceleration data as well to see if it was potentially something to do with the sensor fusion packet size and had similar results (the data read incorrect/erratic values). I have successfully used the accounter to get reconstructed timestamps with raw accelerometer data, but this cannot be used with sensor fusion due to packet size.

I am able to stream euler angles fine off the MetaBase app and off my own python code that does not use the accounter processor, it is when I try to use the accounter (count mode) that I start getting erratic data

Here is an example of the sensor fusion euler output when i try to use the accounter count processor:
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 198286819328.000, roll : 2040491614993935165595126861922304.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 214342615040.000, roll : 1838261730176275443887605928689664.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 235637096448.000, roll : 1555971787137951609041808833642496.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 258806431744.000, roll : 1247690055034791929944229726388224.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 288461258752.000, roll : 1075190538200609900918686160519168.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 330916003840.000, roll : 977046651886064952724683592040448.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 367054127104.000, roll : 894530520627458645121007567765504.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 400063299584.000, roll : 804725398417540018458725500059648.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 80531185664.000, roll : 13693241011827848259304981568421888.000, yaw : -0.000}
DA:6A:BD:93:6C:FA -> {heading : -0.000, pitch : 6657697.500, roll : 20487910977755869148682684836045914112.000, yaw : -0.000}

I have also attached my python script. Please let me know if there is something I am missing or where this issue may be stemming from.

Thanks in advance.

Board Information - MMR
Model number: 5
Firmware:1.5.0
Hardware 0.4

Host Device Information
MetaHub (raspberry pi running Raspbian (stretch))

Comments

  • It looks like you are not parsing the incoming data correctly now that it has the accounter in the packet and not just the euler data.

  • I was passing the data to the parse value function to extract the roll, pitch and yaw, can this not be used with euler data when there is additional accounter data in the packet?

  • Here is my code on how i have set up the data processor and how I am trying to parse the data. A similar method works fine for only the sensor fusion data, but its when i add the accounter count processor that my data outputted from the parse value function does not make sense.

    class State:
        def __init__(self, device):
            self.device = device
            self.samples_received = 0
            self.callback = FnVoid_VoidP_DataP(self.data_handler)
            self.data_list = []
            self.processor = None
    
    
        def data_handler(self, ctx, data):
            print("%s -> %s" % (self.device.address, parse_value(data)))
    
            euler_components = parse_value(data)
            self.roll = euler_components.roll
            self.pitch = euler_components.pitch
            self.yaw = euler_components.yaw
            self.epoch = data.contents.epoch
            self.sample = cast(data.contents.extra, POINTER(c_uint8)).contents.value
    
            self.data_list.append([self.epoch, self.roll, self.pitch, self.yaw, self.sample])
            self.samples_received+= 1
    
    
        def setup(self):
            libmetawear.mbl_mw_settings_set_connection_parameters(self.device.board, 30, 30, 0, 6000)
            sleep(1.5)
    
            e = Event()
    
            def processor_created(context, pointer):
                self.processor = pointer
                e.set()
    
            fn_wrapper = FnVoid_VoidP_VoidP(processor_created)
    
            libmetawear.mbl_mw_sensor_fusion_set_mode(self.device.board, SensorFusionMode.NDOF);
            libmetawear.mbl_mw_sensor_fusion_set_acc_range(self.device.board, SensorFusionAccRange._8G)
            libmetawear.mbl_mw_sensor_fusion_set_gyro_range(self.device.board, SensorFusionGyroRange._2000DPS)
            libmetawear.mbl_mw_sensor_fusion_write_config(self.device.board)
    
    
            signal = libmetawear.mbl_mw_sensor_fusion_get_data_signal(self.device.board, SensorFusionData.EULER_ANGLE);
            libmetawear.mbl_mw_dataprocessor_accounter_create_count(signal, None ,fn_wrapper)
            e.wait()
            libmetawear.mbl_mw_datasignal_subscribe(self.processor, None, self.callback)
    
        def start(self):
            libmetawear.mbl_mw_sensor_fusion_enable_data(self.device.board, SensorFusionData.EULER_ANGLE);
            libmetawear.mbl_mw_sensor_fusion_start(self.device.board);
    
  • Where do you handle the counter value?

  • within the data handler callback
    self.sample = cast(data.contents.extra, POINTER(c_uint8)).contents.value

  • edited June 2020

    That must not be working since everything else works fine. Not sure exactly why.

    You might want to print the raw data (the sensor data packet in hex/bytes - don't parse it) and see which bytes are which.

    Then make sure self.sample is actually getting the accumulator bytes and parsing it from the data:

    **self.sample** = cast(**data**.contents.extra, POINTER(c_uint8)).contents.value
    

    Basically I don't think the right bytes are getting parsed correctly in your data_handler function:

    def data_handler(self, ctx, data):
    
Sign In or Register to comment.