Exemple #1
0
	    public XsMvnPose pose;                          		// Every packet has a pose
	
		/// <summary>
		/// Initializes a new instance of the <see cref="xsens.XsDataPacket"/> class.
		/// </summary>
		/// <param name='readData'>
		/// Create the packed from this byte array.
		/// </param>
	    public XsDataPacket(byte[] readData)
	    {
	        memStream = new MemoryStream(readData);            // Create a memory stream of the packet data
	        binReader = new BinaryReader(memStream);          // Create a binary reader on that memory stream, so we can easely convert the data it contains
	
	        parseHeader();
	        parsePayload(0);                                    // Calls the correct classes parsePayload by itself (inheritance)
	
	        pose = new XsMvnPose(isQuaternionPacket);
	        pose.setHeaderData(headerData);                    // TODO: figure out if this is even neccesary
	        pose.setPayloadData(payloadData);                  // Sets the payload data in the pose
	
	        pose.createPose(0, 0);                              // Try to create a new pose with the data that was send
	    }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="xsens.XsDataPacket"/> class.
 /// </summary>
 /// <param name='readData'>
 /// Create the packed from this byte array.
 /// </param>
 public XsDataPacket (byte[] readData)
 {
     using (BinaryReader br = new BinaryReader(new MemoryStream(readData))) 
     {
         pose = null;
         int[] headerData = parseHeader (br);
         //we only care about pose data, which is Z up
         if (headerData [0] == (int)MessageType.PoseDataZup) 
         {
             double[] payloadData = parsePayload (br);    // Calls the correct classes parsePayload by itself (inheritance)
             pose = new XsMvnPose ();
             pose.createPose (payloadData);               // Try to create a new pose with the data that was send
         }
     }
 }
        protected XsMvnPose pose; // Every valid packet has a pose (Just like every pose has its thorn)

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="xsens.XsDataPacket"/> class.
        /// </summary>
        /// <param name='readData'>
        /// Create the packed from this byte array.
        /// </param>
        public XsDataPacket(byte[] readData)
        {
            using (BinaryReader br = new BinaryReader(new MemoryStream(readData)))
            {
                pose = null;
                int[] headerData = parseHeader (br);
                //we only care about pose data, which is Z up
                if (headerData [0] == (int)MessageType.PoseDataZup)
                {
                    double[] payloadData = parsePayload (br);    // Calls the correct classes parsePayload by itself (inheritance)
                    pose = new XsMvnPose ();
                    pose.createPose (payloadData);               // Try to create a new pose with the data that was send
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="xsens.XsDataPacket"/> class.
        /// </summary>
        /// <param name='readData'>
        /// Create the packed from this byte array.
        /// </param>
        public XsDataPacket (byte[] readData)
        {
            using (BinaryReader br = new BinaryReader(new MemoryStream(readData))) 
            {
                pose = null;
                int[] headerData = parseHeader (br);
                //we only care about pose data, which is Z up
                if ((headerData [0] == (int)MessageType.PoseDataZup)
					|| (headerData [0] == (int)MessageType.PosDataUnity))
                {
                    double[] payloadData = parsePayload (br, headerData[3]);    // Calls the correct classes parsePayload by itself (inheritance)
                    if (headerData[5] == 0) //if we are using an MVN version below 2019
                    {
                        pose = new XsMvnPose(headerData[3]);
                    }
                    else //If we are using MVN 2019 and above
                    {
                        pose = new XsMvnPose(headerData[5], headerData[7], headerData[6]);
                    }
                    pose.createPose (payloadData);               // Try to create a new pose with the data that was send
                }
            }
        }