thalmiclabs / myo-bluetooth

The BLE specification of the Myo armband
Apache License 2.0
136 stars 72 forks source link

Quaternion definition in BLE Header and SDK differ #4

Closed vroland closed 8 years ago

vroland commented 9 years ago

I noticed that the quaternion definition in this header and in the Myo SDK is different:

/// Orientation data, represented as a unit quaternion. Values are multiplied by MYOHW_ORIENTATION_SCALE.
    struct MYOHW_PACKED {
        int16_t w, x, y, z;
    } orientation;

While the SDK defines it as

/// Index into orientation data, which is provided as a quaternion.
/// Orientation data is returned as a unit quaternion of floats, represented as `w + x * i + y * j + z * k`.
typedef enum {
    libmyo_orientation_x = 0, ///< First component of the quaternion's vector part
    libmyo_orientation_y = 1, ///< Second component of the quaternion's vector part
    libmyo_orientation_z = 2, ///< Third component of the quaternion's vector part
    libmyo_orientation_w = 3, ///< Scalar component of the quaternion.
} libmyo_orientation_index;

This is either inconsistent or a even a bug, because using the SDK definition with the Bluetooth data instead gives reasonable results while using the BLE header definition seems to result in wrong data for me.

smngreenberg commented 8 years ago

Closing this out for now, further discussion about this can be found on the forums here. This is likely down to the specific matrix construction, as the order is correct in both places. Admittedly the fact that it's different between the BLE standard and the SDK can be confusing, but the documentation is correct.