Ejemplo n.º 1
0
 private void Hub_MyoDisconnected(object sender, MyoEventArgs e)
 {
     e.Myo.OrientationDataAcquired -= myoData.Myo_OrientationDataAcquired;
     e.Myo.EmgDataAcquired         -= myoData.Myo_EmgDataAcquired;
     e.Myo.SetEmgStreaming(false);
     timer.Stop();
 }
Ejemplo n.º 2
0
        private async void _myoHub_MyoConnected(object sender, MyoEventArgs e)
        {
            e.Myo.Vibrate(VibrationType.Long);
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                tblUpdates.Text = "Myo Connected: " + e.Myo.Handle;
            });

            // add the pose changed event here
            e.Myo.PoseChanged += Myo_PoseChanged;



            // unlock the Myo so that it doesn't keep locking between our poses
            e.Myo.Unlock(UnlockType.Hold);

            try
            {
                var sequence = PoseSequence.Create(e.Myo, Pose.FingersSpread, Pose.WaveIn);
                sequence.PoseSequenceCompleted += Sequence_PoseSequenceCompleted;
            }
            catch (Exception myoErr)
            {
                string strMsg = myoErr.Message;
            }
        }
Ejemplo n.º 3
0
        private void Myo_Locked(object sender, MyoEventArgs e)
        {
            var           braco = e.Myo.Arm == Arm.Right ? "Direito" : e.Myo.Arm == Arm.Left ? "Esquerdo" : "Desconhecido";
            MethodInvoker inv   = delegate { this.label5.Text = $"Braco {braco} bloqueado"; };

            this.Invoke(inv);
        }
Ejemplo n.º 4
0
        private void myoHub_MyoConnected(object sender, MyoEventArgs e)
        {
            m_CTId0.Set();
            Ojw.CMessage.Write("Myo [{0}, {1}, {2}] has connected!", e.Myo.Handle, e.Myo.XDirectionOnArm, e.Myo.Arm);

            e.Myo.Vibrate(VibrationType.Short); // 접속에 성공했으니 짧게 진동 출력


            e.Myo.Locked   += Myo_Locked;
            e.Myo.Unlocked += Myo_Unlocked;
            //e.Myo.Locked += new EventHandler<MyoEventArgs>(Myo_Locked);
            //e.Myo.Unlocked += new EventHandler<MyoEventArgs>(Myo_Unlocked);
            #region Pose(Edge - 자세가 변하는 순간에만 기록)
            e.Myo.PoseChanged += Myo_PoseChanged;
            #endregion Pose(Edge - 자세가 변하는 순간에만 기록)

            #region Pose(자세가 계속적으로 기록...)
            // setup for the pose we want to watch for
            m_myoPos = HeldPose.Create(e.Myo, Pose.Fist, Pose.FingersSpread, Pose.WaveIn, Pose.WaveOut, Pose.Rest);
            // set the interval for the event to be fired as long as
            // the pose is held by the user
            m_myoPos.Interval = TimeSpan.FromSeconds(0.5);

            m_myoPos.Start();
            m_myoPos.Triggered += Pose_Triggered;
            #endregion Pose(자세가 계속적으로 기록...)

            e.Myo.Unlock(UnlockType.Hold); // 이걸 마지막에 선언하면 Myo 가 내버려 두어도 Lock 이 되지 않는다.

            #region Orientation
            e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;
            #endregion Orientation
        }
Ejemplo n.º 5
0
        private void _hub_MyoConnected(object sender, MyoEventArgs e)
        {
            //When myo connects, unlock myo so the user can interact with it at all times.
            string status = "Myo is Connected";

            e.Myo.Unlock(UnlockType.Hold);

            //Create sequence for the rage ability (Fist -> Fingerspread).
            var sequence = PoseSequence.Create(
                e.Myo,
                Pose.Fist,
                Pose.FingersSpread);

            sequence.PoseSequenceCompleted += sequence_PoseSequenceCompleted;

            //Whenever pose is changed, go to poseChanged event.
            e.Myo.PoseChanged += Myo_PoseChanged;

            //Whenever orientation is changed, go to this event.
            e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;

            if (isConnectedLbl.InvokeRequired)
            {
                isConnectedLbl.Invoke(new MethodInvoker(delegate { isConnectedLbl.Text = status; }));
            }
        }
