Пример #1
0
        /// <summary>
        /// Initialize hand controller pairs corresponding to each of the hand model pairs
        /// configured in _handPool.HandPairs list. If any of the hand model in
        /// _handPool.HandPairs is not configured properly, its corresponding hand controller
        /// will be null and will not be updated afterwards.
        /// </summary>
        private void InitHandControllers()
        {
            _handModelCalibProfileManager = CalibrationProfileManager.Instance;
            _handControllerPairs          = new List <LeftRightPair <UnityHandController> >();
            _handControllers = new List <UnityHandController>();
            int n = _handPool.HandPairs.Count;
            int vrControllerPairNum = _vrControllerObjReferencePairs.Count;

            for (int i = 0; i < n; i++)
            {
                UnityHandRepresentation leftRep = _handPool.HandPairs[i].Left;
                UnityHandController     left    = null;
                if (leftRep.Initialized)
                {
                    HandModelCalibrationProfile profile =
                        _handModelCalibProfileManager.FindProfile(
                            leftRep.GraphicsHandModel.Hand);
                    left = new UnityHandController(false, leftRep, this);
                    GameObject vrControllerObj = i < vrControllerPairNum ?
                                                 _vrControllerObjReferencePairs[i].Left : null;

                    Debug.Log(leftRep.GraphicsHandModel.Hand + "+++++++++++++++");
                    Debug.Log(profile);
                    Debug.Log("_handModelCalibProfileManager" + _handModelCalibProfileManager);
                    //Debug.Log(vrControllerObj);
                    //Debug.Log(rightRep.BendInwardLocalDirection);

                    left.StartInit(profile, vrControllerObj,
                                   leftRep.BendInwardLocalDirection);
                    _handControllers.Add(left);
                }
                UnityHandRepresentation rightRep = _handPool.HandPairs[i].Right;
                UnityHandController     right    = null;
                if (rightRep.Initialized)
                {
                    HandModelCalibrationProfile profile =
                        _handModelCalibProfileManager.FindProfile(
                            rightRep.GraphicsHandModel.Hand);
                    right = new UnityHandController(true, rightRep, this);
                    GameObject vrControllerObj = i < vrControllerPairNum ?
                                                 _vrControllerObjReferencePairs[i].Right : null;

                    right.StartInit(profile, vrControllerObj,
                                    rightRep.BendInwardLocalDirection);
                    _handControllers.Add(right);
                }
                LeftRightPair <UnityHandController> pair =
                    new LeftRightPair <UnityHandController>(left, right);
                _handControllerPairs.Add(pair);
            }
        }
Пример #2
0
 private float GetJointSplitAngle(UnityHandController hand, UnityHandRepresentation rep, int finger, int joint)
 {
     if (isReady)
     {
         var value       = hand.GetCurrentFingerRotationInfo().Fingers[finger].Split.Value;
         var handProfile = profileMgr.FindProfile(rep.GraphicsHandModel.Hand);
         if (handProfile != null)
         {
             var angle = handProfile.Fingers[finger].Joints[joint].SplitAngleExtreme * value;
             return(angle);
         }
     }
     return(0);
 }
Пример #3
0
    /* private float GetJointRotationAngle(UnityHandController hand, UnityHandRepresentation rep, int finger, int joint)
     * {
     *  if (isReady)
     *  {
     *      var value = hand.GetCurrentFingerRotationInfo().Thumb.Rotate.Value;
     *      var handProfile = profileMgr.FindProfile(rep.GraphicsHandModel.Hand);
     *      if (handProfile != null)
     *      {
     *          //                var angle = handProfile.Fingers[finger].Joints[joint]. value;\
     *          return 8;
     *      }
     *  }
     *  return 0;
     * }*/

    private float GetForceIndex(UnityHandController hand, UnityHandRepresentation rep)
    {
        if (isReady)
        {
            var handProfile = profileMgr.FindProfile(rep.GraphicsHandModel.Hand);
            //float currentForce = 0;
            if (handProfile != null)
            {
                var value = hand.Index.GetCollisionInfoOnTouch().FingerImpControlInfo.Stiffness;
                //var value = hand.GetCollisionInfoOnTouch().FingerImpControlInfo.Stiffness;
                return(value);
            }
        }
        return(0);
    }
Пример #4
0
    private void FindController()
    {
        if (isReady)
        {
            return;
        }
        controller = DexmoController.Instance;
        profileMgr = CalibrationProfileManager.Instance;

        if (controller != null && profileMgr != null)
        {
            isReady   = true;
            leftHand  = controller.HandControllerPairs[0].Left;
            rightHand = controller.HandControllerPairs[0].Right;
            leftRep   = controller.HandPool.HandPairs[0].Left;
            rightRep  = controller.HandPool.HandPairs[0].Right;
        }
    }
Пример #5
0
        /// <summary>
        /// Keyboard shortcuts for debug purpose.
        /// </summary>
        private void KeyboardCommandToDexmo()
        {
            if (LibdexmoClientController == null || !LibdexmoClientController.Connected)
            {
                return;
            }
            if (Input.GetKeyDown(KeyCode.S))
            {
                SwitchHandPositionAndAttitudeReference();
            }

            if (Input.GetKeyDown(KeyCode.R))
            {
                foreach (UnityHandController handController in _handControllers)
                {
                    if (handController.Active)
                    {
                        int assignedId = handController.DeviceInfo.AssignedId;
                        ImpedanceControlStopAllFingers(assignedId);
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.U))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMax(bounds, -0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.I))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMax(bounds, 0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.J))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMin(bounds, -0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.K))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMin(bounds, 0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.T))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMax(bounds, -0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.Y))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMax(bounds, 0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.G))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMin(bounds, -0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.H))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    BoundaryValue bounds = handRep.HandRotationBounds.Fingers[0].BendRotationBounds;
                    ModifyHandRotationBoundsMin(bounds, 0.1f);
                }
            }
            if (Input.GetKeyDown(KeyCode.Alpha0))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Right;
                if (handRep != null)
                {
                    int n = 5;
                    for (int i = 0; i < n; i++)
                    {
                        BoundaryValue bounds = handRep.HandRotationBounds.Fingers[i].BendRotationBounds;
                        bounds.RestoreToDefault();
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.Alpha9))
            {
                UnityHandRepresentation handRep = _handPool.HandPairs[0].Left;
                if (handRep != null)
                {
                    int n = 5;
                    for (int i = 0; i < n; i++)
                    {
                        BoundaryValue bounds = handRep.HandRotationBounds.Fingers[i].BendRotationBounds;
                        bounds.RestoreToDefault();
                    }
                }
            }
        }