francocruces / MioConnect

MyoConnect alternative for the Myo Armband with OSC protocol
MIT License
22 stars 12 forks source link

Orientation Data Format #8

Open jaimovier opened 5 years ago

jaimovier commented 5 years ago

Orientation data is being sent with four values (i.e. /myo/orientation 1 -13912. 4767. -1452. 7074.)

It would be ideal to have this data formatted as the MyOSC application, with yaw, pitch and roll values.

jaimovier commented 5 years ago

The quaternion to euler values is not working correctly. The values are fixed or have jumps between positions.

MyOSC does the following calculations: https://github.com/benkuper/MyOSC/blob/e35961a54c19951e9c4569193b99501bb4deeec6/extension/debug/MyoController.ane/META-INF/ANE/MacOS-x86/MyoExtension/MyoExtension/MyoExtension.cpp

    // Calculate Euler angles (roll, pitch, and yaw) from the unit quaternion.
    double roll = atan2(2.0f * (quat.w() * quat.x() + quat.y() * quat.z()),
                        1.0f - 2.0f * (quat.x() * quat.x() + quat.y() * quat.y()));

    double pitch = asin(2.0f * (quat.w() * quat.y() - quat.z() * quat.x()));

    double yaw = atan2(2.0f * (quat.w() * quat.z() + quat.x() * quat.y()),
                       1.0f - 2.0f * (quat.y() * quat.y() + quat.z() * quat.z()));

myo-to-osc also makes this calculations: https://github.com/cpmpercussion/myo-to-osc/blob/master/myo_to_osc.py