North (formerly Thalmic Labs), the creator of the Myo armband, was acquired by Google in June 2020. Myo sales ended in October 2018 and Myo software, hardware and SDKs are no longer available or supported. Learn more.
Part Four: Jump! Jump!
But first, this is the way for us to correctly calculate the delta between two radians:
function calculateDeltaRadians(currentYaw, centreYaw) local deltaYaw = currentYaw - centreYaw if (deltaYaw > PI) then deltaYaw = deltaYaw - TWOPI elseif(deltaYaw < -PI) then deltaYaw = deltaYaw + TWOPI end return deltaYaw end
Jump! Jump! Everybody Jump!
Flying left and right is pretty good of course, but there is another command we’re missing. Try nabbing one of these glowing green things:
Once you do, you’ll unlock a single-shot jump ability that you trigger with the spacebar:
What’s a good gesture for this action? We’re already using fist and fingers spread. Double tap is really for unlocking something. We haven’t used wave in/out yet, but we’re going to use them later too. Also, waving left or right doesn’t exactly scream “jump” to me.
Here’s the thing though: It doesn’t have to be left or right.
Try holding your arm out, rolling it 90(ish) degrees toward your body, and doing wave out. That “wave up” gesture feels kinda like a jump action to me. To be honest, wave in/down feels OK too. Rotating the other way also works, but to me feels a bit awkward. Let’s just do them all (though we’ll definitely exclude the standard wave left/right because you already know how to do that, and this is a useful technique. Hey, I’m here to teach you new things.)
The first thing we need to do is centre the roll value when we centre our yaw. We should also start keeping track of the change in roll in
onPeriodic. Retrieving roll works like you would expect. Use what you learned when implementing the rudder to calculate and store
deltaRoll in a global variable.
Once you’ve got that working, if you start logging the value of
deltaRoll you may notice something. The Myo armband doesn’t actually rotaate all that much before you are in the position to do a wave up or wave down. For me, it’s about .4-6 radians inward, and -1 outward. Not the consistent +/- 1.5ish radians (or 90 degrees) that you might expect. That’s, well, because of how arms work. If you watch the Myo logo while you rotate, you will see it doesn’t move nearly as much as your hand. Keep that in mind when you’re using rotation.
Try it yourself to see how it works for you. I’m going to consider the arm rotated whenever it’s passed .2 radians (about 10 degrees). Call that our roll deadzone. Then modify
onPoseEdge such that if the user does wave out or wave in and the absolute value of
deltaRoll is bigger than the roll deadzone, it triggers the Jump command.
On Monday, I’ll be back with the answer (and actually the whole script we’ve written to this point, in case you got lost). See you then!