private static void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e) { const float PI = (float)System.Math.PI; // convert the values to a 0-9 scale (for easier digestion/understanding) var roll = (int)((e.Roll + PI) / (PI * 2.0f) * 10); var pitch = (int)((e.Pitch + PI) / (PI * 2.0f) * 10); var yaw = (int)((e.Yaw + PI) / (PI * 2.0f) * 10); Console.Clear(); Console.WriteLine(@"Roll: {0}", roll); Console.WriteLine(@"Pitch: {0}", pitch); Console.WriteLine(@"Yaw: {0}", yaw); }
private static void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e) { const float PI = (float)System.Math.PI; var roll = (int)((e.Roll + PI) / (PI * 2.0f) * 10); var pitch = (int)((e.Pitch + PI) / (PI * 2.0f) * 10); var yaw = (int)((e.Yaw + PI) / (PI * 2.0f) * 10); Player.Volume(pitch); Player.Skip(roll); Console.SetCursorPosition(0, 4); Console.WriteLine("Volumen: " + pitch); Console.SetCursorPosition(0, 5); Console.WriteLine("Avanzar: " + roll); Console.SetCursorPosition(0, 7); Console.WriteLine(@"Roll: {0}", roll); Console.SetCursorPosition(0, 8); Console.WriteLine(@"Pitch: {0}", pitch); Console.SetCursorPosition(0, 9); Console.WriteLine(@"Yaw: {0}", yaw); }
public void GetMyo_ValidState_EqualsConstructorParameter() { // Setup var myo = new Mock<IMyo>(); var args = new OrientationDataEventArgs( myo.Object, DateTime.UtcNow, new QuaternionF(), 0, 0, 0); // Execute var result = args.Myo; // Assert Assert.Equal(myo.Object, result); }
/// <summary> /// Called when orientation data has been acquired from the Myo. /// </summary> /// <param name="evt">The pointer to the event.</param> /// <param name="timestamp">The timestamp of the event.</param> protected virtual void OnAcquiredOrientationData(IntPtr evt, DateTime timestamp) { var orientation = _myoDeviceDriver.GetEventOrientation(evt); this.Orientation = orientation; var handler = OrientationDataAcquired; if (handler != null) { var args = new OrientationDataEventArgs( this, timestamp, orientation, CalculateRoll(orientation), CalculatePitch(orientation), CalculateYaw(orientation) ); handler.Invoke(this, args); } }
/// <summary> /// Called when orientation data has been acquired from the Myo. /// </summary> /// <param name="evt">The pointer to the event.</param> /// <param name="timestamp">The timestamp of the event.</param> protected virtual void OnAcquiredOrientationData(IntPtr evt, DateTime timestamp) { // Contract.Requires<ArgumentException>(evt != IntPtr.Zero, "The event handle must be set."); var orientation = _myoDeviceDriver.GetEventOrientation(evt); this.Orientation = orientation; var handler = OrientationDataAcquired; if (handler != null) { var args = new OrientationDataEventArgs( this, timestamp, orientation, CalculateRoll(orientation), CalculatePitch(orientation), CalculateYaw(orientation) ); handler.Invoke(this, args); } }
public void GetOrientation_ValidState_EqualsConstructorParameter() { // Setup var orientationData = new QuaternionF(1, 2, 3, 4); var args = new OrientationDataEventArgs( new Mock<IMyo>().Object, DateTime.UtcNow, orientationData, 0, 0, 0); // Execute var result = args.Orientation; // Assert Assert.Equal(orientationData, result); }
public void GetYaw_ValidState_EqualsConstructorParameter() { // Setup var yaw = 1; var args = new OrientationDataEventArgs( new Mock<IMyo>().Object, DateTime.UtcNow, new QuaternionF(), 0, 0, yaw); // Execute var result = args.Yaw; // Assert Assert.Equal(yaw, result); }
public void GetTimestamp_ValidState_EqualsConstructorParameter() { // Setup var timestamp = DateTime.UtcNow; var args = new OrientationDataEventArgs( new Mock<IMyo>().Object, timestamp, new QuaternionF(), 0, 0, 0); // Execute var result = args.Timestamp; // Assert Assert.Equal(timestamp, result); }
public void GetRoll_ValidState_EqualsConstructorParameter() { // Setup var roll = 1; var args = new OrientationDataEventArgs( new Mock<IMyo>().Object, DateTime.UtcNow, new QuaternionF(), roll, 0, 0); // Execute var result = args.Roll; // Assert Assert.Equal(roll, result); }
public void GetPitch_ValidState_EqualsConstructorParameter() { // Setup var pitch = 1; var args = new OrientationDataEventArgs( new Mock<IMyo>().Object, DateTime.UtcNow, new QuaternionF(), 0, pitch, 0); // Execute var result = args.Pitch; // Assert Assert.Equal(pitch, result); }
private void OnOrientationData(object sender, OrientationDataEventArgs e) { if (_onReceive) { _orientation.PushQuat(e.Roll, e.Pitch, e.Yaw); if (_orientation.BufferFull) { string dir = _orientation.GetArmDirection(); if (dir != "") _currentPose = dir; _orientation.ClearBuffer(); } } }
//Contains all of the orientation data which is received private static void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e) { cachedEvent = e; //const float PI = (float)System.Math.PI; // Only needed if using conversion //Commented math will convert the values to a 0-9 scale (for easier digestion/understanding) var roll = e.Roll; //(int)((e.Roll + PI) / (PI * 2.0f) * 10); var pitch = e.Pitch; //(int)((e.Pitch + PI) / (PI * 2.0f) * 10); var yaw = e.Yaw; //(int)((e.Yaw + PI) / (PI * 2.0f) * 10); currentPitch = pitch; currentYaw = yaw; currentRoll = roll; //Console.WriteLine(@"Roll: {0}", roll); //Console.WriteLine(@"Pitch: {0}", pitch); //Console.WriteLine(@"Yaw: {0}", yaw); }