Ejemplo n.º 6
0
        private void _myoHub_MyoDisconnected(object sender, MyoEventArgs e)
        {
            UpdateUi("Myo disconnected");

            _MyoHub.MyoConnected    -= _myoHub_MyoConnected;
            _MyoHub.MyoDisconnected -= _myoHub_MyoDisconnected;
        }
Ejemplo n.º 7
0
        private void myoHub_MyoDisconnected(object sender, MyoEventArgs e)
        {
            e.Myo.SetEmgStreaming(false);
            e.Myo.EmgDataAcquired -= Myo_EmgDataAcquired;

            Ojw.CMessage.Write("Disconnected(Myo)");
        }
Ejemplo n.º 8
0
 // OnUnpair() is called whenever the Myo is disconnected from Myo Connect by the user.
 protected void OnUnpair(object sender, MyoEventArgs e)
 {
     lock (myLock)
     {
         myo   = null;
         onArm = false;
     }
 }
Ejemplo n.º 9
0
 private void Hub_MyoConnected(object sender, MyoEventArgs e)
 {
     e.Myo.Vibrate(VibrationType.Long);
     e.Myo.OrientationDataAcquired += myoData.Myo_OrientationDataAcquired;
     e.Myo.EmgDataAcquired         += myoData.Myo_EmgDataAcquired;
     e.Myo.SetEmgStreaming(true);
     timer.Start();
 }
Ejemplo n.º 10
0
        private void Myo_PoseChanged(object sender, MyoEventArgs e)
        {
            Ojw.CMessage.Write("{0} arm Myo detected {1} pose!", e.Myo.Arm, e.Myo.Pose);
            if (e.Myo.Arm == Arm.Left)
            {
                m_ER_Pose = e.Myo.Pose;

                if (m_ER_Pose == Pose.DoubleTap)
                {
                    //if (m_bCamera == false) Camera(true);
                    //else Camera(false);
                }
            }
            else if (e.Myo.Arm == Arm.Right)
            {
                m_EL_Pose = e.Myo.Pose;
                if (e.Myo.Pose == Pose.DoubleTap)
                {
                    Ready();
                }
                else
                {
                    if (m_nFistCommand == 0)
                    {
                        if (m_fL_Roll < 3)
                        {
                            if (e.Myo.Pose == Pose.FingersSpread)
                            {
                                Stop();
                            }
                            else if (e.Myo.Pose == Pose.WaveOut)
                            {
                                Move_Up();
                                //Ojw.CTimer.Wait(100);
                                //Hovering();
                            }
                            else if (e.Myo.Pose == Pose.Rest)
                            {
                                Hovering();
                            }
                        }
                    }

                    if (e.Myo.Pose == Pose.Fist)
                    {
                        m_nFistCommand = 1;
                    }
                    else
                    {
                        if (m_nFistCommand == 1)
                        {
                            Hovering();
                        }
                        m_nFistCommand = 0;
                    }
                }
            }
        }
Ejemplo n.º 11
0
 // OnUnpair() is called whenever the Myo is disconnected from Myo Connect by the user.    
 static void OnUnpair(object sender, MyoEventArgs e)
 {
     // We've lost a Myo.
     // Let's clean up some leftover state.
     roll_w = 0;
     pitch_w = 0;
     yaw_w = 0;
     onArm = false;
 }
