コード例 #1
0
    /// <summary> Updates all variables that can change during the simulation.</summary>
    /// <param name="data"></param>
    public void UpdateVariables(SenseGloveCs.GloveData data)
    {
        this.dataLoaded     = data.dataLoaded;
        this.deviceID       = data.deviceID;
        this.gloveValues    = data.gloveValues;
        this.imuValues      = data.imuValues;
        this.imuCalibration = data.imuCalibration;

        this.numberOfSensors = data.numberOfSensors;

        this.packetsPerSecond = data.samplesPerSec;

        this.calibrationStep       = data.currentCalStep;
        this.totalCalibrationSteps = data.totalCalSteps;

        this.absoluteCalibratedWrist = SG_Util.ToUnityQuaternion(data.wrist.QcalibratedAbs);
        this.absoluteWrist           = SG_Util.ToUnityQuaternion(data.wrist.QwristAbs);
        this.relativeWrist           = SG_Util.ToUnityQuaternion(data.wrist.Qrelative);

        SenseGlove_Data.GetChainVariables(ref data.kinematics.gloveLinks, ref this.glovePositions,
                                          ref this.gloveAngles, ref this.gloveRotations, ref this.gloveLengths);

        SenseGlove_Data.GetChainVariables(ref data.kinematics.fingers, ref this.handPositions,
                                          ref this.handAngles, ref this.handRotations, ref this.handLengths);
    }
コード例 #2
0
    /// <summary> Extract right-handed coordinate system data from the SenseGlove DLL and convert it into Unity values. </summary>
    /// <param name="data"></param>
    /// <param name="packets"></param>
    /// <param name="totalCSteps"></param>
    /// <param name="currCStep"></param>
    public SenseGlove_Data(SenseGloveCs.GloveData data)
    {
        if (data != null)
        {
            this.gloveSide = SenseGlove_Data.GetSide(data.kinematics.isRight);

            this.deviceID        = data.deviceID;
            this.firmwareVersion = data.firmwareVersion;
            this.gloveVersion    = data.deviceVersion;

            this.packetsPerSecond = data.samplesPerSec;

            this.commonOriginPos = SG_Util.ToUnityPosition(data.kinematics.gloveRelPos);
            this.commonOriginRot = SG_Util.ToUnityQuaternion(data.kinematics.gloveRelRot);

            this.UpdateVariables(data);
        }
    }
コード例 #3
0
    /// <summary> Fill the appropriate unity Quaternion and Vector3 arrays based on a single joing chain (finger or glove semgent) </summary>
    /// <param name="chain"></param>
    /// <param name="positions"></param>
    /// <param name="angles"></param>
    /// <param name="rotations"></param>
    /// <param name="lengths"></param>
    protected static void GetLinkVariables(ref SenseGloveCs.Kinematics.JointChain chain, ref Vector3[] positions, ref Vector3[] angles, ref Quaternion[] rotations, ref Vector3[] lengths)
    {
        int n = chain.joints.Length;

        positions = new Vector3[n];
        angles    = new Vector3[n];
        rotations = new Quaternion[n];
        lengths   = new Vector3[n - 1];

        for (int j = 0; j < n; j++)
        {
            positions[j] = SG_Util.ToUnityPosition(chain.joints[j].position);
            angles[j]    = SG_Util.ToUnityEuler(chain.joints[j].relativeAngle);
            rotations[j] = SG_Util.ToUnityQuaternion(chain.joints[j].rotation);
            if (j < n - 1)
            {
                lengths[j] = SG_Util.ToUnityPosition(chain.lengths[j]);
            }
        }
    }