Ejemplo n.º 1
0
        public void ChannelEventReceived_Orientation_TriggersOrientationDataAcquiredEvent()
        {
            // Setup
            var routeEventArgs = new RouteMyoEventArgs(
                new IntPtr(123),
                new IntPtr(789),
                MyoEventType.Orientation,
                DateTime.UtcNow);

            var orientation = new QuaternionF(10, 20, 30, 40);

            var channelListener = new Mock <IChannelListener>(MockBehavior.Strict);

            var myoDeviceDriver = new Mock <IMyoDeviceDriver>(MockBehavior.Strict);

            myoDeviceDriver
            .SetupGet(x => x.Handle)
            .Returns(new IntPtr(123));
            myoDeviceDriver
            .Setup(x => x.GetEventOrientation(routeEventArgs.Event))
            .Returns(orientation);
            myoDeviceDriver
            .Setup(x => x.GetEventAccelerometer(routeEventArgs.Event))
            .Returns(new Vector3F());
            myoDeviceDriver
            .Setup(x => x.GetGyroscope(routeEventArgs.Event))
            .Returns(new Vector3F());

            var myo = Myo.Create(
                channelListener.Object,
                myoDeviceDriver.Object);

            OrientationDataEventArgs actualEventArgs = null;
            object actualSender = null;

            myo.OrientationDataAcquired += (sender, args) =>
            {
                actualSender    = sender;
                actualEventArgs = args;
            };

            // Execute
            channelListener.Raise(
                x => x.EventReceived += null,
                routeEventArgs);

            // Assert
            Assert.Equal(myo, actualSender);
            Assert.Equal(myo, actualEventArgs.Myo);
            Assert.Equal(routeEventArgs.Timestamp, actualEventArgs.Timestamp);
            Assert.Equal(orientation, actualEventArgs.Orientation);
            Assert.InRange(actualEventArgs.Roll, 2.03404385580104d, 2.03404385580106d);
            Assert.Equal(double.NaN, actualEventArgs.Pitch);
            Assert.InRange(actualEventArgs.Yaw, 2.31898255934001d, 2.31898255934003d);

            myoDeviceDriver.VerifyGet(x => x.Handle, Times.Once);
            myoDeviceDriver.Verify(x => x.GetEventOrientation(routeEventArgs.Event), Times.Once);
            myoDeviceDriver.Verify(x => x.GetEventAccelerometer(routeEventArgs.Event), Times.Once);
            myoDeviceDriver.Verify(x => x.GetGyroscope(routeEventArgs.Event), Times.Once);
        }
Ejemplo n.º 2
0
        private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            const float PI = (float)System.Math.PI;

            int nDev = 1; //10;
            // convert the values to a 0-9 scale (for easier digestion/understanding)
            float nRoll  = (float)((e.Roll + PI) / (PI * 2.0f) * nDev);
            float nPitch = (float)((e.Pitch + PI) / (PI * 2.0f) * nDev);
            float nYaw   = (float)((e.Yaw + PI) / (PI * 2.0f) * nDev);

            if (m_CTId0.Get() >= 1000)
            {
                m_CTId0.Set();
                //if (m_bFirst == true)
                //{
                //    m_afInitAngle[0] = e.Orientation.X;
                //    m_afInitAngle[1] = e.Orientation.Y;
                //    m_afInitAngle[2] = e.Orientation.W;
                //}
                float fX = (float)Math.Round(Ojw.CMath.R2D(e.Orientation.X - m_afInitAngle[0]), 3);
                float fY = (float)Math.Round(Ojw.CMath.R2D(e.Orientation.Y - m_afInitAngle[1]), 3);
                float fW = (float)Math.Round(Ojw.CMath.R2D(e.Orientation.W - m_afInitAngle[2]), 3);
                //float fSwing = (float)Math.Round(Ojw.CMath.R2D(e.Roll), 3);
                //float fTilt = (float)Math.Round(Ojw.CMath.R2D(e.Pitch), 3);
                //float fPan = (float)Math.Round(Ojw.CMath.R2D(e.Yaw), 3);
                //m_C3d.SetRobot_Rot(fPan - 90.0f, -fTilt, -fSwing);
                Ojw.CMessage.Write("[{6}]Roll[{0}], Pitch[{1}], Yaw[{2}] || X[{3}], Y[{4}], W[{5}]", nRoll, nPitch, nYaw, fX, fY, fW, e.Myo.Handle);
            }
        }
