/// <summary>
 /// Override operator []
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Finger this[FingerType id]
 {
     get
     {
         return(Fingers[id]);
     }
 }
Beispiel #2
0
        public void OnTransferredTriggerExit(Collider other, FingerType fingerType)
        {
//			if (this.transform.root == other.transform.root){ return; }

            if (!this.isGraspable(other))
            {
                return;
            }

            if (fingerType == FingerType.Left)
            {
                this.leftCollidingObjects.Remove(other.attachedRigidbody);
            }
            if (fingerType == FingerType.Right)
            {
                this.rightCollidingObjects.Remove(other.attachedRigidbody);
            }


            if (this.graspedRigidbody != null)
            {
                if (!this.leftCollidingObjects.Contains(this.graspedRigidbody) && !this.rightCollidingObjects.Contains(this.graspedRigidbody))
                {
                    this.Release();
                }
            }
        }
 /// <summary>
 /// Override operator []
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Finger this[FingerType id]
 {
     get
     {
         return Fingers[id];
     }
 }
 /// <summary>
 /// 填充输入按下事件
 /// </summary>
 /// <param name="fingerId"></param>
 /// <param name="postion"></param>
 /// <param name="fingerType"></param>
 /// <returns></returns>
 public InputPointDownGameEvent Fill(int fingerId, Vector2 postion, FingerType fingerType)
 {
     FingerId   = fingerId;
     Postion    = postion;
     FingerType = fingerType;
     return(this);
 }
