Exemplo n.º 1
0
 /// <summary>
 /// Method called upon receiving the even myodata received. It passes on the orientation data to the UpdateOrientation class in Mainwindow
 /// </summary>
 /// <param name="e"></param>
 public void CalculateGyroscope(GyroscopeDataEventArgs e)
 {
     gyroscopeX = e.Gyroscope.X / 500;
     gyroscopeY = e.Gyroscope.Y / 500;
     gyroscopeZ = e.Gyroscope.Z / 500;
     mWindow.UpdateGyroscope(gyroscopeX, gyroscopeY, gyroscopeZ);
 }
Exemplo n.º 2
0
        public MyoData buildRecordUsing(DataCollector data, DateTime AGOStamp, DateTime EMGStamp)
        {
            AccelerometerDataEventArgs Acc  = data.accelerometerData.First(X => X.Timestamp == AGOStamp);
            EmgDataEventArgs           Emg  = data.emgData.First(X => X.Timestamp == EMGStamp);
            OrientationDataEventArgs   Ori  = data.orientationData.First(X => X.Timestamp == AGOStamp);
            GyroscopeDataEventArgs     Gyro = data.gyroscopeData.First(X => X.Timestamp == AGOStamp);

            return(buildRecordUsing(Emg, Acc, Gyro, Ori));
        }
Exemplo n.º 3
0
        public void ChannelEventReceived_Orientation_TriggersGyroscopeDataAcquiredEvent()
        {
            // Setup
            var routeEventArgs = new RouteMyoEventArgs(
                new IntPtr(123),
                new IntPtr(789),
                MyoEventType.Orientation,
                DateTime.UtcNow);

            var gyroscope = new Vector3F(10, 20, 30);

            var channelListener = new Mock <IChannelListener>(MockBehavior.Strict);

            var myoDeviceDriver = new Mock <IMyoDeviceDriver>(MockBehavior.Strict);

            myoDeviceDriver
            .SetupGet(x => x.Handle)
            .Returns(new IntPtr(123));
            myoDeviceDriver
            .Setup(x => x.GetEventOrientation(routeEventArgs.Event))
            .Returns(new QuaternionF());
            myoDeviceDriver
            .Setup(x => x.GetEventAccelerometer(routeEventArgs.Event))
            .Returns(new Vector3F());
            myoDeviceDriver
            .Setup(x => x.GetGyroscope(routeEventArgs.Event))
            .Returns(gyroscope);

            var myo = Myo.Create(
                channelListener.Object,
                myoDeviceDriver.Object);

            GyroscopeDataEventArgs actualEventArgs = null;
            object actualSender = null;

            myo.GyroscopeDataAcquired += (sender, args) =>
            {
                actualSender    = sender;
                actualEventArgs = args;
            };

            // Execute
            channelListener.Raise(
                x => x.EventReceived += null,
                routeEventArgs);

            // Assert
            Assert.Equal(myo, actualSender);
            Assert.Equal(myo, actualEventArgs.Myo);
            Assert.Equal(routeEventArgs.Timestamp, actualEventArgs.Timestamp);
            Assert.Equal(gyroscope, actualEventArgs.Gyroscope);;

            myoDeviceDriver.VerifyGet(x => x.Handle, Times.Once);
            myoDeviceDriver.Verify(x => x.GetEventOrientation(routeEventArgs.Event), Times.Once);
            myoDeviceDriver.Verify(x => x.GetEventAccelerometer(routeEventArgs.Event), Times.Once);
            myoDeviceDriver.Verify(x => x.GetGyroscope(routeEventArgs.Event), Times.Once);
        }
Exemplo n.º 4
0
 private void Myo_GyroscopeDataAcquired(object sender, GyroscopeDataEventArgs e)
 {
     this._mouse.onGyroscope(e.Gyroscope);
     if (!e.Myo.IsUnlocked)
     {
         return;
     }
     MyoController.mouse_event(1, (int)this._mouse.dx, (int)this._mouse.dy, 0, 0);
 }
Exemplo n.º 5
0
        private void Myo_GyroscopeDataAcquired(object sender, GyroscopeDataEventArgs e)
        {
            //there is no need to send emg data
            GyroscopeChangedEventArgs args = new GyroscopeChangedEventArgs();

            args.gyroscopeX = e.Gyroscope.X;
            args.gyroscopeY = e.Gyroscope.Y;
            args.gyroscopeZ = e.Gyroscope.Z;
            OnGyroscopeChanged(args);
        }
Exemplo n.º 6
0
 private void GyroscopeDataAcquired(object sender, GyroscopeDataEventArgs e)
 {
     LastTransmissionTick = CurrentTick;
     if (streamData == true)
     {
         //"," + DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() + ","
         Publish("/i5/myo/full", EMG + Acc + "," + e.Gyroscope.X + "," + e.Gyroscope.Y.ToString() + "," + e.Gyroscope.Z.ToString());
         Publish("/i5/myo/gyroscope", e.Gyroscope.X + "," + e.Gyroscope.Y.ToString() + "," + e.Gyroscope.Z.ToString());
     }
 }
Exemplo n.º 7
0
        private void Myo_GyroscopeAcquired(object sender, GyroscopeDataEventArgs e)
        {
            if (_isRecording == true)
            {
                if ((DateTime.Now - lastExecutionGyroscope).TotalSeconds >= 0.5)
                {
                    CalculateGyroscope(e);
                    if (MainWindow.isRecordingData == true)
                    {
                        SendData();
                    }

                    lastExecutionGyroscope = DateTime.Now;
                }
            }
        }