Ejemplo n.º 3
0
        private 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);

            //Check if the user has his arm down, as well as checking if the game has started and if its player move.
            if (roll <= 3 && pitch <= 3 && isPlayerMove == true && isGameStarted == true)
            {
                //Making sure player has enough rage to buff his ability
                if (playerRage >= 1)
                {
                    bufflbl.Invoke(new MethodInvoker(delegate { bufflbl.ForeColor = System.Drawing.Color.DeepSkyBlue; }));
                    playerBuffSound.Play();
                    updateBuffMove();
                    System.Threading.Thread.Sleep(500);
                    bufflbl.Invoke(new MethodInvoker(delegate { bufflbl.ForeColor = System.Drawing.Color.OrangeRed; }));
                }
                else
                {
                    statusLbl.Invoke(new MethodInvoker(delegate { statusLbl.Text = "You do not have enough rage to Buff!"; }));
                }
            }
        }
Ejemplo n.º 4
0
 private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
 {
     mainForm.myoOrientation[0].Add(e.Orientation.X);
     mainForm.myoOrientation[1].Add(e.Orientation.Y);
     mainForm.myoOrientation[2].Add(e.Orientation.Z);
     mainForm.myoOrientation[3].Add(e.Orientation.W);
 }
Ejemplo n.º 5
0
        private static void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            // convert the values from (-PI, PI) to a 0-255 scale
            double pitch = (e.Pitch + Math.PI) / (Math.PI * 2.0f) * 256.0f;
            double roll  = (e.Roll + Math.PI) / (Math.PI * 2.0f) * 256.0f;
            double yaw   = (e.Yaw + Math.PI) / (Math.PI * 2.0f) * 256.0f;

            if (double.IsNaN(initPitch))
            {
                initPitch = e.Pitch;
                initRoll  = e.Roll;
                initYaw   = e.Yaw;
            }

            double deltaPitch = initPitch - e.Pitch;
            double deltaRoll  = initRoll - e.Roll;
            double deltaYaw   = initYaw - e.Yaw;

            // convert the values from (-PI, PI) to a 0-255 scale
            byte deltaPitchByte = (byte)((e.Pitch + Math.PI) / (Math.PI * 2.0f) * 256.0f);
            byte deltaRollByte  = (byte)((e.Roll + Math.PI) / (Math.PI * 2.0f) * 256.0f);
            byte deltaYawByte   = (byte)((e.Yaw + Math.PI) / (Math.PI * 2.0f) * 256.0f);

            byte[] msgBytes = { deltaPitchByte, deltaRollByte, deltaYawByte };

            SendUDP(msgBytes);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Method called upon receiving the even myodata received. It passes on the orientation data to the UpdateOrientation class in Mainwindow
 /// </summary>
 /// <param name="e"></param>
 public void CalculateOrientation(OrientationDataEventArgs e)
 {
     orientationW = e.Orientation.W;
     orientationX = e.Orientation.X;
     orientationY = e.Orientation.Y;
     orientationZ = e.Orientation.Z;
     mWindow.UpdateOrientation(orientationW, orientationX, orientationY, orientationZ);
 }
Ejemplo n.º 7
0
        public void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            var         pose = HeldPose.Create(e.Myo, Pose.Fist, Pose.DoubleTap);
            const float PI   = (float)System.Math.PI;
            var         Roll = (e.Roll + PI) / (PI * 2.0f) * 100;
            string      data = "Roll: " + Roll.ToString() + Environment.NewLine;

            InvokeData(data);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the orientation changed event of the left arm.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void LeftArmOrientationChanged(object sender, OrientationDataEventArgs e)
        {
            var rollDegree     = e.Roll * 180f / Constants.Pi;
            var rollPercentage = (float)(65f / 100f * rollDegree) / 100f;

            _logger.Debug($"Roll percentage={rollDegree}");

            _vehicle.SetSteeringAngle(rollPercentage * -1f);
        }
