Exemplo n.º 1
0
        // Update is called once per frame
        private void Update()
        {
            manus_hand_t leftHand;
            manus_hand_t rightHand;

            _leftRet  = Manus.ManusGetHand(session, device_type_t.GLOVE_LEFT, out leftHand);
            _rightRet = Manus.ManusGetHand(session, device_type_t.GLOVE_RIGHT, out rightHand);
            // if the retrieval of the handdata is succesfull update the local value and wether the hand is closed
            if (_leftRet == manus_ret_t.MANUS_SUCCESS)
            {
                _leftHand = leftHand;
                UpdateCloseValue(TotalAverageValue(_leftHand), device_type_t.GLOVE_LEFT);
            }

            if (_rightRet == manus_ret_t.MANUS_SUCCESS)
            {
                _rightHand = rightHand;
                UpdateCloseValue(TotalAverageValue(_rightHand), device_type_t.GLOVE_RIGHT);
            }

            if (Input.GetKeyDown(AutomaticCalibration))
            {
                Calibrate(device_type_t.GLOVE_LEFT);
                Calibrate(device_type_t.GLOVE_RIGHT);
                Debug.Log("Calibrated the hands with the Vive trackers");
            }

            ManualWristRotation();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the average value of all fingers combined on the given hand
        /// </summary>
        /// <param name="hand"></param>
        /// <returns></returns>
        public double TotalAverageValue(manus_hand_t hand)
        {
            int    sensors = 0;
            double total   = 0;

            // Loop through all of the finger values
            for (int bendPosition = 0; bendPosition < 10; bendPosition++)
            {
                // Only get the sensor values of the first bending point without the thumb (1,3,5,7)
                if (bendPosition < 8)
                {
                    sensors++;
                    total += hand.raw.finger_sensor[bendPosition];

                    //TODO
                    //0,1 - pinky
                    //2,3 - kmitza
                    //4,5 - ama
                    //6,7 - finger
                    //0 is open - 1 is closed
                }
            }

            return(total / sensors);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the average value of the first joints without the thumb
        /// </summary>
        /// <param name="deviceType"></param>
        /// <returns></returns>
        public double FirstJointAverage(device_type_t deviceType)
        {
            manus_hand_t hand = deviceType == device_type_t.GLOVE_LEFT ? _leftHand : _rightHand;

            double total = hand.raw.finger_sensor[1];

            total += hand.raw.finger_sensor[3];
            total += hand.raw.finger_sensor[5];
            total += hand.raw.finger_sensor[7];
            return(total / 4);
        }
Exemplo n.º 4
0
 public bool CalculateIsPointing(manus_hand_t hand)
 {
     //if etzba is open
     if (Math.Abs(hand.raw.finger_sensor[6]) < 0.1 && Math.Abs(hand.raw.finger_sensor[7]) < 0.2)
     {
         //check that zeret,kmitsa,ama are closed
         if (Math.Abs(hand.raw.finger_sensor[1] - 1) < 0.3 && Math.Abs(hand.raw.finger_sensor[3] - 1) < 0.3 && Math.Abs(hand.raw.finger_sensor[5] - 1) < 0.3)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 5
0
        IEnumerator PlayRecording(List <manus_hand_t> handData, List <manus_ret_t> succeses, device_type_t deviceType)
        {
            while (true)
            {
                //Loop through data
                for (int i = 0; i < handData.Count; i++)
                {
                    yield return(new WaitForFixedUpdate());

                    if (succeses.Count > 0)
                    {
                        if (deviceType == device_type_t.GLOVE_LEFT)
                        {
                            _leftRet = succeses[i];
                        }
                        else
                        {
                            _rightRet = succeses[i];
                        }
                        if (succeses[i] != manus_ret_t.MANUS_SUCCESS)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        _leftRet  = manus_ret_t.MANUS_SUCCESS;
                        _rightRet = manus_ret_t.MANUS_SUCCESS;
                    }

                    var manusHandT = handData[i];

                    switch (deviceType)
                    {
                    case device_type_t.GLOVE_LEFT:
                        _leftHand = manusHandT;
                        UpdateCloseValue(TotalAverageValue(_leftHand), deviceType);
                        break;

                    case device_type_t.GLOVE_RIGHT:
                        _rightHand = manusHandT;
                        UpdateCloseValue(TotalAverageValue(_rightHand), deviceType);
                        break;
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get the average value of all fingers combined on the given hand
        /// </summary>
        /// <param name="hand"></param>
        /// <returns></returns>
        public double TotalAverageValue(manus_hand_t hand)
        {
            int    sensors = 0;
            double total   = 0;

            // Loop through all of the finger values
            for (int bendPosition = 0; bendPosition < 10; bendPosition++)
            {
                // Only get the sensor values of the first bending point without the thumb (1,3,5,7)
                if (bendPosition < 8)
                {
                    sensors++;
                    total += hand.raw.finger_sensor[bendPosition];
                }
            }

            return(total / sensors);
        }
        // Update is called once per frame
        private void Update()
        {
            manus_hand_t leftHand;
            manus_hand_t rightHand;

            _leftRet  = Manus.ManusGetHand(session, device_type_t.GLOVE_LEFT, out leftHand);
            _rightRet = Manus.ManusGetHand(session, device_type_t.GLOVE_RIGHT, out rightHand);
            // if the retrieval of the handdata is succesfull update the local value and wether the hand is closed
            if (_leftRet == manus_ret_t.MANUS_SUCCESS)
            {
                _leftHand = leftHand;
                UpdateCloseValue(TotalAverageValue(_leftHand), device_type_t.GLOVE_LEFT);
            }

            if (_rightRet == manus_ret_t.MANUS_SUCCESS)
            {
                _rightHand = rightHand;
                UpdateCloseValue(TotalAverageValue(_rightHand), device_type_t.GLOVE_RIGHT);
            }

            ManualWristRotation();
        }
Exemplo n.º 8
0
 public static extern manus_ret_t ManusGetHand_id(manus_session_t session, UInt32 dongle_id, device_type_t device_type, out manus_hand_t out_hand);
Exemplo n.º 9
0
 public static extern manus_ret_t ManusGetHand(manus_session_t session, device_type_t device_type, out manus_hand_t out_hand);