Пример #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));
    }
Пример #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));
        Debug.Log(string.Format("Max: [x:{0} y:{1} z:{2}], Min: [x:{3} y:{4} z:{5}]]", _AVG_X.GetMax(), _AVG_Y.GetMax(), _AVG_Z.GetMax(), _AVG_X.GetMin(), _AVG_Y.GetMin(), _AVG_Z.GetMin()));

        // Convert Euler (Rotation) Angles to Quaternions
        _QT = Quaternion.Euler(_Roll, _Yaw, -_Pitch);
    }
Пример #3
0
    /// <summary>
    /// Obtain smoothed position (x, y, z) and orientation (p, r, y) data
    /// </summary>
    private void ExtractData()
    {
        const char REMOVE_F = 'f';

        // Get next OSC Packet for this GameObject (Pozyx Tag)
        _PozyxData = OSC.GetOSCPacket(TagID);

        // Position Data
        _XCoord = _AVG_X.SmoothPositionData(Convert.ToInt32(_PozyxData[2]));
        // z and y axis reversed for unity reference frame
        _YCoord = _AVG_Y.SmoothPositionData(Convert.ToInt32(_PozyxData[4]));
        _ZCoord = _AVG_Z.SmoothPositionData(Convert.ToInt32(_PozyxData[3]));

        // Orientation Data
        _Pitch = _AVG_Pitch.SmoothOrientationData(float.Parse(_PozyxData[5].TrimEnd(REMOVE_F)));
        _Roll  = _AVG_Roll.SmoothOrientationData(float.Parse(_PozyxData[6].TrimEnd(REMOVE_F)));
        _Yaw   = _AVG_Yaw.SmoothOrientationData(float.Parse(_PozyxData[7].TrimEnd(REMOVE_F))) - 90;  // Rotate 90 deg to compensate for Unity Reference Frame / Pozyx difference

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

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