Ejemplo n.º 9
0
        public MyoData buildRecordUsing(DataCollector data, DateTime AGOStamp, DateTime EMGStamp)
        {
            AccelerometerDataEventArgs Acc  = data.accelerometerData.First(X => X.Timestamp == AGOStamp);
            EmgDataEventArgs           Emg  = data.emgData.First(X => X.Timestamp == EMGStamp);
            OrientationDataEventArgs   Ori  = data.orientationData.First(X => X.Timestamp == AGOStamp);
            GyroscopeDataEventArgs     Gyro = data.gyroscopeData.First(X => X.Timestamp == AGOStamp);

            return(buildRecordUsing(Emg, Acc, Gyro, Ori));
        }
Ejemplo n.º 10
0
        void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            //Invoke Roll, Pitch, Yaw
            var    roll  = (e.Roll + 3.14) / (3.14 + 2.0f) * 100;
            var    pitch = (e.Pitch + 3.14) / (3.14 + 2.0f) * 100;
            var    yaw   = (e.Yaw + 3.14) / (3.14 + 2.0f) * 100;
            string data  = "Roll:  " + roll.ToString() + Environment.NewLine + "Pitch:  " + pitch.ToString() + Environment.NewLine + "Yaw:  " + yaw.ToString() + Environment.NewLine;

            InvokeData(data);
        }
Ejemplo n.º 11
0
        private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            OrientationChangedEventArgs args = new OrientationChangedEventArgs();

            args.OrientationW = e.Orientation.W;
            args.OrientationX = e.Orientation.X;
            args.OrientationY = e.Orientation.Y;
            args.OrientationZ = e.Orientation.Z;
            OnOrientationChanged(args);
        }
Ejemplo n.º 12
0
        public void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            var multiplier = (float)(10);
            var roll       = (float)(e.Roll * multiplier);
            var pitch      = (float)(e.Pitch * multiplier);
            var yaw        = (float)(e.Yaw * multiplier);

            abbSensor.axis1 = roll;
            abbSensor.axis2 = pitch;
            abbSensor.axis3 = yaw;
        }
Ejemplo n.º 13
0
		static void OnOrientationData(object sender, OrientationDataEventArgs e)
		{
			// Calculate Euler angles (roll, pitch, and yaw) from the unit quaternion.        
			double roll = Quaternion.Roll(e.Orientation);
			double pitch = Quaternion.Pitch(e.Orientation);
			double yaw = Quaternion.Yaw(e.Orientation);

			// Convert the floating point angles in radians to a scale from 0 to 18.
			roll_w = (int)((roll + (double)Math.PI) / (Math.PI * 2.0) * 18);
			pitch_w = (int)((pitch + (double)Math.PI / 2.0) / Math.PI * 18);
			yaw_w = (int)((yaw + (double)Math.PI) / (Math.PI * 2.0) * 18);
		}
Ejemplo n.º 14
0
        static void OnOrientationData(object sender, OrientationDataEventArgs e)
        {
            // Calculate Euler angles (roll, pitch, and yaw) from the unit quaternion.        
            double roll = Quaternion.Roll(e.Orientation);
            double pitch = Quaternion.Pitch(e.Orientation);
            double yaw = Quaternion.Yaw(e.Orientation);

            // Convert the floating point angles in radians to a scale from 0 to 18.
            roll_w = (int)((roll + (double)Math.PI) / (Math.PI * 2.0) * 18);
            pitch_w = (int)((pitch + (float)Math.PI / 2.0) / Math.PI * 18);
            yaw_w = (int)((yaw + (float)Math.PI) / (Math.PI * 2.0) * 18);
        }
Ejemplo n.º 15
0
        private void OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            if (streamData == true)
            {
                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);

                Publish("/i5/myo/orientation", roll.ToString() + "," + pitch.ToString() + "," + yaw.ToString());
            }
        }
Ejemplo n.º 16
0
        private void Myo2_OrientationDataAcquired(object sender, OrientationDataEventArgs f)
        {
            // list of poses available to be given actions to
            var pose = HeldPose.Create(f.Myo, Pose.Fist, Pose.DoubleTap);
            // gives a variable the value of pi(3.14...)
            const float PI = (float)System.Math.PI;
            // calculation for getting the value of the MYO's roll
            var Roll = (f.Roll + PI) / (PI * 2.0f) * 100;
            // gives the string the value of what the roll is and converts it to a string
            string data2 = "Roll: " + Roll.ToString() + Environment.NewLine;

            // calls the method while passing the data2 value to it
            InvokeData2(data2);
        }