Beispiel #5
0
        public void OnTransferredTriggerExit(Rigidbody targetRigidbody, FingerType fingerType)
        {
            if (!this.IsGraspable(targetRigidbody))
            {
                return;
            }

            if (fingerType == FingerType.Left)
            {
                this.leftCollidingObjects.Remove(targetRigidbody);
            }
            if (fingerType == FingerType.Right)
            {
                this.rightCollidingObjects.Remove(targetRigidbody);
            }

            if (this.graspedRigidbody != null)
            {
                if (!this.leftCollidingObjects.Contains(this.graspedRigidbody) && !this.rightCollidingObjects.Contains(this.graspedRigidbody))
                {
                    if (this.graspedRigidbody.constraints == RigidbodyConstraints.FreezeAll)
                    {
                        return;
                    }

                    this.Release();
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Constructs a finger.
 ///
 /// Generally, you should not create your own finger objects. Such objects will not
 /// have valid tracking data. Get valid finger objects from a hand in a frame
 /// received from the service.
 /// @since 3.0
 /// </summary>
 public Finger(long frameId,       //帧id
               int handId,
               int fingerId,       //指头id
               float timeVisible,
               Vector tipPosition, //指尖位置
               Vector direction,
               float width,
               float length,
               bool isExtended,
               FingerType type,
               Bone metacarpal,   //掌骨
               Bone proximal,     //近端骨
               Bone intermediate, //中间的骨头
               Bone distal        //末端骨头
               )
 {
     Type        = type;     //哪根手指
     bones[0]    = metacarpal;
     bones[1]    = proximal;
     bones[2]    = intermediate;
     bones[3]    = distal;
     Id          = (handId * 10) + fingerId;
     HandId      = handId;                 //手id
     TipPosition = tipPosition;            //指尖位置
     Direction   = direction;              //方向
     Width       = width;
     Length      = length;
     IsExtended  = isExtended;
     TimeVisible = timeVisible;
 }
Beispiel #7
0
 public Finger(FingerType fingerType, bool isExtended, float length, Joint tip, Joint dip, Joint mcp, Joint pip) : this(EfficioRuntimePINVOKE.new_Finger__SWIG_1((int)fingerType, isExtended, length, Joint.getCPtr(tip), Joint.getCPtr(dip), Joint.getCPtr(mcp), Joint.getCPtr(pip)), true)
 {
     if (EfficioRuntimePINVOKE.SWIGPendingException.Pending)
     {
         throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #8
0
 public Finger(int frameId,
               int handId,
               int fingerId,
               float timeVisible,
               Vector tipPosition,
               Vector tipVelocity,
               Vector direction,
               Vector stabilizedTipPosition,
               float width,
               float length,
               bool isExtended,
               Finger.FingerType type,
               Bone metacarpal,
               Bone proximal,
               Bone intermediate,
               Bone distal)
 {
     _type                  = type;
     _bones [0]             = metacarpal;
     _bones [1]             = proximal;
     _bones [2]             = intermediate;
     _bones [3]             = distal;
     _frameId               = frameId;
     _id                    = (handId * 10) + fingerId;
     _handID                = handId;
     _tipPosition           = tipPosition;
     _tipVelocity           = tipVelocity;
     _direction             = direction;
     _width                 = width;
     _length                = length;
     _isExtended            = isExtended;
     _isValid               = false;
     _stabilizedTipPosition = stabilizedTipPosition;
     _timeVisible           = timeVisible;
 }
        public ManagedFinger GetFinger(FingerType fingerType)
        {
            ManagedFinger finger = null;

            switch (fingerType)
            {
            case FingerType.Thumb:
                finger = Thumb;
                break;

            case FingerType.Index:
                finger = Index;
                break;

            case FingerType.Middle:
                finger = Middle;
                break;

            case FingerType.Ring:
                finger = Ring;
                break;

            case FingerType.Pinky:
                finger = Pinky;
                break;
            }

            return(finger);
        }
Beispiel #10
0
 /// <summary>
 /// Constructs a finger.
 ///
 /// Generally, you should not create your own finger objects. Such objects will not
 /// have valid tracking data. Get valid finger objects from a hand in a frame
 /// received from the service.
 /// @since 3.0
 /// </summary>
 public Finger(long frameId,
               int handId,
               int fingerId,
               float timeVisible,
               Vector tipPosition,
               Vector direction,
               float width,
               float length,
               bool isExtended,
               FingerType type,
               Bone metacarpal,
               Bone proximal,
               Bone intermediate,
               Bone distal)
 {
     Type        = type;
     bones[0]    = metacarpal;
     bones[1]    = proximal;
     bones[2]    = intermediate;
     bones[3]    = distal;
     Id          = (handId * 10) + fingerId;
     HandId      = handId;
     TipPosition = tipPosition;
     Direction   = direction;
     Width       = width;
     Length      = length;
     IsExtended  = isExtended;
     TimeVisible = timeVisible;
 }
Beispiel #11
0
    public void SetTipReference(FingerType ft, Transform t)
    {
        if ((int)ft > fingerCount - 1 && ft != FingerType.Thumb)
        {
            return;
        }

        if (ft == FingerType.Thumb)
        {
            thumbTip = t;
            _thumb.SetTipTransform(t);
        }
        else if (ft == FingerType.Index)
        {
            indexTip = t;
            _fingers[(int)ft].SetTipTransform(t);
        }
        else if (ft == FingerType.Middle)
        {
            middleTip = t;
            _fingers[(int)ft].SetTipTransform(t);
        }
        else if (ft == FingerType.Ring)
        {
            ringTip = t;
            _fingers[(int)ft].SetTipTransform(t);
        }
        else if (ft == FingerType.Pinky)
        {
            littleTip = t;
            _fingers[(int)ft].SetTipTransform(t);
        }
    }
Beispiel #12
0
 public Finger(int frameId,
                    int handId, 
                    int fingerId,
                    float timeVisible,
                    Vector tipPosition,
                    Vector tipVelocity,
                    Vector direction,
                    Vector stabilizedTipPosition,
                    float width,
                    float length,
                    bool isExtended,
                    Finger.FingerType type,
                    Bone metacarpal,
                    Bone proximal,
                    Bone intermediate,
                    Bone distal)
 {
     _type = type;
     _bones [0] = metacarpal;
     _bones [1] = proximal;
     _bones [2] = intermediate;
     _bones [3] = distal;
     _frameId = frameId;
     _id = (handId * 10) + fingerId;
     _handID = handId;
     _tipPosition = tipPosition;
     _tipVelocity = tipVelocity;
     _direction = direction;
     _width = width;
     _length = length;
     _isExtended = isExtended;
     _isValid = false;
     _stabilizedTipPosition = stabilizedTipPosition;
     _timeVisible = timeVisible;
 }
Beispiel #13
0
        /// <summary>
        /// Remove glitches from filtered data, returns smooth output
        /// </summary>
        /// <param name="_input">Input from filter</param>
        /// <param name="_anchor">Value to assign to, if fluctuation is small enough to be glitch</param>
        /// <param name="_fingerType">Current finger</param>
        private static float _removeGlitch(float _input, float _anchor, FingerType _fingerType)
        {
            // _fluc is fluctuation of new reading from previous
            float _fluc         = _input - _anchor;
            float _absFluc      = Mathf.Abs(_fluc);
            bool  _flucNegative = (Mathf.Sign(_fluc) == -1f);

            // movement is how many consecutive steps away in the same direction the fluctuation has gone
            float _mvmt          = tofMovements[(int)_fingerType];
            float _maxGlitchSize = 3f;

            if (_absFluc < 2)             // = max noise when resting
            {
                if (Mathf.Abs(_mvmt) < _maxGlitchSize)
                {
                    // Anchor if movement steps are consecutively small and random
                    _input = _anchor;
                    // Step movement based on glitch direction, only if glitch is big enough
                    _mvmt = (_absFluc > 1) ? (_flucNegative ? _mvmt - 1 : _mvmt + 1) : _mvmt;
                }
                else
                {
                    // If stepped enough in same direction, release anchor, until fluctuation in other direction again
                    _mvmt = (_mvmt < 0) ? ((_flucNegative) ? _mvmt : 0) : ((_flucNegative) ? 0 : _mvmt);
                }
            }
            tofMovements[(int)_fingerType] = _mvmt;
            return(_input);
        }
Beispiel #14
0
 public static string ToAttributeString(this FingerType _this)
 {
     if (_this < FingerType.Last)
     {
         return(_this.ToString());
     }
     throw new ArgumentException(_this.ToString());
 }
Beispiel #15
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="_fingerType">Type of finger</param>
        /// <param name="_learningGrasp">Type of grasp to learn</param>
        public GraspLearner(FingerType _fingerType, LearningGrasp _learningGrasp)
        {
            fingerType       = _fingerType;
            CurLearningGrasp = _learningGrasp;
            LearningActive   = true;

            Debug.Log(String.Format("{0} <color=blue> {1} </color> learning started...", fingerType, _learningGrasp));
        }
Beispiel #16
0
 float IHandSystem.GetFingerStrength(HandType handType, FingerType fingerType)
 {
     if (TryGetHand(handType, out IHand hand))
     {
         return(hand.GetFingerStrength(fingerType));
     }
     return(0);
 }
 public PointSkeleton3D GetSkeleton3DPosition(FingerType id)
 {
     if (this[id].TrackingState == FingerTrackingState.Tracked)
     {
         return(this[id].Position);
     }
     return(new PointSkeleton3D());
 }
Beispiel #18
0
 protected void ChangeImage(FingerType type)
 {
     foreach (var f in fingerImages)
     {
         f.SetActive(false);
     }
     fingerImages[(int)type].SetActive(true);
 }
Beispiel #19
0
        public Finger(Point _restPosition, int finger)
        {
            restPosition    = _restPosition;
            currentPosition = _restPosition;

            fingerID = (FingerType)finger;

            keySet = new List <char>();
        }
 public PointDepth3D GetDepth3DPosition(FingerType id)
 {
     if (this[id].TrackingState == FingerTrackingState.Tracked)
     {
         CoordinateMapperPlus mapper = new CoordinateMapperPlus(this.sensor);
         return mapper.MapSkeletonPointToDepthPoint(this[id].Position, this.sensor.DepthStream.Format);
     }
     return new PointDepth3D();
 }
 public Point2D GetPoint2Position(FingerType id)
 {
     if (this[id].TrackingState == FingerTrackingState.Tracked)
     {
         CoordinateMapperPlus mapper = new CoordinateMapperPlus(this.sensor);
         return(mapper.MapSkeletonPointToColorPoint(this[id].Position, this.sensor.ColorStream.Format));
     }
     return(new Point2D());
 }
Beispiel #22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="_fingerType">Type of finger</param>
 public GraspPredictor(FingerType _fingerType)
 {
     fingerType = _fingerType;
     RemapPredictionConsts[0] = new float[] { 0f, 1f, 0f, 1f };
     RemapPredictionConsts[1] = new float[] { -0.2f, 1.5f, -0.2f, 1f };
     RemapPredictionConsts[2] = new float[] { -0.2f, 1.5f, -0.2f, 1f };
     RemapPredictionConsts[3] = new float[] { -0.2f, 1.5f, -0.2f, 1f };
     RemapPredictionConsts[4] = new float[] { -0.2f, 1.5f, -0.2f, 1f };
 }
    void AttachObject(Rigidbody objectToAttach, FingerType holdingFinger1, FingerType holdingFinger2)
    {
        _lastForearmPosition = Parts.Forearm.transform.position;

        Parts.Fingers[(int)holdingFinger1].IsHoldingObject = Parts.Fingers[(int)holdingFinger2].IsHoldingObject = true;
        AttachedObject = objectToAttach.gameObject.AddComponent <AttachedObject>();
        AttachedObject.Attach(this, DetachObject);
        Parts.IgnoreCollisions(objectToAttach, true);

        OnObjectAttached(objectToAttach);
    }
Beispiel #24
0
 public FingerModalityAccessor(SideType side, FingerType finger)
 {
     this._side  = side;
     this.finger = finger;
     _joints     = new JointModalityAccessor[3];
     for (int i = 0; i < _joints.Length; ++i)
     {
         _joints[i] = new JointModalityAccessor(((FingerJointType)i).ToString());
         _subModalities.Add(_joints[i]);
     }
 }
Beispiel #25
0
 /// <summary>
 /// Issue the most general force feedback command to one finger.
 /// </summary>
 /// <param name="assignedId">ID of the the Dexmo device to be controlled.</param>
 /// <param name="fingerType">Type of the finger.</param>
 /// <param name="stiffness">Stiffness of the force feedback, with 0 being release command</param>
 /// <param name="positionSetpoint">Position setpoint from 0 to 1, related to the angle
 /// that finger starts to feel any force.</param>
 /// <param name="isInwardControl">Direction of the force. If set to true, fingers will feel
 /// force when they bend inwards (think of grasping).</param>
 public void ImpedanceControlFinger(int assignedId, FingerType fingerType,
                                    float stiffness, float positionSetpoint, bool isInwardControl)
 {
     if (LibdexmoClientController == null)
     {
         return;
     }
     if (LibdexmoClientController.Connected)
     {
         LibdexmoClientController.ImpedanceControlOneFinger(assignedId, fingerType, stiffness, positionSetpoint,
                                                            isInwardControl);
     }
 }
        public ManagedKeypoint GetKeypoint(FingerType fingerType, KeypointType keypointType)
        {
            if (keypointType == KeypointType.HandCenter)
            {
                return(HandCenter);
            }
            if (keypointType == KeypointType.Wrist)
            {
                return(WristCenter);
            }

            return(GetFinger(fingerType).GetKeypoint(keypointType));
        }
Beispiel #27
0
        /// <summary>
        /// 指定した指を動かす
        /// </summary>
        /// <param name="ft"></param>
        /// <param name="val">0-1</param>
        void FingerSeparateRotation(FingerType ft, float val)
        {
            //   val = Mathf.Clamp01(val);
            var _finger = FingerBoneMap[ft];

            foreach (var _obj in _finger.Keys)
            {
                mecanimBones[_obj].localRotation = Quaternion.Euler(Vector3.Lerp(Vector3.zero, _finger[_obj], val));
            }

            // 値を記憶
            FingerNowVal[(int)ft] = val;
        }
Beispiel #28
0
        private void UpdateHandRotationNormalizedInfo()
        {
            int n = _fingers.Length;

            for (int i = 0; i < n; i++)
            {
                IFingerRotationManager finger     = _fingers[i];
                FingerType             fingerType = finger.FingerType;
                float[] fingerRotation            = finger.GetCurrentJointRotation();
                _curHandRotationNormalized.UpdateFingerRotationNormalizedInfo(
                    fingerType, fingerRotation);
            }
        }
        public Transform[] GetFingerBones(FingerType fingerType)
        {
            switch (fingerType)
            {
            case FingerType.Thumb: return(thumb);

            case FingerType.Index: return(index);

            case FingerType.Middle: return(middle);

            case FingerType.Ring: return(ring);

            case FingerType.Little: return(little);
            }

            return(null);
        }
 public static string ToAttributeString(this HumanoidMuscleType _this)
 {
     if (_this < HumanoidMuscleType.Root)
     {
         int delta = _this - HumanoidMuscleType.Motion;
         return(nameof(HumanoidMuscleType.Motion) + GetTransformPostfix(delta % 7));
     }
     if (_this < HumanoidMuscleType.Limbs)
     {
         int delta = _this - HumanoidMuscleType.Root;
         return(nameof(HumanoidMuscleType.Root) + GetTransformPostfix(delta % 7));
     }
     if (_this < HumanoidMuscleType.Muscles)
     {
         int      delta = _this - HumanoidMuscleType.Limbs;
         LimbType limb  = (LimbType)(delta / 7);
         return(limb.ToBoneType().ToAttributeString() + GetTransformPostfix(delta % 7));
     }
     if (_this < HumanoidMuscleType.Fingers)
     {
         int        delta  = _this - HumanoidMuscleType.Muscles;
         MuscleType muscle = (MuscleType)delta;
         return(muscle.ToAttributeString());
     }
     if (_this < HumanoidMuscleType.TDoFBones)
     {
         const int armSize = (int)FingerType.Last * (int)FingerDoFType.Last;
         const int dofSize = (int)FingerDoFType.Last;
         int       delta   = _this - HumanoidMuscleType.Fingers;
         ArmType   arm     = (ArmType)(delta / armSize);
         delta = delta % armSize;
         FingerType finger = (FingerType)(delta / dofSize);
         delta = delta % dofSize;
         FingerDoFType dof = (FingerDoFType)delta;
         return($"{arm.ToBoneType().ToAttributeString()}.{finger.ToAttributeString()}.{dof.ToAttributeString()}");
     }
     if (_this < HumanoidMuscleType.Last)
     {
         const int    TDoFSize = (int)TDoFBoneType.Last;
         int          delta    = _this - HumanoidMuscleType.TDoFBones;
         TDoFBoneType tdof     = (TDoFBoneType)(delta / TDoFSize);
         return($"{tdof.ToBoneType().ToAttributeString()}{GetTDoFTransformPostfix(delta % TDoFSize)}");
     }
     throw new ArgumentException(_this.ToString());
 }
Beispiel #31
0
    // GameObjectの名前が指の名前のとき指タイプとボタンや回転軸を自動設定
    void AutoSetupFingerType()
    {
        FingerType type = FingerType.Custom;
        string     name = transform.name.ToLower();

        string[] typeNames = { "thumb", "index", "middle", "ring", "little" };
        int      typeIndex = (int)(name.Contains("j_bip_r")? FingerType.R_Thumb : FingerType.L_Thumb);

        for (int i = 0; i < typeNames.Length; i++)
        {
            if (name.IndexOf(typeNames[i]) >= 0)
            {
                type = (FingerType)(typeIndex + i);
                break;
            }
        }
        SetupFingerType(type);
    }
Beispiel #32
0
 void _PresetBoneLocation(BoneLocation boneLocation)
 {
     _isPresetted  = true;
     _boneLocation = boneLocation;
     _boneType     = ToBoneType(boneLocation);
     _boneSide     = ToBoneSide(boneLocation);
     if (_boneType == BoneType.HandFinger)
     {
         _fingerType  = ToFingerType(boneLocation);
         _fingerIndex = ToFingerIndex(boneLocation);
     }
     else
     {
         _fingerType  = FingerType.Unknown;
         _fingerIndex = -1;
     }
     _PresetLocalAxis();
 }
Beispiel #33
0
			void _PresetBoneLocation( BoneLocation boneLocation )
			{
				_isPresetted = true;
				_boneLocation = boneLocation;
				_boneType = ToBoneType( boneLocation );
				_boneSide = ToBoneSide( boneLocation );
				if( _boneType == BoneType.HandFinger ) {
					_fingerType = ToFingerType( boneLocation );
					_fingerIndex = ToFingerIndex( boneLocation );
				} else {
					_fingerType = FingerType.Unknown;
					_fingerIndex = -1;
				}
				_PresetLocalAxis();
			}
Beispiel #34
0
            /** 
                 @brief Return the data of the requested finger
                 @note This information is available only in full-hand tracking mode (TRACKING_MODE_FULL_HAND)
                 @see PXCHandConfiguration::SetTrackingMode
			
                 @param[in] fingerLabel - the ID of the requested finger.
                 @param[out] fingerData - the tracking data of the requested finger.
			
                 @return PXCM_STATUS_NO_ERROR - operation succeeded.
			
                 @see FingerType
                 @see FingerData
             */
            public pxcmStatus QueryFingerData(FingerType fingerLabel, out FingerData fingerData)
            {
                return QueryFingerDataINT(instance, fingerLabel, out fingerData);
            }
 public PointSkeleton3D GetSkeleton3DPosition(FingerType id)
 {
     if(this[id].TrackingState == FingerTrackingState.Tracked)
         return this[id].Position;
     return new PointSkeleton3D();
 }
 private void NotTracked(FingerType id)
 {
     Fingers[id].Position = new PointSkeleton3D();
     Fingers[id].TrackingState = FingerTrackingState.NotTracked;
 }
Beispiel #37
0
 private void Add(FingerType type, FingerIdentification Fingers)
 {
     if (Fingers[type].TrackingState == FingerTrackingState.Tracked)
     {
         Dict[type].Add(Fingers[type].Position);
     }
 }
 private void Tracked(FingerType id, PointSkeleton3D position)
 {
     //if (null != position)
     Fingers[id].Position = new PointSkeleton3D(position);
     Fingers[id].TrackingState = FingerTrackingState.Tracked;
 }
Beispiel #39
0
 private static extern pxcmStatus PXCMHandData_IHand_QueryFingerData(IntPtr instance, FingerType fingerLabel, [Out] FingerData fingerData);
Beispiel #40
0
 internal static pxcmStatus QueryFingerDataINT(IntPtr instance, FingerType fingerLabel, out FingerData fingerData)
 {
     fingerData = new FingerData();
     return PXCMHandData_IHand_QueryFingerData(instance, fingerLabel, fingerData);
 }
Beispiel #41
0
 public Finger(int id, FloatPoint3D positionInRealWorld, IntPoint3D positionInKinectPersp, FingerType fingerType, FingerState fingerState)
 {
     this.id = id;
     this.positionInKinectProj = positionInKinectPersp;
     this.positionInRealWorld = positionInRealWorld;
     this.fingerType = fingerType;
     this.fingerState = fingerState;
 }