Ejemplo n.º 12
0
        private void myoHub_MyoDisconnected(object sender, MyoEventArgs e)
        {
            MessageBox.Show("Myo is disconnected!", "Myo Armband");
            e.Myo.Vibrate(VibrationType.Long);

            e.Myo.EmgDataAcquired         -= Myo_EmgDataAcquired;
            e.Myo.OrientationDataAcquired -= Myo_OrientationDataAcquired;
            e.Myo.SetEmgStreaming(false);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles the Myo connected event by assigning event handlers.
        /// </summary>
        /// <param name="myoEventArgs"></param>
        private static void HandleMyoConnected(MyoEventArgs myoEventArgs)
        {
            _logger.Info($"Myo {myoEventArgs.Myo.Handle} has connected!");
            myoEventArgs.Myo.Vibrate(VibrationType.Short);

            myoEventArgs.Myo.PoseChanged += PoseChanged;
            myoEventArgs.Myo.Locked      += Locked;
            myoEventArgs.Myo.Unlocked    += Unlocked;
        }
Ejemplo n.º 14
0
        private void _hub_MyoDisconnected(object sender, MyoEventArgs e)
        {
            string status = "Myo has diconnected";

            if (isConnectedLbl.InvokeRequired)
            {
                isConnectedLbl.Invoke(new MethodInvoker(delegate { isConnectedLbl.Text = status; }));
            }
        }
Ejemplo n.º 15
0
		// OnUnpair() is called whenever the Myo is disconnected from Myo Connect by the user.    
		static void OnUnpair(object sender, MyoEventArgs e)
		{
			// We've lost a Myo.
			// Let's clean up some leftover state.
			roll_w = 0;
			pitch_w = 0;
			yaw_w = 0;
			onArm = false;
		}
Ejemplo n.º 16
0
 private void _myoHub_MyoDisconnected(object sender, MyoEventArgs e)
 {
     RhinoApp.WriteLine("Myo has Disconnected!");
     e.Myo.Locked                  -= new EventHandler <MyoEventArgs>(this.Myo_Locked);
     e.Myo.Unlocked                -= new EventHandler <MyoEventArgs>(this.Myo_Unlocked);
     e.Myo.PoseChanged             -= new EventHandler <PoseEventArgs>(this.Myo_PoseChanged);
     e.Myo.OrientationDataAcquired -= new EventHandler <OrientationDataEventArgs>(this.Myo_OrientationDataAcquired);
     e.Myo.GyroscopeDataAcquired   -= new EventHandler <GyroscopeDataEventArgs>(this.Myo_GyroscopeDataAcquired);
 }
Ejemplo n.º 17
0
 private void MyoDisconnected(object sender, MyoEventArgs e)
 {
     Console.WriteLine("Myo Disconnented!!");
     e.Myo.PoseChanged             -= OnPose;
     e.Myo.OrientationDataAcquired -= OnOrientationData;
     e.Myo.Locked   -= OnLocked;
     e.Myo.Unlocked -= OnUnlocked;
     //e.Myo.EmgDataAcquired -= OnEmgData;
     //e.Myo.SetEmgStreaming(false);
 }
Ejemplo n.º 18
0
        static void OnMyoConnected(object sender, MyoEventArgs e)
        {
            _myos.Add(e.Myo);
            e.Myo.AccelerometerDataAcquired += OnAccelerationDataAcquired;
            e.Myo.OrientationDataAcquired   += OnOrientationDataAcquired;

            var args = new MyoRoutedEventArgs(MyoDevice.ConnectedEvent, sender, e.Myo, e.TimeStamp);

            RaiseEvent(MyoDevice.ConnectedEvent, args);
        }
Ejemplo n.º 19
0
        private void myoHub_MyoConnected(object sender, MyoEventArgs e)
        {
            Ojw.CMessage.Write(String.Format("Myo {0} has connected!", e.Myo.Handle));
            e.Myo.Vibrate(VibrationType.Short);
            //e.Myo.Unlock(UnlockType.Hold);
            Ojw.CMessage.Write("Connected(Myo)");

            m_CTId.Set();
            e.Myo.EmgDataAcquired += Myo_EmgDataAcquired;
            e.Myo.SetEmgStreaming(true);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Handles the unlocked event by assigning the orientation handlers to the arms.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Unlocked(object sender, MyoEventArgs e)
 {
     if (e.Myo.Arm == Arm.Right)
     {
         e.Myo.OrientationDataAcquired += RightArmOrientationChanged;
     }
     if (e.Myo.Arm == Arm.Left)
     {
         e.Myo.OrientationDataAcquired += LeftArmOrientationChanged;
     }
 }
Ejemplo n.º 21
0
 private void MyoDisconnected(object sender, MyoEventArgs e)
 {
     Publish("/i5/myo/pose", "end");
     Publish("/i5/myo/orientation", "end");
     Publish("/i5/myo/full", "end");
     Publish("/i5/myo/gyroscope", "end");
     Publish("/i5/myo/accelerometer", "end");
     Publish("/i5/myo/emg", "end");
     OnDisconnect(this, new ConnectEventArgs("Success"));
     streamData = false;
 }
Ejemplo n.º 22
0
 private void MyoConnected(object sender, MyoEventArgs e)
 {
     Status = "Connected";
     e.Myo.AccelerometerDataAcquired += AccelerometerDataAcquired;
     e.Myo.SetEmgStreaming(true);
     e.Myo.EmgDataAcquired         += EmgDataAcquired;
     e.Myo.GyroscopeDataAcquired   += GyroscopeDataAcquired;
     e.Myo.OrientationDataAcquired += OrientationDataAcquired;
     e.Myo.PoseChanged             += PoseChanged;
     OnConnect(this, new ConnectEventArgs("Success"));
 }
Ejemplo n.º 23
0
        private async void _myoHub_MyoDisconnected(object sender, MyoEventArgs e)
        {
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                tblUpdates.Text = expGetures.Text + System.Environment.NewLine +
                                  "Myo disconnected";
            });

            _myoHub.MyoConnected    -= _myoHub_MyoConnected;
            _myoHub.MyoDisconnected -= _myoHub_MyoDisconnected;
        }