Ejemplo n.º 17
0
        private static void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            var 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);
        }
Ejemplo n.º 18
0
 private void Myo_OrientationAcquired(object sender, OrientationDataEventArgs e)
 {
     if (_isRecording == true)
     {
         if ((DateTime.Now - lastExecutionOrientation).TotalSeconds >= 0.5)
         {
             CalculateOrientation(e);
             if (MainWindow.isRecordingData == true)
             {
                 SendData();
             }
             lastExecutionOrientation = DateTime.Now;
         }
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Method called upon receiving the even myodata received. It passes on the orientation data to the UpdateOrientation class in Mainwindow
        /// </summary>
        /// <param name="e"></param>
        public void CalculateOrientation(OrientationDataEventArgs e)
        {
            orientationW = e.Orientation.W;
            orientationX = e.Orientation.X;
            orientationY = e.Orientation.Y;
            orientationZ = e.Orientation.Z;
            mWindow.UpdateOrientation(orientationW, orientationX, orientationY, orientationZ);

            myoRoll = e.Roll;
            mWindow.UpdateRoll(myoRoll);
            myoPitch = e.Pitch;
            mWindow.UpdatePitch(myoPitch);
            myoYaw = e.Yaw;
            mWindow.UpdateYaw(myoYaw);
        }
Ejemplo n.º 20
0
        //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);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Handles the orientation changed event of the right arm.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void RightArmOrientationChanged(object sender, OrientationDataEventArgs e)
        {
            var pitchDegree = e.Pitch * 180 / Constants.Pi;

            _logger.Debug($"Pitch percentage={pitchDegree}");

            var absAcceleartion = (float)(70f / 100f * Math.Abs(pitchDegree)) / 100f;

            if (pitchDegree > 0)
            {
                Accelerate(absAcceleartion);
            }
            else if (pitchDegree < 0)
            {
                Brake(absAcceleartion);
            }
        }
Ejemplo n.º 22
0
        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();
                }
            }
        }
Ejemplo n.º 23
0
        private void Myo2_OrientationDataAcquired(object sender, OrientationDataEventArgs f)
        {
            var         pose  = HeldPose.Create(f.Myo, Pose.Fist, Pose.DoubleTap);
            const float PI    = (float)System.Math.PI;
            var         Roll  = (f.Roll + PI) / (PI * 2.0f) * 100;
            string      data2 = "Roll: " + Roll.ToString() + Environment.NewLine;

            InvokeData2(data2);
            var InitRoll = 50;

            if (f.Myo.Pose == Pose.DoubleTap)
            {
                this.Close();
            }
            if (f.Myo.Pose == Pose.Fist)
            {
                PlayerTwoMovement = 0;
            }
            else if (Roll <= InitRoll)
            {
                if (Player2.Location.X + Player2.Width > this.Width)
                {
                    PlayerTwoMovement = 0;
                }
                else
                {
                    SpeedOfPlayer     = 7;
                    PlayerTwoMovement = SpeedOfPlayer;
                }
                //PlayerOneMovement = SpeedOfPlayer;
            }
            else if (Roll >= InitRoll)
            {
                if (Player2.Location.X < 0)
                {
                    PlayerTwoMovement = 0;
                }
                else if (Player2.Location.X > 0)
                {
                    SpeedOfPlayer     = 7;
                    PlayerTwoMovement = -SpeedOfPlayer;
                }
            }
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
        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);
        }
Ejemplo n.º 30
0
        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);
        }
Ejemplo n.º 31
0
		static void OnOrientationDataAcquired(object sender, OrientationDataEventArgs e)
		{
			var args = new OrientationChangedEventArgs(MyoDevice.OrientationChangedEvent, sender, e.Myo, e.TimeStamp, e.Orientation);
			RaiseEvent(MyoDevice.OrientationChangedEvent, args);
		}
