Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            myHandController.IOpen(false);
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            myHandController.IResetHand();
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            myHandController.IClose(false);
        }
        if (Input.GetKeyDown(KeyCode.F))
        {
            myHandController.CloseSequence();
        }

        if (_commpleteOneComm)
        {
            SendMessageToServer($"{completeTimeList.Last()}");
            SendMessageToServer("206");
            _commpleteOneComm = false;
        }

        if (!_connected)
        {
            return;
        }
        if (!_serverCommandNew)
        {
            return;
        }
        UnityEngine.Debug.Log($"Gesture: {_serverCommand}");
        UnityEngine.Debug.Log($"Gesture MAV: {_serverMavCommand}");
        _serverCommandNew = false;

        switch (_serverCommand)
        {
        case 0:
            if (!myHandController.IsTesting && !myHandController.IsNullTesting)
            {
                return;
            }
            IntroText.text = myHandController.GestureIntroTest[MyHandController.GestureState.NoMovement];
            break;

        case 1:
        case 11:
            if (!myHandController.IsTesting && !myHandController.IsNullTesting)
            {
                return;
            }
            IntroText.text = myHandController.GestureIntroTest[MyHandController.GestureState.Close];
            myHandController.CloseSequence(_serverMavCommand);
            break;

        case 2:
        case 22:
            if (!myHandController.IsTesting && !myHandController.IsNullTesting)
            {
                return;
            }
            IntroText.text = myHandController.GestureIntroTest[MyHandController.GestureState.Open];
            myHandController.OpenSequence(_serverMavCommand);
            break;

        case 3:
        case 33:
            if (!myHandController.IsTesting && !myHandController.IsNullTesting)
            {
                return;
            }
            IntroText.text = myHandController.GestureIntroTest[MyHandController.GestureState.Supination];
            myHandController.SupinationAndPronation(true, _serverMavCommand);
            break;

        case 4:
        case 44:
            if (!myHandController.IsTesting && !myHandController.IsNullTesting)
            {
                return;
            }
            IntroText.text = myHandController.GestureIntroTest[MyHandController.GestureState.Pronation];
            myHandController.SupinationAndPronation(false, _serverMavCommand);
            break;

        case 5:
        case 55:
            if (!myHandController.IsTesting && !myHandController.IsNullTesting)
            {
                return;
            }
            IntroText.text = myHandController.GestureIntroTest[MyHandController.GestureState.Flexion];
            myHandController.FlexionAndExtension(true, _serverMavCommand);
            break;

        case 6:
        case 66:
            if (!myHandController.IsTesting && !myHandController.IsNullTesting)
            {
                return;
            }
            IntroText.text = myHandController.GestureIntroTest[MyHandController.GestureState.Extension];
            myHandController.FlexionAndExtension(false, _serverMavCommand);
            break;

        case 10:
            myHandController.IResetHand();
            break;

        case 202:
            myHandController.StartNullTesting();
            break;

        case 203:
            myHandController.StopNullTesting();
            break;

        case 204:
            _comCount++;
            if (!_isPreparing)
            {
                StartCoroutine(GestureCom(_comCount));
            }
            break;

        case 205:
            StartCoroutine(GestureCom(_commCommand));
            break;

        case 206:
            myHandController.SetTolerance(_commCommand);
            break;

        case 210:
            myHandController.ManualReset();
            break;
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!_connected)
        {
            return;
        }
        if (!_serverCommandNew)
        {
            return;
        }
        _serverCommandNew = false;
        switch (_serverCommand)
        {
        case 100:
            myHandController.IResetHand();
            IntroText.text = myHandController.GestureIntro[MyHandController.GestureState.NoMovement];
            break;

        case 101:
            IntroText.text = myHandController.GestureIntro[MyHandController.GestureState.Close];
            myHandController.IClose();
            break;

        case 102:
            IntroText.text = myHandController.GestureIntro[MyHandController.GestureState.Open];
            myHandController.IOpen();
            break;

        case 103:
            IntroText.text = myHandController.GestureIntro[MyHandController.GestureState.Supination];
            myHandController.ISupination();
            break;

        case 104:
            IntroText.text = myHandController.GestureIntro[MyHandController.GestureState.Pronation];
            myHandController.IPronation();
            break;

        case 105:
            IntroText.text = myHandController.GestureIntro[MyHandController.GestureState.Flexion];
            myHandController.IFlexion();
            break;

        case 106:
            IntroText.text = myHandController.GestureIntro[MyHandController.GestureState.Extension];
            myHandController.IExtension();
            break;

        case 1010:
            IntroText.text = "The Trainning Process is Over, Waitting for next process";
            myHandController.IResetHand();
            break;

        case 1011:
            StartTestScene();
            break;

        default:
            break;
        }
    }