Ejemplo n.º 24
0
 private void myoHub_MyoDisconnected(object sender, MyoEventArgs e)
 {
     Ojw.CMessage.Write("Myo [{0}, {1}, {2}]접속해제", e.Myo.Handle, e.Myo.XDirectionOnArm, e.Myo.Arm);
     m_nCnt_Handle = 0;
     //m_abHandle[0] = false;
     //m_abHandle[1] = false;
     #region Sensor
     e.Myo.AccelerometerDataAcquired -= Myo_AccelerometerDataAcquired;
     e.Myo.GyroscopeDataAcquired     -= Myo_GyroscopeDataAcquired;
     //e.Myo.OrientationDataAcquired -= Myo_OrientationDataAcquired;
     #endregion Sensor
 }
Ejemplo n.º 25
0
        private void myoHub_MyoConnected(object sender, MyoEventArgs e)
        {
            mainForm.StatusLabel.Text = "Myo is connected and it is listening.";
            //MessageBox.Show("Myo is connected.\nPress OK to start listening.", "Myo Armband");
            e.Myo.Vibrate(VibrationType.Medium);

            e.Myo.EmgDataAcquired         += Myo_EmgDataAcquired;
            e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;
            e.Myo.SetEmgStreaming(true);

            //myoIsWorking = true;
        }
Ejemplo n.º 26
0
 private void Myo_PoseChanged(object sender, MyoEventArgs e)
 {
     Ojw.CMessage.Write("{0} arm Myo detected {1} pose!", e.Myo.Arm, e.Myo.Pose);
     if (e.Myo.Arm == Arm.Left)
     {
         Ojw.CMessage.Write("왼팔의 Myo 가 동작시 키실 동작을 여기에 넣는다.");
     }
     else if (e.Myo.Arm == Arm.Right)
     {
         Ojw.CMessage.Write("오른팔의 Myo 가 동작시 키실 동작을 여기에 넣는다.");
     }
     pose = Convert.ToString(e.Myo.Pose);
 }
Ejemplo n.º 27
0
 private void Myo_Unlocked(object sender, MyoEventArgs e)
 {
     e.Myo.Unlock(UnlockType.Hold);
     e.Myo.Vibrate(VibrationType.Short);
     if (Viewports.RiftViews[2] != null && Viewports.RiftViews[2].Document != null)
     {
         MyoController._myoUnlocked = true;
     }
     else
     {
         e.Myo.Lock();
         MyoController._myoUnlocked = false;
     }
 }
