private void OnTriggerEnter(Collider other) { if (other.gameObject.name.Contains("index") && other.gameObject.layer.Equals(12)) { if (Flag == true) { return; } fingerFlag = other.gameObject.name; leftIndexBending = leftPoseManager.CurHandRotationNormalized.Index.Bend.Value; float[] stiffnessArray = new float[5]; stiffnessArray[1] = Stiffness; float[] PositionSetPointArray = new float[5]; PositionSetPointArray[1] = leftIndexBending; bool[] InwardControlArray = new bool[5]; InwardControlArray[1] = InwardControl; Debug.Log("enter " + other.name); //Sending force feedback command to the client ClientController.ImpedanceControlFingers(AssignedID, targets, stiffnessArray, PositionSetPointArray, InwardControlArray); Debug.Log("hit"); //Stop force feedback after a given time, can be modified StartCoroutine(WaitAndReleaseForceFeedBack(ForceFeedbackLastTime)); //Force feedback can only be triggered once in 0.5 second Flag = true; StartCoroutine(WaitAndSetFlagFalse(0.5f)); } }
void KeyboardControll() { if (Input.GetKeyDown(KeyCode.U)) { Debug.Log("update impedance"); float[] stiffnessArray = new float[5]; stiffnessArray[1] = Stiffness; float[] PositionSetPointArray = new float[5]; PositionSetPointArray[1] = PositionSetPoint; bool[] InwardControlArray = new bool[5]; InwardControlArray[1] = InwardControl; ClientController.ImpedanceControlFingers(AssignedID, targets, stiffnessArray, PositionSetPointArray, InwardControlArray); isImpeding = true; } if (Input.GetKeyDown(KeyCode.I)) { if (constantForceApply) { return; } Debug.Log("start impending"); float[] stiffnessArray = new float[5]; stiffnessArray[1] = Stiffness; float[] PositionSetPointArray = new float[5]; PositionSetPointArray[1] = PositionSetPoint; bool[] InwardControlArray = new bool[5]; InwardControlArray[1] = InwardControl; ClientController.ImpedanceControlFingers(AssignedID, targets, stiffnessArray, PositionSetPointArray, InwardControlArray); isImpeding = true; } //constant force if (Input.GetKeyDown(KeyCode.C)) { Debug.Log("costant force impending"); constantForceApply = true; } /* No locking in current hardware * * if (Input.GetKeyDown(KeyCode.L)) * { * if (isLocked)//tofix * { * Debug.Log("stop locking"); * ClientController.StopContinuousLockFingers(AssignedID, targets);//tofix * isLocked = false;//tofix * } * else * { * * Debug.Log("start locking"); * ClientController.StopContinuousLockFingers(AssignedID, targets);//tofix; * isLocked = true;//tofix * } * } */ /* I can't understand what this testing is but it turns out makes no effect * * if (Input.GetKeyDown(KeyCode.T)) * { * if (isLatencyTesting) * { * * Debug.Log("stop testing"); * ClientController.StopImpedanceControlFingers(AssignedID, targets);//tofix * isLatencyTesting = false;//tofix * } * else * { * * Debug.Log("start testing"); * float[] stiffnessArray = new float[5]; * stiffnessArray[1] = Stiffness; * float[] PositionSetPointArray = new float[5]; * PositionSetPointArray[1] = PositionSetPoint; * bool[] InwardControlArray = new bool[5]; * InwardControlArray[1] = InwardControl; * ClientController.ImpedanceControlLatencyTest(AssignedID, targets, stiffnessArray, PositionSetPointArray, InwardControlArray); * isLatencyTesting = true; * } * } */ /*no viberating in current hardware * * if (Input.GetKeyDown(KeyCode.V)) * { * if (isVibrating)//tofix * { * Debug.Log("stop V-ing"); * ClientController.StopContinuousVibrateFingers(AssignedID, targets);//tofix * isVibrating = false;//tofix * } * else * { * * Debug.Log("start V-ing"); * ClientController.StartContinuousVibrateFingers(AssignedID, targets);//tofix; * isVibrating = true;//tofix * } * } */ }