Ejemplo n.º 1
0
 public Wimu(string wimuSerialPortNumber)
 {
     WimuData = new WimuData();
     serialPortConfigured = configSerialPort(wimuSerialPortNumber);
     if(serialPortConfigured)
         configBw();
 }
Ejemplo n.º 2
0
 private void bw_DoWork(object sender, DoWorkEventArgs e)
 {
     while (!trabajador.CancellationPending)
     {
         WimuData = readWimuData();
     }
 }
Ejemplo n.º 3
0
 private void bw_DoWork(object sender, DoWorkEventArgs e)
 {
     while (!trabajador.CancellationPending)
     {
         WimuData = readWimuData();
     }
 }
        PointD linearTransformation()
        {
            WimuData offsetHead          = refPointHead - currentHeadLocation();
            PointD   deltaCursorLocation = offsetHead2CursorLocation(offsetHead);

            return(deltaCursorLocation);
        }
        PointD offsetHead2CursorLocation(WimuData offsetHead)
        {
            PointD deltaCursorLocation = new PointD();

            deltaCursorLocation.X = offsetHead.yaw * linearCoefYaw;
            deltaCursorLocation.Y = offsetHead.pitch * linearCoefPitch;
            return(deltaCursorLocation);
        }
Ejemplo n.º 6
0
 public Wimu(string wimuSerialPortNumber)
 {
     WimuData             = new WimuData();
     serialPortConfigured = configSerialPort(wimuSerialPortNumber);
     if (serialPortConfigured)
     {
         configBw();
     }
 }
Ejemplo n.º 7
0
        private WimuData readWimuData()
        {
            WimuData wimudata = new WimuData();
            string   message  = string.Empty;

            do
            {
                try
                {
                    message = wimuSerialPort.ReadLine();
                }
                catch
                {
                    //cancelar al trabajador
                    //retornar nada
                    trabajador.CancelAsync();
                    wimudata.SetNullValue();
                    return(wimudata);
                }
            }while (!message.StartsWith("#YPR") || !message.EndsWith("\r"));

            string[] words = message.Split('=', ',', '\r');
            //#YPR=Yaw, Pitch, Roll, Yaw+Pitch+Roll, alfa, beta, gama, alfa+beta+gama, timeStamp
            //ver si el último carácter es una "r" para saber si esta completo

            /*
             *  [0]: "#YPR"
             *  [1]: "-18.16" yaw
             *  [2]: "-10.29" pitch
             *  [3]: "21.03" roll
             *  [4]: "-7.42"
             *  [5]: "-3.60"
             *  [6]: "-30.02"
             *  [7]: "-4.13"
             *  [8]: "-37.75"
             *  [9]: "285980" timestamp
             *  [10]: ""
             */

            try
            {
                wimudata.yaw              = Convert.ToDouble(words[1], CultureInfo.InvariantCulture); // X YAW
                wimudata.pitch            = Convert.ToDouble(words[2], CultureInfo.InvariantCulture); // PITCH
                wimudata.roll             = Convert.ToDouble(words[3], CultureInfo.InvariantCulture); // Y ROLL
                wimudata.timeStampMiliSec = Convert.ToDouble(words[9], CultureInfo.InvariantCulture);
                wimudata.validValue       = true;
            }
            catch
            {
                wimudata.SetNullValue();
            }

            return(wimudata);
        }
 public PointD GetDeltaLocationFromHEADTracking()
 {
     if (refPointHead == null)
     {
         refPointHead = currentHeadLocation();
         deltaCursor  = new PointD(0, 0);
         return(deltaCursor);
     }
     else
     {
         PointD deltaCursorLocation = linearTransformation();
         return(deltaCursorLocation);
     }
 }
Ejemplo n.º 9
0
        private WimuData readWimuData()
        {
            WimuData wimudata = new WimuData();
            string message = string.Empty;

            do
            {
                try
                {
                    message = wimuSerialPort.ReadLine();
                }
                catch
                {
                    //cancelar al trabajador
                    //retornar nada
                    trabajador.CancelAsync();
                    wimudata.SetNullValue();
                    return wimudata;
                }

            }
            while (!message.StartsWith("#YPR") || !message.EndsWith("\r"));

            string[] words = message.Split('=',',','\r');
            //#YPR=Yaw, Pitch, Roll, Yaw+Pitch+Roll, alfa, beta, gama, alfa+beta+gama, timeStamp
            //ver si el último carácter es una "r" para saber si esta completo
            /*
                [0]: "#YPR"
                [1]: "-18.16" yaw
                [2]: "-10.29" pitch
                [3]: "21.03" roll
                [4]: "-7.42"
                [5]: "-3.60"
                [6]: "-30.02"
                [7]: "-4.13"
                [8]: "-37.75"
                [9]: "285980" timestamp
                [10]: ""
             */

            try
            {
                wimudata.yaw = Convert.ToDouble(words[1], CultureInfo.InvariantCulture); // X YAW
                wimudata.pitch = Convert.ToDouble(words[2], CultureInfo.InvariantCulture); // PITCH
                wimudata.roll = Convert.ToDouble(words[3], CultureInfo.InvariantCulture); // Y ROLL
                wimudata.timeStampMiliSec = Convert.ToDouble(words[9], CultureInfo.InvariantCulture);
                wimudata.validValue = true;
            }
            catch
            {
                wimudata.SetNullValue();
            }

            return wimudata;
        }
        WimuData currentHeadLocation()
        {
            WimuData currentHeadLocation = wimuDevice.WimuData;

            return(currentHeadLocation);
        }
Ejemplo n.º 11
0
        private void GazePoint(object sender, GazePointEventArgs gazePointEventArgs)
        {
            headData = wimuDevice.WimuData;
            headData.timeStampMiliSec = (double)PseudoTimeStampMiliSecImu++;

            BeginInvoke(new Action(() =>
            {
                var handle = Handle;
                if (handle == null)
                {
                    // window not created yet. never mind.
                    return;
                }

                _trackStatus.OnGazeData(gazePointEventArgs.GazeDataReceived);
                progressBar4Distance.Value = eyetrackingFunctions.distanceBetweenDev2User(gazePointEventArgs.GazeDataReceived);
                Invalidate();
                headData2Chart(headData);
            }));

            if (AppControlCursor)
            {
                PointD deltaCursor = head2deltaCursor.GetDeltaLocationFromHEADTracking();
                //PointD deltaCursor = new PointD(0, 0);
                PointD gazeWeighted = eyetrackingFunctions.WeighGaze(gazePointEventArgs.GazeDataReceived);//valores normalizados
                PointD gazeFilteredNormalized = gazeFilter.filterGazeData(gazeWeighted);//valores normalizados
                PointD gazeFilteredPixels = eyetrackingFunctions.normalized2Pixels(gazeFilteredNormalized);
                Point cursorLocation = (Point)fusionador.getCursorLocation(true, deltaCursor, gazeFilteredPixels);
                CursorControl.locateCursor(cursorLocation);
            }
        }
Ejemplo n.º 12
0
 private void headData2Chart(WimuData headData)
 {
     point2Chart(new PointD(headData.timeStampMiliSec, headData.yaw), chartYaw);
     point2Chart(new PointD(headData.timeStampMiliSec, headData.pitch), chartPitch);
     point2Chart(new PointD(headData.timeStampMiliSec, headData.roll), chartRoll);
 }