Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------------
        // Calibration

        /// <summary> Checks the calibration stage of this glove when it connects. </summary>
        protected virtual void CheckForCalibration()
        {
            if (this.checkCalibrationOnStart && SGCore.Calibration.HG_CalCheck.NeedsCheck(this.DeviceType))
            {
                SGCore.Calibration.SensorRange lastRange;
                if (SG_HandProfiles.LoadLastRange(this.lastGlove, out lastRange))
                {
                    //Debug.Log("Loaded Last Range: " + lastRange.ToString(true));
                    Debug.Log("Please move your " + (this.IsRight ? "right" : "left") + " hand so we can determine of calibration is required");
                    this.CalibrationStage = CalibrationStage.MoveFingers; //todo: Check for Nova or SenseGlove DK1
                    this.calibrationCheck = new HG_CalCheck(lastRange);
                }
                else
                {
                    //Debug.Log("There's no range from last time, so we start off with calibration regardless!");
                    this.CalibrationStage = CalibrationStage.CalibrationNeeded;
                }
            }
            else
            {
                this.CalibrationStage = CalibrationStage.Done;
            }
            //CalibrationLocked = this.CalibrationStage == CalibrationStage.Calibrating; //only locked if we're calibrating
            this.CalibrationStateChanged.Invoke();
        }
Exemplo n.º 2
0
 /// <summary> Retrieve flexion angles, normalized to [0...1] or [fingers extended ... fingers flexed] </summary>
 /// <param name="flexions"></param>
 /// <param name="forceUpdate"></param>
 /// <returns></returns>
 public virtual bool GetNormalizedFlexion(out float[] flexions, bool forceUpdate = false)
 {
     if (lastHandModel == null)
     {
         lastHandModel = SGCore.Kinematics.BasicHandModel.Default(this.IsRight);
     }
     //if (lastProfile == null) { lastProfile = SGCore.HandProfile.Default(this.IsRight); }
     return(GetNormalizedFlexion(lastHandModel, SG_HandProfiles.GetProfile(this.IsRight), out flexions, forceUpdate));
 }
Exemplo n.º 3
0
        /// <summary> Takes a sensor range taked from a Calibration sequence and calibrates the hand accordingly.. </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        public virtual bool CalibrateHand(SGCore.Calibration.SensorRange range)
        {
            SGCore.HandProfile newProfile;
            SGCore.Calibration.HG_CalibrationSequence.CompileProfile(range, this.DeviceType, this.IsRight, out newProfile);
            SG_HandProfiles.SetProfile(newProfile);

            //this.lastRange = new SGCore.Calibration.SensorRange(range); //deep copy
            if (SG_HandProfiles.SaveLastRange(range, this.lastGlove))
            {
                //Debug.Log("Saved Range: " + range.ToString(true));
            }

            if (this.CalibrationStage != CalibrationStage.Done)
            {
                this.CalibrationStage = CalibrationStage.Done;
                this.CalibrationStateChanged.Invoke();
            }
            return(true);
        }
Exemplo n.º 4
0
 /// <summary> Returns a Hand Pose containing everything you'd want to animate a hand model in Unity. Using the global HandProfile. </summary>
 /// <param name="handModel"></param>
 /// <param name="pose"></param>
 /// <param name="forceUpdate"></param>
 /// <returns></returns>
 public virtual bool GetHandPose(SGCore.Kinematics.BasicHandModel handModel, out SG_HandPose pose, bool forceUpdate = false)
 {
     return(GetHandPose(handModel, SG_HandProfiles.GetProfile(this.IsRight), out pose, forceUpdate));
 }