コード例 #1
0
    public void stimulate_C1_strong()
    {
        Debug.Log("Channel 1 Full intensity");
        // string array stimulation commands = convert stimulation command into an array of commands (split by spaces)
        IList commandList = channel1StrongCommand.Split(',').ToList();

        foreach (string command in commandList)
        {
            Debug.Log(command);

            // parse the stimulation command to get the duration

            // convert stimulation command from string into bytes
            byte[] stimulation_message = System.Text.Encoding.UTF8.GetBytes(command);
            // trigger stimulation with EMS device
            Debug.Log(openEMSstim.sendMessage(stimulation_message));

            // wait for duration
        }
    }
コード例 #2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            Debug.Log("Collision between " + other.ToString() + " and " + gameObject.ToString());

            // trigger stimulation with EMS device
            bool messageSent = openEMSstim.sendMessage(message_to_stimulate_this_player);
            //Debug.Log(messageSent);
        }
    }
コード例 #3
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            Debug.Log("Grabbable Object collision between " + other.ToString() + " and " + gameObject.ToString());

            // trigger stimulation with EMS device
            // bool messageSent = openEMSstim.sendMessage(message_to_stimulate_this_player);
            // Debug.Log(messageSent);

            var hand = isLeft ? GestureProvider.LeftHand : GestureProvider.RightHand;
            if (hand.gesture == GestureType.Fist)
            {
                Debug.Log("Hand gesture is fist, grabbing object");
                isGrabbed = true;
                // trigger stimulation with EMS device
                bool messageSent = openEMSstim.sendMessage(on_message_to_stimulate_this_player);
                Debug.Log("Starting move with ems now" + messageSent);
                StartMove();
            }
        }
    }
コード例 #4
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("point to" + other_player);
        if (other_player != null)
        {
            other_player.GetComponent <Points> ().points += 1;
            openEMSstim.sendMessage(message_to_stimulate_this_player);
        }

        if (ball != null)
        {
            ball.transform.position = new Vector2(0, 0);
            Vector2 dir = new Vector2(ball.GetComponent <Rigidbody2D>().velocity.x * -1, 0).normalized;
            ball.GetComponent <Rigidbody2D>().velocity = dir * 10;
        }
    }
コード例 #5
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            Debug.Log("Stefani collision with " + other.ToString() + " and " + gameObject.ToString());
            // anim.SetTrigger("touch");
            anim.SetBool("sleeping", true);

            Debug.Log("Alarm OFF: " + gameObject.ToString());
            sound.Pause();

            //Debug.Log("Alarm ON: " + gameObject.ToString());
            //sound.Play();

            // trigger stimulation with EMS device
            bool messageSent = openEMSstim.sendMessage(message_to_stimulate_this_player);
            //Debug.Log(messageSent);
        }
    }
コード例 #6
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            Debug.Log("Wall collision with " + other.ToString() + " and " + gameObject.ToString());
            foreach (string command in commandList)
            {
                Debug.Log(command);

                // parse the stimulation command to get the duration

                // convert stimulation command from string into bytes
                byte[] stimulation_message = System.Text.Encoding.UTF8.GetBytes(command);
                // trigger stimulation with EMS device
                Debug.Log(openEMSstim.sendMessage(stimulation_message));

                // wait for duration
            }
        }
    }
コード例 #7
0
    // Update is called once per frame
    void FixedUpdate()
    {
        /*
         * string commande = "C0I50T500G";
         * byte[] stimulation_messagee = System.Text.Encoding.UTF8.GetBytes(commande);
         * Debug.Log(openEMSstim.sendMessage(stimulation_messagee));
         */

        if (cutting)
        {
            foreach (string command in commandList)
            {
                Debug.Log(command);

                // parse the stimulation command to get the duration

                // convert stimulation command from string into bytes
                byte[] stimulation_message = System.Text.Encoding.UTF8.GetBytes(command);
                // trigger stimulation with EMS device
                Debug.Log(openEMSstim.sendMessage(stimulation_message));
                // wait for duration
            }
        }
    }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        // Get distance from markers
        mDist     = MotiveDirect.markerDistance;
        markerErr = MotiveDirect.lostMarker;
        mDistDiff = Mathf.Abs(mDist - mDistLast);
        if (Mathf.Abs(mDist - mDistLast) > 0.01)
        {
            mDistErr = true;
        }
        else
        {
            mDistErr = false;
        }

        mHand = GameObject.Find("Hand").transform;


        distBottleHand = Vector3.Distance(this.transform.position, mHand.transform.position);

        if (debug)
        {
            Debug.Log(mDist);
        }

        if (mDist < 0.067 && mDist != 0 && distBottleHand <= 0.15) // TODO: add distance hand-bottle
                                                                   //if (test)
        {
            transform.parent = mHand;
            this.gameObject.GetComponent <Rigidbody>().isKinematic = true;
            serialExo.dataOut = "150";
            grabOn            = true;

            // Avoids sending 2nd message which would desactivate EMS
            if (!emsOn)
            {
                serialEMS.sendMessage(System.Text.Encoding.UTF8.GetBytes("1q")); // Activate Ch1 and send intensity to max
                emsOn = true;
                //Debug.Log("Turning EMS On");
            }
        }
        else if (mDist > 0.1 && mDist < 0.15)
        {
            transform.parent = null;
            this.gameObject.GetComponent <Rigidbody>().isKinematic = false;
            serialExo.dataOut = "80";
            grabOn            = false;

            // Avoids sending 2nd message which would activate EMS
            if (emsOn)
            {
                serialEMS.sendMessage(System.Text.Encoding.UTF8.GetBytes("1")); // Desactivate EMS Ch1
                emsOn = false;
                //Debug.Log("Turning EMS Off");
            }
        }
        else
        {
            if (grabOn)
            {
                transform.parent = mHand;
                this.gameObject.GetComponent <Rigidbody>().isKinematic = true;
                serialExo.dataOut = "150";
                grabOn            = true;

                // Avoids sending 2nd message which would desactivate EMS
                if (!emsOn)
                {
                    serialEMS.sendMessage(System.Text.Encoding.UTF8.GetBytes("1q")); // Activate Ch1 and send intensity to max
                    emsOn = true;
                    //Debug.Log("Turning EMS On");
                }
            }
            else
            {
                transform.parent = null;
                this.gameObject.GetComponent <Rigidbody>().isKinematic = false;
                serialExo.dataOut = "80";
                grabOn            = false;

                // Avoids sending 2nd message which would activate EMS
                if (emsOn)
                {
                    serialEMS.sendMessage(System.Text.Encoding.UTF8.GetBytes("1")); // Desactivate EMS Ch1
                    emsOn = false;
                    //Debug.Log("Turning EMS Off");
                }
            }
        }

        mDistLast = mDist;
    }