Наследование: MonoBehaviour
Пример #1
0
    void OnGUI()
    {
        GUI.BeginGroup(new Rect(10, 10, 300, 500));

        if (GUILayout.Button("Present Pairing", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.PresentPairing();
        }

        if (GUILayout.Button("Attach to Adjacent", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.AttachToAdjacent();
        }

        if (GUILayout.Button("Vibrate Short", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
        }

        if (GUILayout.Button("Vibrate Medium", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.VibrateForLength(MyoVibrateLength.MEDIUM);
        }

        if (GUILayout.Button("Vibrate Long", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.VibrateForLength(MyoVibrateLength.LONG);
        }

        GUILayout.Label("Myo Quaternion: " + myoRotation.ToString(), GUILayout.MinWidth(300), GUILayout.MinHeight(30));

        GUILayout.Label("Myo Pose: " + myoPose.ToString(), GUILayout.MinWidth(300), GUILayout.MinHeight(30));

        GUI.EndGroup();
    }
Пример #2
0
    IEnumerator attach()
    {
        //if (!MyoManager.GetIsAttached())
        //{
        //    MyoManager.AttachToAdjacent();
        //    yield return new WaitForSeconds(2);
        //    if (!MyoManager.GetIsAttached())
        //    {
        //        MyoManager.AttachToAdjacent();
        //        yield return new WaitForSeconds(2);
        //        if (!MyoManager.GetIsAttached())
        //        {
        //            MyoManager.AttachToAdjacent();
        //            yield return new WaitForSeconds(2);
        //            if (!MyoManager.GetIsAttached())
        //            {
        //                MyoManager.AttachToAdjacent();

        //            }

        //        }

        //    }
        //}
        yield return(new WaitForSeconds(5));

        MyoManager.AttachToAdjacent();
    }
Пример #3
0
    IEnumerator isWOHold()
    {
        if (myoPose == MyoPose.WAVE_OUT)
        {
            yield return(new WaitForSeconds(0.5f));

            if (myoPose == MyoPose.WAVE_OUT)
            {
                yield return(new WaitForSeconds(0.5f));

                if (myoPose == MyoPose.WAVE_OUT)
                {
                    yield return(new WaitForSeconds(0.5f));

                    if (myoPose == MyoPose.WAVE_OUT)
                    {
                        yield return(new WaitForSeconds(0.5f));

                        if (myoPose == MyoPose.WAVE_OUT)
                        {
                            yield return(new WaitForSeconds(0.5f));

                            if (myoPose == MyoPose.WAVE_OUT)
                            {
                                MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
                                mainScript.TapControl();
                                locked = !locked;
                                StartCoroutine("registerClavo");
                            }
                            else
                            {
                                mainScript.Adelante();
                            }
                        }
                        else
                        {
                            mainScript.Adelante();
                        }
                    }
                    else
                    {
                        mainScript.Adelante();
                    }
                }
                else
                {
                    mainScript.Adelante();
                }
            }
            else
            {
                mainScript.Adelante();
            }
        }
        else
        {
            mainScript.Adelante();
        }
    }
Пример #4
0
    IEnumerator isWIHold()
    {
        if (myoPose == MyoPose.WAVE_IN)
        {
            yield return(new WaitForSeconds(0.5f));

            if (myoPose == MyoPose.WAVE_IN)
            {
                yield return(new WaitForSeconds(0.5f));

                if (myoPose == MyoPose.WAVE_IN)
                {
                    yield return(new WaitForSeconds(0.5f));

                    if (myoPose == MyoPose.WAVE_IN)
                    {
                        yield return(new WaitForSeconds(0.5f));

                        if (myoPose == MyoPose.WAVE_IN)
                        {
                            yield return(new WaitForSeconds(0.5f));

                            if (myoPose == MyoPose.WAVE_IN)
                            {
                                MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
                                mainScript.TapControl();
                                locked = !locked;
                                registerScript.calibrarBroca();
                            }
                            else
                            {
                                mainScript.Atras();
                            }
                        }
                        else
                        {
                            mainScript.Atras();
                        }
                    }
                    else
                    {
                        mainScript.Atras();
                    }
                }
                else
                {
                    mainScript.Atras();
                }
            }
            else
            {
                mainScript.Atras();
            }
        }
        else
        {
            mainScript.Atras();
        }
    }
Пример #5
0
    IEnumerator isFistHold()
    {
        if (myoPose == MyoPose.FIST)
        {
            yield return(new WaitForSeconds(0.5f));

            if (myoPose == MyoPose.FIST)
            {
                yield return(new WaitForSeconds(0.5f));

                if (myoPose == MyoPose.FIST)
                {
                    yield return(new WaitForSeconds(0.5f));

                    if (myoPose == MyoPose.FIST)
                    {
                        yield return(new WaitForSeconds(0.5f));

                        if (myoPose == MyoPose.FIST)
                        {
                            yield return(new WaitForSeconds(0.5f));

                            if (myoPose == MyoPose.FIST)
                            {
                                MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
                                mainScript.TapControl();
                                locked = !locked;
                                StartCoroutine("registerFemur");
                            }
                            else
                            {
                                mainScript.SelectMyo();
                            }
                        }
                        else
                        {
                            mainScript.SelectMyo();
                        }
                    }
                    else
                    {
                        mainScript.SelectMyo();
                    }
                }
                else
                {
                    mainScript.SelectMyo();
                }
            }
            else
            {
                mainScript.SelectMyo();
            }
        }
        else
        {
            mainScript.SelectMyo();
        }
    }
Пример #6
0
        private void AddMyo(object sender, RoutedEventArgs e)
        {
            MyoManager myoManager = new MyoManager();

            myoManager.OnConnect    += OnMyoConnect;
            myoManager.OnDisconnect += OnMyoDisconnect;
            myoManager.Connect();
        }
Пример #7
0
 /// <summary>
 /// Read the string message received
 /// </summary>
 /// <param name="s"></param>
 private void ReadStream(String s)
 {
     //if the string contains Myo vibrate myo
     if (s.Contains("Myo"))
     {
         MyoManager.PingMyo();
     }
 }
Пример #8
0
 void Update()
 {
     if (MyoManager.GetIsAttached())
     {
         myoRotation             = MyoManager.GetQuaternion();
         objectToRotate.rotation = myoRotation;
     }
 }
Пример #9
0
    void Update()
    {
        if (MyoManager.IsEnabled)
        {
            myoRotation = MyoManager.GetQuaternion();

            objectToRotate.rotation = myoRotation;
        }
    }
Пример #10
0
 void Start()
 {
     holded    = false;
     myoScript = GameObject.Find("MyoManager").GetComponent <MyoManager>();
     MyoManager.Initialize();
     StartCoroutine("attach");
     MyoManager.PoseEvent += OnPoseEvent;
     mainScript            = GameObject.Find("MainScript").GetComponent <Main>();
     registerScript        = GameObject.Find("main").GetComponent <register>();
 }
 void Update()
 {
     if (MyoManager.GetIsAttached())
     {
         myoRotation             = MyoManager.GetQuaternion();
         objectToRotate.rotation = myoRotation;
     }
     else
     {
         MyoManager.AttachToAdjacent();
     }
 }
Пример #12
0
 static void Main(string[] args)
 {
     mgr = new MyoManager();
     mgr.Init();
     //mgr.MyoConnected += Mgr_MyoConnected;
     //mgr.MyoLocked += Mgr_MyoLocked;
     //mgr.MyoUnlocked += Mgr_MyoUnlocked;
     //mgr.PoseChanged += Mgr_PoseChanged;
     //mgr.HeldPoseTriggered += Mgr_HeldPoseTriggered;
     //mgr.PoseSequenceCompleted += Mgr_PoseSequenceCompleted;
     mgr.MyoConnected += Mgr_MyoConnected1;
     mgr.StartListening();
     ReadKey();
 }
Пример #13
0
    void OnGUI()
    {
        GUI.BeginGroup(new Rect(10, 10, 300, 500));

        if (GUILayout.Button("Attach to Adjacent", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.AttachToAdjacent();
        }

        if (GUILayout.Button("Vibrate Short", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
        }

        if (GUILayout.Button("Vibrate Medium", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.VibrateForLength(MyoVibrateLength.MEDIUM);
        }

        if (GUILayout.Button("Vibrate Long", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
        {
            MyoManager.VibrateForLength(MyoVibrateLength.LONG);
        }

        if (!MyoManager.GetIsInitialized())
        {
            if (GUILayout.Button("Initialize MyoPlugin", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
            {
                MyoManager.Initialize();
            }
        }
        else
        {
            if (GUILayout.Button("Uninitialize MyoPlugin", GUILayout.MinWidth(300), GUILayout.MinHeight(50)))
            {
                MyoManager.Uninitialize();
            }
        }

        GUILayout.Label("Myo Quaternion: " + myoRotation.ToString(), GUILayout.MinWidth(300), GUILayout.MinHeight(30));

        GUILayout.Label("Myo Pose: " + myoPose.ToString(), GUILayout.MinWidth(300), GUILayout.MinHeight(30));

        GUILayout.Label("Initialized: " + MyoManager.GetIsInitialized(), GUILayout.MinWidth(300), GUILayout.MinHeight(30));

        GUILayout.Label("Attached: " + MyoManager.GetIsAttached(), GUILayout.MinWidth(300), GUILayout.MinHeight(30));

        GUI.EndGroup();
    }
Пример #14
0
 void Awake()
 {
     //Singelton from UnityPatterns.com (non existing anymore)
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         if (this != instance)
         {
             Destroy(this.gameObject);
         }
     }
 }
Пример #15
0
    IEnumerator registerFemur()
    {
        registerScript.registrarFemur0();
        yield return(new WaitForSeconds(5));

        registerScript.registrarFemur1();
        MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
        yield return(new WaitForSeconds(5));

        registerScript.registrarFemur2();
        MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
        yield return(new WaitForSeconds(5));

        registerScript.registrarFemur3();
        MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
    }
Пример #16
0
    IEnumerator registerClavo()
    {
        registerScript.registrarClavo0();
        yield return(new WaitForSeconds(5));

        registerScript.registrarClavo1();
        MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
        yield return(new WaitForSeconds(5));

        registerScript.registrarClavo2();
        MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
        yield return(new WaitForSeconds(5));

        registerScript.registrarClavo3();
        MyoManager.VibrateForLength(MyoVibrateLength.SHORT);
    }
    void Awake()
    {
        //Persist through level changes, only one singleton instance
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(this);
        }
        else
        {
            DestroyImmediate(this.gameObject);
            return;
        }

        //Enable compass to get Relative Quaternion
        Input.compass.enabled = true;
    }
Пример #18
0
 // Update is called once per frame
 void Update()
 {
     if (!MyoManager.GetIsAttached())
     {
     }
     else
     {
         if (myoPose != lastPose)
         {
             if (myoPose == MyoPose.DOUBLE_TAP)
             {
                 mainScript.TapControl();
                 locked   = !locked;
                 lastPose = myoPose;
             }
             if (myoPose == MyoPose.REST)
             {
                 lastPose = myoPose;
             }
             if (!locked)
             {
                 if (myoPose == MyoPose.FIST)
                 {
                     StartCoroutine("isFistHold");
                     lastPose = myoPose;
                 }
                 if (myoPose == MyoPose.FINGERS_SPREAD)
                 {
                     lastPose = myoPose;
                     mainScript.AbrirMenu();
                 }
                 if (myoPose == MyoPose.WAVE_OUT)
                 {
                     StartCoroutine("isWOHold");
                     lastPose = myoPose;
                 }
                 if (myoPose == MyoPose.WAVE_IN)
                 {
                     StartCoroutine("isWIHold");
                     lastPose = myoPose;
                 }
             }
         }
     }
 }
Пример #19
0
        /// <summary>
        /// Method for calculating the GripPressure. Iterate through each emg sensor pod in myo and assign 1 if RMS value is more than the threshold,
        /// else assign 0. When the RMS value of the Emg pod is more than threshold it means that the the emg recorded higher musvle potential.
        /// </summary>
        /// <param name="e"></param>
        private void CalculateGripPressure(double[] currentEmgValues, double emgThreshold)
        {
            //temp array that holds 1 or 0 for each of the myo pod to be added at the last
            int[] emgTension = new int[8];
            //temporary value that holds the value of grip pressure
            int gripEMG = 0;

            //iterate through all the emg pods and store 1/0  in emgTension[] depending on
            //if the RMS is more or less than threshold
            // 0 meaning no tension and 100 meaning lots of tension
            for (int i = 0; i <= 7; i++)
            {
                try
                {
                    if (currentEmgValues[i] >= emgThreshold)
                    {
                        emgTension[i] = 1;
                    }
                    else
                    {
                        emgTension[i] = 0;
                    }
                }
                catch
                {
                    Debug.WriteLine("Error Calculating GripPressure");
                }
            }

            //add all value from emgTension and assign it to gripEmg
            Array.ForEach(emgTension, delegate(int i) { gripEMG += i; });
            //assign it to grippressure
            GripPressure = gripEMG;
            //if the grip pressure is more than 5, or more than 5 pods return high potential readings
            if (gripEMG >= 4)
            {
                //vibrate myo
                if (ActivateMyo)
                {
                    MyoManager.PingMyo();
                }
                Debug.WriteLine("GripPressure = " + gripEMG);
            }
        }
Пример #20
0
 void Awake()
 {
     //Singelton from UnityPatterns.com (non existing anymore)
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         if (this != instance)
             Destroy(this.gameObject);
     }
 }
Пример #21
0
 void Start()
 {
     MyoManager.Initialize();
     MyoManager.PoseEvent += OnPoseEvent;
 }