Ejemplo n.º 1
0
    /// <summary>
    /// Obtain smoothed position (x, y, z) and orientation (x, y, z, w) data
    /// </summary>
    private void ExtractData()
    {
        // Get next OSC Packet
        _OSCReader.GetOSCPacket();

        // Position Data
        _XCoord = _AVG_X.SmoothPositionData(_OSCReader.Position(Values.X));
        // z and y axis reversed for unity reference frame
        _YCoord = _AVG_Y.SmoothPositionData(_OSCReader.Position(Values.Z));
        _ZCoord = _AVG_Z.SmoothPositionData(_OSCReader.Position(Values.Y));

        // Rotation Data
        _QuartX = _AVG_QtX.SmoothOrientationData(_OSCReader.Orientation(Values.Qt_X));
        _QuartY = _AVG_QtY.SmoothOrientationData(_OSCReader.Orientation(Values.Qt_Y));
        _QuartZ = _AVG_QtZ.SmoothOrientationData(_OSCReader.Orientation(Values.Qt_Z));
        _QuartW = _AVG_QtW.SmoothOrientationData(_OSCReader.Orientation(Values.Qt_W));

        Debug.Log(string.Format("Position: [x:{0} y:{1} z:{2}], Rotation: [x:{3:f2} y:{4:f2} z:{5:f2} w:{6:f2}]", _XCoord, _YCoord, _ZCoord, _QuartX, _QuartY, _QuartZ, _QuartW));
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Obtain smoothed position (x, y, z) and orientation (p, r, y) data
    /// </summary>
    private void ExtractData()
    {
        // Get next OSC Packet
        _OSCReader.GetOSCPacket();

        // Position Data
        _XCoord = _AVG_X.SmoothPositionData(_OSCReader.Position(Values.X));
        // z and y axis reversed for unity reference frame
        _YCoord = _AVG_Y.SmoothPositionData(_OSCReader.Position(Values.Z));
        _ZCoord = _AVG_Z.SmoothPositionData(_OSCReader.Position(Values.Y));

        // Rotation Data
        _Pitch = _AVG_Pitch.SmoothOrientationData(_OSCReader.Orientation(Values.P));
        _Roll  = _AVG_Roll.SmoothOrientationData(_OSCReader.Orientation(Values.R));
        _Yaw   = _AVG_Yaw.SmoothOrientationData(_OSCReader.Orientation(Values.Yaw)) - 90;  // Rotate 90 deg to compensate for Unity Reference Frame / Pozyx difference

        Debug.Log(string.Format("Position: [x:{0} y:{1} z:{2}], Rotation: [p:{3:f2} r:{4:f2} y:{5:f2}]", _XCoord, _YCoord, _ZCoord, _Pitch, _Roll, _Yaw));

        // Convert Euler (Rotation) Angles to Quaternions
        _QT = Quaternion.Euler(_Roll, _Yaw, -_Pitch);
    }