Ejemplo n.º 32
0
        private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
        {
            if (e.Myo.Arm == Arm.Left)
            {
                m_bLeft = true;


                const float PI = (float)System.Math.PI;

                int nDev = 1; //10;
                // convert the values to a 0-9 scale (for easier digestion/understanding)
                float fRoll  = (float)((e.Roll + PI) / (PI * 2.0f) * nDev);
                float fPitch = (float)((e.Pitch + PI) / (PI * 2.0f) * nDev);
                float fYaw   = (float)((e.Yaw + PI) / (PI * 2.0f) * nDev);

                if (m_CTId0.Get() >= 1000)
                {
                    m_CTId0.Set();
                    Ojw.CMessage.Write("Pitch={0}", fPitch);
                    if (m_ER_Pose == Pose.FingersSpread)
                    {
                        if ((fPitch < 0.6f) && (fPitch >= 0.4f))
                        {
                            // 전진
                            Ojw.CMessage.Write("Forward");
                            m_nCommand = 1;
                            MoveForward();
                            //QWalk(_CNT_WALK, 0, ((chkQwm_SpeedUp.Checked == true) ? 1 : 0));
                        }
                        else if (fPitch >= 0.6f)
                        {
                            // 후진
                            Ojw.CMessage.Write("Backward");
                            m_nCommand = 2;
                            MoveBackward();
                            //QWalk(_CNT_WALK, 3, ((chkQwm_SpeedUp.Checked == true) ? 1 : 0));
                        }
                    }
                    else if (m_ER_Pose == Pose.Fist)
                    {
                        if (fPitch >= 0.6f)
                        {
                            //if (m_nCommand != 3)
                            {
                                Ojw.CMessage.Write("Stand up");
                                m_nCommand = 3;
                                //Ojw.CTimer.Wait(1000);
                                //ActionPlay("80");
                                //Stop();
                                MoveTurnLeft();
                            }
                        }
                        else if (fPitch < 0.4f)
                        {
                            if (m_nCommand != 4)
                            {
                                Ojw.CMessage.Write("have a seat");
                                m_nCommand = 4;
                                //Ojw.CTimer.Wait(1000);
                                //ActionPlay("40");
                                MoveTurnRight();// Stop();
                            }
                        }
                        else
                        {
                            Stop(); // QWalk_Stop(0); // Stop
                        }
                    }
                    else if (m_ER_Pose == Pose.WaveOut)
                    {
                        if (m_nCommand != 5)
                        {
                            Ojw.CMessage.Write("Right");
                            m_nCommand = 5;
                            MoveLeft();
                            //QWalk(_CNT_WALK, 1, ((chkQwm_SpeedUp.Checked == true) ? 1 : 0)); // Right
                        }
                    }
                    else if (m_ER_Pose == Pose.WaveIn)
                    {
                        if (m_nCommand != 6)
                        {
                            Ojw.CMessage.Write("Left");
                            m_nCommand = 6;
                            MoveRight();// MoveLeft();
                            //QWalk(_CNT_WALK, 2, ((chkQwm_SpeedUp.Checked == true) ? 1 : 0));
                        }
                    }
                }

                m_fR_Roll  = fRoll;
                m_fR_Pitch = fPitch;
                m_fR_Yaw   = fYaw;
            }
            else if (e.Myo.Arm == Arm.Right)
            {
                m_bRight = true;


                const float PI = (float)System.Math.PI;

                int nDev = 1; //10;
                // convert the values to a 0-9 scale (for easier digestion/understanding)
                float fRoll  = (float)((e.Roll + PI) / (PI * 2.0f) * nDev);
                float fPitch = (float)((e.Pitch + PI) / (PI * 2.0f) * nDev);
                float fYaw   = (float)((e.Yaw + PI) / (PI * 2.0f) * nDev);

                m_fL_Roll  = fRoll;
                m_fL_Pitch = fPitch;
                m_fL_Yaw   = fYaw;
            }
        }
Ejemplo n.º 33
0
 protected void OnOrientationData(object sender, OrientationDataEventArgs e)
 {
     lock (myLock)
         currentOrientation = e.Orientation;
 }
Ejemplo n.º 34
0
 protected virtual void OnOrientationData(OrientationDataEventArgs e)
 {
     var handler = OrientationData;
     if (handler != null) handler(this, e);
 }