public XsDataPacket(XsDataPacket pack) : this(xsensdeviceapiPINVOKE.new_XsDataPacket__SWIG_2(XsDataPacket.getCPtr(pack)), true)
 {
     if (xsensdeviceapiPINVOKE.SWIGPendingException.Pending)
     {
         throw xsensdeviceapiPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #2
0
    /// <summary>
    /// Callback function when data is available.
    /// </summary>
    /// <param name="packet"></param>
    public void OnDataAvailable(XsDataPacket packet)
    {
        _eulerOrientation = packet.orientationEuler();
        _rotMatrix        = packet.orientationMatrix();
        _rotQuat          = packet.orientationQuaternion();
        _accXs            = packet.calibratedAcceleration();
        _freeAccXs        = packet.freeAcceleration();

        // store rotation and acceleration in Unity friendly format
        _quat    = new Quaternion((float)_rotQuat.x(), (float)_rotQuat.y(), (float)_rotQuat.z(), (float)_rotQuat.w());
        _acc     = new Vector3((float)_accXs.value(0), (float)_accXs.value(1), (float)_accXs.value(2));
        _freeAcc = new Vector3((float)_freeAccXs.value(0), (float)_freeAccXs.value(1), (float)_freeAccXs.value(2));

        int currentPacketId = packet.packetCounter();

        if (_lastPacketId == -1)
        {
            // this is the first frame
            _lastPacketId = currentPacketId;
        }

        int packetDiff = currentPacketId - _lastPacketId;

        if (packetDiff > 10)
        {
            Debug.Log("packet loss " + packetDiff);
        }
        _lastPacketId = currentPacketId;
    }
 public void swap(XsDataPacket other)
 {
     xsensdeviceapiPINVOKE.XsDataPacket_swap(swigCPtr, XsDataPacket.getCPtr(other));
     if (xsensdeviceapiPINVOKE.SWIGPendingException.Pending)
     {
         throw xsensdeviceapiPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemple #4
0
        protected override void onLiveDataAvailable(SWIGTYPE_p_XsDevice dev, XsDataPacket packet)
        {
            XsDevice     device = new XsDevice(dev);
            XsDataPacket pack   = new XsDataPacket(packet);

            if (DataAvailable != null)
            {
                DataAvailable(this, new DataAvailableArgs(device, pack));
            }
        }
        public XsDataPacket merge(XsDataPacket other)
        {
            XsDataPacket ret = new XsDataPacket(xsensdeviceapiPINVOKE.XsDataPacket_merge__SWIG_1(swigCPtr, XsDataPacket.getCPtr(other)), false);

            if (xsensdeviceapiPINVOKE.SWIGPendingException.Pending)
            {
                throw xsensdeviceapiPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemple #6
0
 protected virtual void onLiveDataAvailable(SWIGTYPE_p_XsDevice dev, XsDataPacket packet)
 {
     if (SwigDerivedClassHasMethod("onLiveDataAvailable", swigMethodTypes1))
     {
         xsensdeviceapiPINVOKE.XsCallback_onLiveDataAvailableSwigExplicitXsCallback(swigCPtr, SWIGTYPE_p_XsDevice.getCPtr(dev), XsDataPacket.getCPtr(packet));
     }
     else
     {
         xsensdeviceapiPINVOKE.XsCallback_onLiveDataAvailable(swigCPtr, SWIGTYPE_p_XsDevice.getCPtr(dev), XsDataPacket.getCPtr(packet));
     }
 }
Exemple #7
0
        public XsDataPacket takeFirstDataPacketInQueue()
        {
            XsDataPacket ret = new XsDataPacket(xsensdeviceapiPINVOKE.XsDevice_takeFirstDataPacketInQueue(swigCPtr), true);

            return(ret);
        }
Exemple #8
0
        public XsDataPacket lastAvailableLiveData()
        {
            XsDataPacket ret = new XsDataPacket(xsensdeviceapiPINVOKE.XsDevice_lastAvailableLiveData(swigCPtr), true);

            return(ret);
        }
Exemple #9
0
        public XsDataPacket getDataPacketByIndex(uint index)
        {
            XsDataPacket ret = new XsDataPacket(xsensdeviceapiPINVOKE.XsDevice_getDataPacketByIndex(swigCPtr, index), true);

            return(ret);
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(XsDataPacket obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Exemple #11
0
 public DataAvailableArgs(XsDevice device, XsDataPacket packet)
 {
     Device = device;
     Packet = packet;
 }