Beispiel #1
0
    void didReceivePoseChange(string param)
    {
        Pose receivedPose = Pose.Unknown;

        for (int i = (int)Pose.Rest; i <= (int)Pose.Unknown; i++)
        {
            Pose currPose = (Pose)i;
            if (currPose.ToString().Equals(param))
            {
                receivedPose = currPose;
                break;
            }
        }
        //Update all myos for now because we don't have the myo id
        foreach (ThalmicMyo myo in ThalmicHub.instance._myos)
        {
            if (ThalmicHub.DidReceivePoseChange != null)
            {
                ThalmicHub.DidReceivePoseChange(null, receivedPose);
            }
            myo._myoPose = receivedPose;
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (myoRef == null) {
            myoRef = FindObjectOfType<ThalmicMyo> ();
        } else {

            Thalmic.Myo.Pose overriddenPose = POSE_OVERRIDES[myoRef.pose];

            if (overriddenPose != pose && poseDuration > MIN_POSE_DURATION)
            {
                byte[] output = new byte[1];
                output[0] = ANGLE_OPEN;

                switch (overriddenPose)
                {
                    case Thalmic.Myo.Pose.Rest:
                        output[0] = ANGLE_OPEN;
                        break;
                    case Thalmic.Myo.Pose.Fist:
                        output[0] = ANGLE_CLOSE;
                        break;
                }

                pose = overriddenPose;
                poseDuration = 0.0f;

                //send hand command
                Debug.Log("Pose: " + pose.ToString() + "\nActual: " + myoRef.pose.ToString() + "\nAngle: " + output[0]);
                stream.Write(output, 0, 1);
            }
            else
            {
                poseDuration += Time.deltaTime;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        Pose pose = myo == null ? Pose.Unknown : myo.pose;

        if (pose == lastPose && updateOnChange)
        {
            return;
        }

        if (pose != lastPose)
        {
            Debug.LogError("Pose: " + pose.ToString());
        }
        lastPose = pose;

        switch (pose)
        {
        case Pose.DoubleTap:
            //onDoubleTap ();
            if (onDoubleTap != null)
            {
                onDoubleTap(this.gameObject);
            }
            break;

        case Pose.FingersSpread:
            if (onFingerSpread != null)
            {
                onFingerSpread(this.gameObject);
            }
            break;

        case Pose.Fist:
            if (onFist != null)
            {
                onFist(this.gameObject);
            }
            break;

        case Pose.Rest:
            if (onRest != null)
            {
                onRest(this.gameObject);
            }
            break;

        case Pose.Unknown:
            break;

        case Pose.WaveIn:
            if (onWaveIn != null)
            {
                onWaveIn(this.gameObject);
            }
            break;

        case Pose.WaveOut:
            if (onWaveOut != null)
            {
                onWaveOut(this.gameObject);
            }
            break;
        }
    }