Exemplo n.º 8
0
        public void GetTimestamp_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var timestamp = DateTime.UtcNow;

            var args = new GyroscopeDataEventArgs(
                new Mock <IMyo>().Object,
                timestamp,
                new Vector3F());

            // Execute
            var result = args.Timestamp;

            // Assert
            Assert.Equal(timestamp, result);
        }
Exemplo n.º 9
0
        public void GetMyo_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var myo = new Mock <IMyo>();

            var args = new GyroscopeDataEventArgs(
                myo.Object,
                DateTime.UtcNow,
                new Vector3F());

            // Execute
            var result = args.Myo;

            // Assert
            Assert.Equal(myo.Object, result);
        }
Exemplo n.º 10
0
        public void GetGyroscope_ValidState_EqualsConstructorParameter()
        {
            // Setup
            var gyroscopeData = new Vector3F(1, 2, 3);

            var args = new GyroscopeDataEventArgs(
                new Mock <IMyo>().Object,
                DateTime.UtcNow,
                gyroscopeData);

            // Execute
            var result = args.Gyroscope;

            // Assert
            Assert.Equal(gyroscopeData, result);
        }
Exemplo n.º 11
0
        private void Myo_GyroscopeDataAcquired(object sender, GyroscopeDataEventArgs e)
        {
            //float fMulti = 10.0f;
            //m_CGrap.Push(m_afAcc(int)Math.Round(e.Gyroscope.X * fMulti), (int)Math.Round(e.Gyroscope.Y * fMulti), (int)Math.Round(e.Gyroscope.Z * fMulti));
            if (m_anHandle[0] == e.Myo.Handle.ToInt32())
            {
                m_afGyro[0] = e.Gyroscope.X;
                m_afGyro[1] = e.Gyroscope.Y;
                m_afGyro[2] = e.Gyroscope.Z;
            }
#if false
            #region Message display on every 1 second
            if (m_CTIdGyro.Get() >= 1000)
            {
                m_CTIdGyro.Set();
                float[] afAngle = new float[3];
                Ojw.CMessage.Write("Gyro : {0}, {1}, {2}", m_afGyro[0], m_afGyro[1], m_afGyro[2]);
            }
            #endregion Message display on every 1 second
#endif
        }
Exemplo n.º 12
0
 public MyoData buildRecordUsing(EmgDataEventArgs Emg, AccelerometerDataEventArgs Acc, GyroscopeDataEventArgs Gyro, OrientationDataEventArgs Ori)
 {
     return(new MyoData()
     {
         Time_stamp = Acc.Timestamp,
         Acc_X = Acc.Accelerometer.X,
         Acc_Y = Acc.Accelerometer.Y,
         Acc_Z = Acc.Accelerometer.Z,
         Gyro_X = Gyro.Gyroscope.X,
         Gyro_Y = Gyro.Gyroscope.Y,
         Gyro_Z = Gyro.Gyroscope.Z,
         Ori_X = Ori.Orientation.X,
         Ori_Y = Ori.Orientation.Y,
         Ori_Z = Ori.Orientation.Z,
         Ori_W = Ori.Orientation.W,
         Emg_1 = Emg.EmgData.GetDataForSensor(0),
         Emg_2 = Emg.EmgData.GetDataForSensor(1),
         Emg_3 = Emg.EmgData.GetDataForSensor(2),
         Emg_4 = Emg.EmgData.GetDataForSensor(3),
         Emg_5 = Emg.EmgData.GetDataForSensor(4),
         Emg_6 = Emg.EmgData.GetDataForSensor(5),
         Emg_7 = Emg.EmgData.GetDataForSensor(6),
         Emg_8 = Emg.EmgData.GetDataForSensor(7),
         EmgMAV = 1.0d / 8.0d * (
             Math.Abs(Emg.EmgData.GetDataForSensor(0)) +
             Math.Abs(Emg.EmgData.GetDataForSensor(1)) +
             Math.Abs(Emg.EmgData.GetDataForSensor(2)) +
             Math.Abs(Emg.EmgData.GetDataForSensor(3)) +
             Math.Abs(Emg.EmgData.GetDataForSensor(4)) +
             Math.Abs(Emg.EmgData.GetDataForSensor(5)) +
             Math.Abs(Emg.EmgData.GetDataForSensor(6)) +
             Math.Abs(Emg.EmgData.GetDataForSensor(7))),
         Pitch = Ori.Pitch,
         Roll = Ori.Roll,
         Yaw = Ori.Yaw,
     });
 }
Exemplo n.º 13
0
 protected virtual void OnGyroscopeData(GyroscopeDataEventArgs e)
 {
     var handler = GyroscopeData;
     if (handler != null) handler(this, e);
 }
Exemplo n.º 14
0
        private void Myo_GyroscopeDataAcquired(object sender, GyroscopeDataEventArgs e)
        {
            MethodInvoker inv = delegate { this.label7.Text = $"X: {e.Gyroscope.X} | Y: {e.Gyroscope.Y} | Z: {e.Gyroscope.Z}"; };

            this.Invoke(inv);
        }
Exemplo n.º 15
0
Arquivo: Pyo.cs Projeto: raphaelfp/pyo
        private void Myo_GyroscopeDataAcquired(object sender, GyroscopeDataEventArgs e)
        {
            MethodInvoker inv = delegate { };

            this.Invoke(inv);
        }
Exemplo n.º 16
0
 void OnGyroscopeData(object sender, GyroscopeDataEventArgs e)
 {
     _myoState.Gyro = e.Gyroscope;
 }