Ejemplo n.º 28
0
        void myoHub2_MyoConnected(object sender, MyoEventArgs f)
        {
            MessageBox.Show("Myo 2 is connected");  // lets the user know that the second MYO is connected

            f.Myo.Vibrate(VibrationType.Long);
            f.Myo.Unlock(UnlockType.Hold);  // keeps the MYO unlocked

            f.Myo.OrientationDataAcquired += Myo2_OrientationDataAcquired;

            var pose = HeldPose.Create(f.Myo, Pose.Fist, Pose.WaveIn, Pose.WaveOut);

            pose.Interval = TimeSpan.FromSeconds(0.5);
            pose.Start();
            // pose.Triggered += pose_Triggered;
        }
Ejemplo n.º 29
0
        public void GetMyo_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var myo = new Mock <IMyo>();

            var args = new MyoEventArgs(
                myo.Object,
                DateTime.UtcNow);

            // Execute
            var result = args.Myo;

            // Assert
            Assert.Equal(myo.Object, result);
        }
Ejemplo n.º 30
0
        private void myoHub_MyoConnected(object sender, MyoEventArgs e)
        {
            Ojw.CMessage.Write("Myo [{0}, {1}, {2}] has connected!", e.Myo.Handle, e.Myo.XDirectionOnArm, e.Myo.Arm);
            //m_abHandle[m_nCnt_Handle] = true;
            m_anHandle[m_nCnt_Handle] = e.Myo.Handle.ToInt32();
            e.Myo.Vibrate(VibrationType.Short); // 접속에 성공했으니 짧게 진동 출력

            #region Sensor
            e.Myo.AccelerometerDataAcquired += Myo_AccelerometerDataAcquired;
            e.Myo.GyroscopeDataAcquired     += Myo_GyroscopeDataAcquired;
            //e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;
            #endregion Sensor

            m_nCnt_Handle++;
        }
Ejemplo n.º 31
0
        public void GetTimestamp_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var timestamp = DateTime.UtcNow;

            var args = new MyoEventArgs(
                new Mock <IMyo>().Object,
                timestamp);

            // Execute
            var result = args.Timestamp;

            // Assert
            Assert.Equal(timestamp, result);
        }
Ejemplo n.º 32
0
		static void OnLostArm(object sender, MyoEventArgs e)
		{
			onArm = false;
		}
Ejemplo n.º 33
0
 protected virtual void OnUnlocked(MyoEventArgs e)
 {
     var handler = Unlocked;
     if (handler != null) handler(this, e);
 }
Ejemplo n.º 34
0
 protected virtual void OnArmUnsynced(MyoEventArgs e)
 {
     var handler = ArmUnsynced;
     if (handler != null) handler(this, e);
 }
Ejemplo n.º 35
0
 protected void OnLostArm(object sender, MyoEventArgs e)
 {
     lock (myLock)
         onArm = false;
 }
Ejemplo n.º 36
0
 private void OnMyoConnected(MyoEventArgs e)
 {
     var handler = MyoConnected;
     if(handler != null)
         handler(this, e);
 }
Ejemplo n.º 37
0
		static void OnMyoConnected(object sender, MyoEventArgs e)
		{
			_myos.Add(e.Myo);
			e.Myo.AccelerometerDataAcquired += OnAccelerationDataAcquired;
			e.Myo.OrientationDataAcquired += OnOrientationDataAcquired;

			var args = new MyoRoutedEventArgs(MyoDevice.ConnectedEvent, sender, e.Myo, e.TimeStamp);
			RaiseEvent(MyoDevice.ConnectedEvent, args);
		}
Ejemplo n.º 38
0
 // OnUnpair() is called whenever the Myo is disconnected from Myo Connect by the user.    
 protected void OnUnpair(object sender, MyoEventArgs e)
 {
     lock (myLock)
     {
         myo = null;
         onArm = false;
     }
 }
Ejemplo n.º 39
0
 protected virtual void OnDisconnected(MyoEventArgs e)
 {
     var handler = Disconnected;
     if (handler != null) handler(this, e);
 }