Exemple #1
0
 private void EnsureDofExists()
 {
     if (Dof == null)
     {
         Dof = new DofData();
     }
 }
        /// <summary>
        /// Extract positional data from the message received from the arduino.
        /// </summary>
        private void ParseData()
        {
            // Extract position and oriantation.
            // sample received message
            // pos: 1.00000,0.00000,1.00000 rot: 0.99985,-0.00356,-0.00462,-0.01626
            // which follows the format --> pos: x, y, z rot: pitch, roll, yaw
            var stringCollection = _receivedSingleMessage.Replace("rot:", COMMA)
                                   .Replace("pos:", COMMA)
                                   .Split(',');
            // We omit stringCollection[0] because it does not contain positional data and is empty.
            float posX = Convert.ToSingle(stringCollection[1]);
            float posY = Convert.ToSingle(stringCollection[2]);
            float posZ = Convert.ToSingle(stringCollection[3]);

            float pitch = Convert.ToSingle(stringCollection[4]);
            float roll  = Convert.ToSingle(stringCollection[5]);
            float yaw   = Convert.ToSingle(stringCollection[6]);

            _latestPosition = new MyArduino.Vector3(posX, posY, posZ);
            _latestData     = new DofData();
        }
Exemple #3
0
 private void EnsureDofExists()
 {
     if (Dof == null)
         Dof = new DofData();
 }