Last edit: Jan. 15, 2016 03:05 AM
by ManarI also would be interested in something like that!
Hello everyone, anyone have a code sample that allows me to control a servo using a Myo on Arduino ?Thanks…
Last edit: Jan. 18, 2016 04:03 AM
by valentinrol
You can get the Myo Orientation as a quaternion, then just extract your x and y movements. Just look up the formulas. I did something like that with matrices, see https://github.com/vroland/MyoIMUGestureController .Using this data to control a servo shouldn't be that hard, Arduino has a “Servo” library.
/**
* convert a myo unit quaternion to a 3x3 matrix
* http://www.cprogramming.com/tutorial/3d/quaternions.html
*/
void unit_quaternion_to_matrix(Matrix33 &matrix, int16_t* quat) {
//convert the raw data in unit quaternion of floats.
float x = clip((float)quat / (MYOHW_ORIENTATION_SCALE), -.999999, .999999);
float y = clip((float)quat / (MYOHW_ORIENTATION_SCALE), -.999999, .999999);
float z = clip((float)quat / (MYOHW_ORIENTATION_SCALE), -.999999, .999999);
float w = clip((float)quat / (MYOHW_ORIENTATION_SCALE), -.999999, .999999);
matrix = 1-2*y*y-2*z*z;
matrix = 2*x*y-2*w*z;
matrix = 2*x*z+2*w*y;
matrix = 2*x*y+2*w*z;
matrix = 1-2*x*x-2*z*z;
matrix = 2*y*z-2*w*x;
matrix = 2*x*z-2*w*y;
matrix = 2*y*z+2*w*x;
matrix = 1-2*x*x-2*y*y;
}