Sensor Fusion Question

Two code examples:

A: https://pastebin.com/wJu4J95a
B: https://pastebin.com/2vtKrqNB

Both connect to a MetaWear device, subscribe to sensor fusion and print the raw data. The only difference is that example A only subscribes to the Euler angles, whereas B subscribes to both Euler and the corrected acceleration. What I don't understand is: the second one crashes with a "Bus Error" message - no explanation given. Example A runs perfectly.

What am I missing? And how should I get my corrected acceleration data if not like this?

Comments

  • You need to configure the bt connection for high frequency streaming:
    https://mbientlab.com/cppdocs/latest/advanced_features.html#high-frequency-streaming

    The "bus error" is most likely from some socket code used by the underling BT library.

    Your code is how to get corrected acceleration data though 2 sensor fusion outputs @ 100Hz each is not recommended over the BLE link.

  • How should I go about getting both Euler and corrected acceleration then?
    Calling

    libmetawear.mbl_mw_settings_set_connection_parameters(board, 7.5, 7.5, 0, 6000)
    

    Does not remove the bus error.

  • Reduce the streaming frequency or log the data.

    I haven't been able to reproduce the bus error on my openSUSE VM; I'll try on the Pi when I get it back. How long does your script run before it shows up?

  • How long does your script run before it shows up?

    T - 0 seconds.

    The combination of Euler + corrected acceleration isn't working, even at reduced speeds.
    However, the combination of Euler + Quaternion is working as expected.

  • For reference, this is a list of permutation that works:

    CORRECTED_GYRO
    CORRECTED_GYRO + CORRECTED_MAG
    CORRECTED_GYRO + QUATERNION
    CORRECTED_GYRO + EULER_ANGLE
    CORRECTED_MAG
    CORRECTED_MAG + QUATERNION
    CORRECTED_MAG + EULER_ANGLE
    QUATERNION
    QUATERNION + EULER_ANGLE
    EULER_ANGLE

    While these throw an uncatchable (by Python) Bus error.

    CORRECTED_ACC
    CORRECTED_ACC + CORRECTED_GYRO
    CORRECTED_ACC + CORRECTED_MAG
    CORRECTED_ACC + QUATERNION
    CORRECTED_ACC + EULER_ANGLE
    CORRECTED_ACC + GRAVITY_VECTOR
    CORRECTED_ACC + LINEAR_ACC
    CORRECTED_GYRO + GRAVITY_VECTOR
    CORRECTED_GYRO + LINEAR_ACC
    CORRECTED_MAG + GRAVITY_VECTOR
    CORRECTED_MAG + LINEAR_ACC
    QUATERNION + GRAVITY_VECTOR
    QUATERNION + LINEAR_ACC
    EULER_ANGLE + GRAVITY_VECTOR
    EULER_ANGLE + LINEAR_ACC
    GRAVITY_VECTOR
    GRAVITY_VECTOR + LINEAR_ACC
    LINEAR_ACC

    Meaning, that I can subscribe to CORRECTED_MAG + EULER_ANGLE at the same time, but not to CORRECTED_ACC + EULER_ANGLE. Is this intended behavior? MetaMotionR with latest firmware.

  • Well, clearly it's not intended that a bus error would be thrown if you attempt to subscribe to those specific combinations of sensor fusion signals.

    I narrowed down the cause of the bus error to these lines in the C++ code:
    https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/0.13.4/src/metawear/impl/cpp/datainterpreter.cpp#L222
    https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/0.13.4/src/metawear/impl/cpp/datainterpreter.cpp#L211

    For whatever reason, it doesn't seem like ARM appreciates typecasting the uint8_t* array to a MblMwCorrectedCartesianFloat*; the same code runs fine on x86 CPUs. I'll push a patch up today and you can try the updated C++ code to see if that fixes your issue.

  • Yes it's ARM. Raspberry PI 3 B+ to be exact.
    And no, it's still not working.

    Gyro, Magnet, Quater and Euler are working fine though. Even all four at the same time with (7.5, 7.5, 0, 6000) settings.

  • Did you update the libmetawear.so library with the latest release? The new C++ code works fine on my Pi3.

This discussion has been closed.