I’m moving on the series of Myo posts
- Getting started, #Windows10 configuration
- Starting as a developer with some C++ basic code
- MyoSharp a C# SDK implementation for the Myo armband
Today I’m going to talk about one of the coolest features in the armband: the gyroscope sensor. Maybe the best way to do this, is to show how easy is to control a 3D Cube using our arm in a natural way.
Note: I need to add some noise removal to the sample so the cube rotation is more natural.
Myo SDK provides a couple of elements which defines the orientation and location of our arm, this is know as Spatial Data. Spatial data informs the application about the orientation and movement of the user’s arm. The Myo SDK provides two kinds of spatial data:
- An orientation represents which way the Myo armband is pointed. In the SDK this orientation is provided as a quaternion that can be converted to other representations, like a rotation matrix or Euler angles.
- An acceleration vector represents the acceleration the Myo armband is undergoing at any given time. The SDK provides this as a three-dimensional vector.
For this sample, I’ll use the X, Y and Z values from the gyroscope and I’ll apply this value to a camera focused on a 3D Cube.
When the Main WPF Window is Loaded is time to
- create a Transform3DGroup to support the rotation in the 3 axis
- initialize the code to interact with the Myo armband and subscribe for the Gyroscope value changes
And then we get to the interactive section. Get the Gyroscope data and apply some camera rotation to the cube. In the Camera Rotation we need to manage some cross thread calling, because all the information we receive from the Myo is on a different thread.
Greetings @ Toronto