コード例 #1
0
        static void Main(string[] args)
        {
            try
            {
                using (var hub = new Hub())
                {
                    Console.WriteLine("Attempting to find a Myo...");
                    IMyo myo = hub.WaitForMyo(TimeSpan.FromSeconds(10));
                    if (myo == null)
                        throw new TimeoutException("Unable to find a Myo!");

                    Console.WriteLine("Connected to a Myo armband!\n");

                    hub.MyoUnpaired += OnUnpair;
                    hub.RecognizedArm += OnRecognizedArm;
                    hub.LostArm += OnLostArm;

                    myo.PoseChanged += OnPoseChanged;
                    myo.OrientationDataAcquired += OnOrientationData;
                    
                    while (true)
                    {
                        hub.Run(TimeSpan.FromMilliseconds(1000 / 20));
                        PrintDisplay();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e.Message);
                Console.WriteLine("Press any key to continue.");
                Console.ReadKey();
            }
        }
コード例 #2
0
        void Create()
        {
            _myoState = new MyoState();
            MyoFound  = false;
            for (int i = 0; i < 30 && _myo == null; i++)
            {
                Console.Write("\r");
                Console.Write("Attempting to find a myo, attempt {0}", i);
                _myo = Context.Instance.Hub.GetMyo();
            }
            if (_myo == null)
            {
                return;
            }

            MyoFound = true;
            //we will vibrate whenever a new MyomiMyo is created

            _myo.AccelerometerDataAcquired += OnAccelerometerData;
            _myo.GyroscopeDataAquired      += OnGyroscopeData;
            _myo.OrientationDataAcquired   += OnOrientationData;
            _myo.PoseChanged   += OnPoseChanged;
            _myo.RecognizedArm += OnRecognizedArm;
            _myo.LostArm       += OnLostArm;

            if (_isOnArm)
            {
                InstanceCollectionEnabled = true;
            }
        }
コード例 #3
0
        private void Myo_PoseChanged(object sender, PoseEventArgs e)
        {
            var samePose = _lastPose == e.Pose;

            _lastPose      = e.Pose;
            _triggeringMyo = e.Myo;

            lock (_timer)
            {
                if (_timerAlive)
                {
                    return;
                }

                if (samePose && _targetPoses.Contains(e.Pose))
                {
                    if (_timerPaused)
                    {
                        _timerPaused = false;
                        _timer.Start();
                    }
                }
                else
                {
                    _timerPaused = true;
                    _timer.Stop();
                }
            }
        }
コード例 #4
0
ファイル: RssiEventArgs.cs プロジェクト: raphaelfp/pyo
        /// <summary>
        /// Initializes a new instance of the <see cref="RssiEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="rssi">The received signal strength indicator (RSSI).</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is null.
        /// </exception>
        public RssiEventArgs(IMyo myo, DateTime timestamp, sbyte rssi)
            : base(myo, timestamp)
        {
            Contract.Requires <ArgumentNullException>(myo != null, "myo");

            this.Rssi = rssi;
        }
コード例 #5
0
        /// <summary>
        /// Initialize the Myo input module. Will throw an exception if no Myo is available
        /// </summary>
        public MyoInput()
        {
            Active = true;

            hub = new Hub("de.dhbw.MyoPilot");
            myo = hub.WaitForMyo(TimeSpan.FromSeconds(5));
            if (myo == null)
            {
                throw new TimeoutException("Unable to find a Myo!");
            }

            hub.MyoUnpaired += OnUnpair;

            myo.PoseChanged             += OnPoseChanged;
            myo.OrientationDataAcquired += OnOrientationData;
            myo.RecognizedArm           += OnRecognizedArm;
            myo.LostArm += OnLostArm;
            myo.Unlock(UnlockType.Hold);

            // hub.Run() needs to run permanently in order to receive events from the Myo
            Thread worker = new Thread(hub.Run)
            {
                IsBackground = true, Name = "MyoBackgroundWorker"
            };

            worker.Start();
        }
コード例 #6
0
ファイル: MyoEventArgs.cs プロジェクト: rafme/MyoSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="MyoEventArgs" /> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>.
        /// </exception>
        public MyoEventArgs(IMyo myo, DateTime timestamp)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");

            _myo = myo;
            _timestamp = timestamp;
        }
コード例 #7
0
ファイル: PoseEventArgs.cs プロジェクト: rafme/MyoSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="PoseEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="pose">The pose that the Myo detected.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is null.
        /// </exception>
        public PoseEventArgs(IMyo myo, DateTime timestamp, Pose pose)
            : base(myo, timestamp)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");

            this.Pose = pose;
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PoseEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="pose">The pose that the Myo detected.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is null.
        /// </exception>
        public PoseEventArgs(IMyo myo, DateTime timestamp, Pose pose)
            : base(myo, timestamp)
        {
            // Contract.Requires<ArgumentNullException>(myo != null, "myo");

            this.Pose = pose;
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyoEventArgs" /> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>.
        /// </exception>
        public MyoEventArgs(IMyo myo, DateTime timestamp)
        {
            Contract.Requires <ArgumentNullException>(myo != null, "myo");

            _myo       = myo;
            _timestamp = timestamp;
        }
コード例 #10
0
ファイル: RssiEventArgs.cs プロジェクト: rafme/MyoSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="RssiEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="rssi">The received signal strength indicator (RSSI).</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is null.
        /// </exception>
        public RssiEventArgs(IMyo myo, DateTime timestamp, sbyte rssi)
            : base(myo, timestamp)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");

            this.Rssi = rssi;
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AccelerometerDataEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="accelerometerData">The accelerometer data. Cannot be <c>null</c>.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> or <paramref name="accelerometerData"/> is null.
        /// </exception>
        public AccelerometerDataEventArgs(IMyo myo, DateTime timestamp, Vector3F accelerometerData)
            : base(myo, timestamp)
        {
            Contract.Requires <ArgumentNullException>(myo != null, "myo");
            Contract.Requires <ArgumentNullException>(accelerometerData != null, "accelerometerData");

            this.Accelerometer = accelerometerData;
        }
コード例 #12
0
ファイル: EmgDataEventArgs.cs プロジェクト: rafme/MyoSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="EmgDataEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised this event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="emgData">The EMG data that corresponds to this event. Cannot be <c>null</c>.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> or <paramref name="emgData"/> is null.
        /// </exception>
        public EmgDataEventArgs(IMyo myo, DateTime timestamp, IEmgData emgData)
            : base(myo, timestamp)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentNullException>(emgData != null, "emgData");

            this.EmgData = emgData;
        }
コード例 #13
0
ファイル: EmgDataEventArgs.cs プロジェクト: VLbest/RD_Sources
        /// <summary>
        /// Initializes a new instance of the <see cref="EmgDataEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised this event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="emgData">The EMG data that corresponds to this event. Cannot be <c>null</c>.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> or <paramref name="emgData"/> is null.
        /// </exception>
        public EmgDataEventArgs(IMyo myo, DateTime timestamp, IEmgData emgData)
            : base(myo, timestamp)
        {
            //Contract.Requires<ArgumentNullException>(myo != null, "myo");
            //Contract.Requires<ArgumentNullException>(emgData != null, "emgData");

            this.EmgData = emgData;
        }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AccelerometerDataEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="accelerometerData">The accelerometer data. Cannot be <c>null</c>.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> or <paramref name="accelerometerData"/> is null.
        /// </exception>
        public AccelerometerDataEventArgs(IMyo myo, DateTime timestamp, Vector3F accelerometerData)
            : base(myo, timestamp)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentNullException>(accelerometerData != null, "accelerometerData");

            this.Accelerometer = accelerometerData;
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArmRecognizedEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="arm">The arm.</param>
        /// <param name="directionX">The direction x.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is null.
        /// </exception>
        public ArmRecognizedEventArgs(IMyo myo, DateTime timestamp, Arm arm, XDirection directionX)
            : base(myo, timestamp)
        {
            // Contract.Requires<ArgumentNullException>(myo != null, "myo");

            this.Arm        = arm;
            this.XDirection = directionX;
        }
コード例 #16
0
 // OnUnpair() is called whenever the Myo is disconnected from Myo Connect by the user.
 protected void OnUnpair(object sender, MyoEventArgs e)
 {
     lock (myLock)
     {
         myo   = null;
         onArm = false;
     }
 }
コード例 #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArmRecognizedEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="arm">The arm.</param>
        /// <param name="directionX">The direction x.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is null.
        /// </exception>
        public ArmRecognizedEventArgs(IMyo myo, DateTime timestamp, Arm arm, XDirection directionX)
            : base(myo, timestamp)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");

            this.Arm = arm;
            this.XDirection = directionX;
        }
コード例 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GyroscopeDataEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="gyroscopeData">The gyroscope data. Cannot be <c>null</c>.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> or <paramref name="gyroscopeData"/> is null.
        /// </exception>
        public GyroscopeDataEventArgs(IMyo myo, DateTime timestamp, Vector3F gyroscopeData)
            : base(myo, timestamp)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentNullException>(gyroscopeData != null, "gyroscopeData");

            this.Gyroscope = gyroscopeData;
        }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OrientationDataEventArgs" /> class.
 /// </summary>
 /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
 /// <param name="timestamp">The timestamp of the event.</param>
 /// <param name="orientationData">The orientation.</param>
 /// <param name="roll">The roll.</param>
 /// <param name="pitch">The pitch.</param>
 /// <param name="yaw">The yaw.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>.
 /// </exception>
 public OrientationDataEventArgs(IMyo myo, DateTime timestamp, QuaternionF orientationData, double roll, double pitch, double yaw)
     : base(myo, timestamp)
 {
     this.Orientation = orientationData;
     this.Roll        = roll;
     this.Pitch       = pitch;
     this.Yaw         = yaw;
 }
コード例 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GyroscopeDataEventArgs"/> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="gyroscopeData">The gyroscope data. Cannot be <c>null</c>.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> or <paramref name="gyroscopeData"/> is null.
        /// </exception>
        public GyroscopeDataEventArgs(IMyo myo, DateTime timestamp, Vector3F gyroscopeData)
            : base(myo, timestamp)
        {
            //Contract.Requires<ArgumentNullException>(myo != null, "myo");
            //Contract.Requires<ArgumentNullException>(gyroscopeData != null, "gyroscopeData");

            this.Gyroscope = gyroscopeData;
        }
コード例 #21
0
ファイル: MyoManager.cs プロジェクト: Hellyon/MyoGame
 public void RemoveHeldPose(IMyo myo, params Pose[] poses)
 {
     if (!heldPoses.ContainsKey(myo))
     {
         return;
     }
     heldPoses[myo].Stop();
     heldPoses[myo].RemovePoses(poses);
     heldPoses[myo].Start();
 }
コード例 #22
0
        public PoseSequenceEventArgs(IMyo myo, DateTime timestamp, IList<Pose> poses)
            : base(myo, timestamp, poses[poses.Count - 1])
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentNullException>(poses != null, "poses");
            Contract.Requires<ArgumentException>(poses.Count > 0, "The sequence must contain at least one pose.");

            // copy this list so we don't have any unexpected reference sharing
            _poses = new List<Pose>(poses).AsReadOnly();
        }
コード例 #23
0
        public PoseSequenceEventArgs(IMyo myo, DateTime timestamp, IList <Pose> poses)
            : base(myo, timestamp, poses[poses.Count - 1])
        {
            // Contract.Requires<ArgumentNullException>(myo != null, "myo");
            // Contract.Requires<ArgumentNullException>(poses != null, "poses");
            // Contract.Requires<ArgumentException>(poses.Count > 0, "The sequence must contain at least one pose.");

            // copy this list so we don't have any unexpected reference sharing
            _poses = new List <Pose>(poses).AsReadOnly();
        }
コード例 #24
0
ファイル: MyoManager.cs プロジェクト: Hellyon/MyoGame
        public void RemovePoseSequence(IMyo myo, params Pose[] poses)
        {
            var sequence = PoseSequence.Create(myo, poses);

            if (!poseSequences.Contains(sequence))
            {
                return;
            }
            sequence.PoseSequenceCompleted -= Sequence_PoseSequenceCompleted;
            poseSequences.Remove(sequence);
        }
コード例 #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrientationDataEventArgs" /> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="orientationData">The orientation.</param>
        /// <param name="roll">The roll.</param>
        /// <param name="pitch">The pitch.</param>
        /// <param name="yaw">The yaw.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>.
        /// </exception>
        public OrientationDataEventArgs(IMyo myo, DateTime timestamp, QuaternionF orientationData, double roll, double pitch, double yaw)
            : base(myo, timestamp)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentNullException>(orientationData != null, "orientationData");

            this.Orientation = orientationData;
            this.Roll = roll;
            this.Pitch = pitch;
            this.Yaw = yaw;
        }
コード例 #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OrientationDataEventArgs" /> class.
        /// </summary>
        /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
        /// <param name="timestamp">The timestamp of the event.</param>
        /// <param name="orientationData">The orientation.</param>
        /// <param name="roll">The roll.</param>
        /// <param name="pitch">The pitch.</param>
        /// <param name="yaw">The yaw.</param>
        /// <exception cref="System.ArgumentNullException">
        /// The exception that is thrown when <paramref name="myo"/> is <c>null</c>.
        /// </exception>
        public OrientationDataEventArgs(IMyo myo, DateTime timestamp, QuaternionF orientationData, double roll, double pitch, double yaw)
            : base(myo, timestamp)
        {
            //Contract.Requires<ArgumentNullException>(myo != null, "myo");
            //Contract.Requires<ArgumentNullException>(orientationData != null, "orientationData");

            this.Orientation = orientationData;
            this.Roll        = roll;
            this.Pitch       = pitch;
            this.Yaw         = yaw;
        }
コード例 #27
0
ファイル: MyoManager.cs プロジェクト: Hellyon/MyoGame
        public void AddPoseSequence(IMyo myo, params Pose[] poses)
        {
            var sequence = PoseSequence.Create(myo, poses);

            if (poseSequences.Contains(sequence))
            {
                return;
            }
            poseSequences.Add(sequence);
            sequence.PoseSequenceCompleted += Sequence_PoseSequenceCompleted;
        }
コード例 #28
0
 internal IMyo GetMyo()
 {
     if (_myo == null)
     {
         _myo = _hub.WaitForMyo(TimeSpan.FromMilliseconds(1500));
         return(_myo);
     }
     else
     {
         return(_myo);
     }
 }
コード例 #29
0
        protected virtual void OnTriggered(IMyo myo, DateTime timestamp, Pose pose)
        {
            var handler = Triggered;

            if (handler != null)
            {
                var args = new PoseEventArgs(
                    myo,
                    timestamp,
                    pose);
                handler.Invoke(this, args);
            }
        }
コード例 #30
0
        protected virtual void OnPoseSequenceCompleted(IMyo myo, DateTime timestamp, IList <Pose> poses)
        {
            var handler = PoseSequenceCompleted;

            if (handler != null)
            {
                var args = new PoseSequenceEventArgs(
                    myo,
                    timestamp,
                    poses);
                handler.Invoke(this, args);
            }
        }
コード例 #31
0
        protected virtual void OnTriggered(IMyo myo, DateTime timestamp, Pose pose)
        {
            //Contract.Requires<ArgumentNullException>(myo != null, "myo");

            var handler = Triggered;
            if (handler != null)
            {
                var args = new PoseEventArgs(
                    myo,
                    timestamp,
                    pose);
                handler.Invoke(this, args);
            }
        }
コード例 #32
0
ファイル: MyoManager.cs プロジェクト: Hellyon/MyoGame
 public void AddHeldPose(IMyo myo, TimeSpan interval, params Pose[] poses)
 {
     if (!heldPoses.ContainsKey(myo))
     {
         var pose = HeldPose.Create(myo, interval, poses);
         pose.Triggered += Pose_Triggered;
         heldPoses.Add(myo, pose);
         pose.Start();
         return;
     }
     heldPoses[myo].Stop();
     heldPoses[myo].AddPoses(poses);
     heldPoses[myo].Start();
 }
コード例 #33
0
        private void _myoHub_MyoConnected(object sender, MyoEventArgs e)
        {
            _MyMyo = e.Myo;
            e.Myo.Vibrate(VibrationType.Long);

            // Add the pose changed event here
            e.Myo.PoseChanged += Myo_PoseChanged;

            // Unlock the Myo so that it doesn't keep locking between our poses
            e.Myo.Unlock(UnlockType.Hold);

            UpdateUi("Myo Connected: " + e.Myo.Handle);

            //Find The Bricks Ip Address
            FindHostIP();
        }
コード例 #34
0
        protected virtual void OnPoseSequenceCompleted(IMyo myo, DateTime timestamp, IList <Pose> poses)
        {
            // Contract.Requires<ArgumentNullException>(myo != null, "myo");
            // Contract.Requires<ArgumentNullException>(poses != null, "poses");
            // Contract.Requires<ArgumentException>(poses.Count > 0, "The sequence must contain at least one pose.");

            var handler = PoseSequenceCompleted;

            if (handler != null)
            {
                var args = new PoseSequenceEventArgs(
                    myo,
                    timestamp,
                    poses);
                handler.Invoke(this, args);
            }
        }
コード例 #35
0
        public MyoSoundControl(MainWindow Gui)
        {
            this.Window = Gui;
            //Channel und Hub (Schnittstelle) erzeugen
            this.Channel = MyoSharp.Communication.Channel.Create(
                ChannelDriver.Create(ChannelBridge.Create(),
                                     MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            this.Hub          = MyoSharp.Device.Hub.Create(Channel);
            Hub.MyoConnected += (sender, e) =>
            {
                this.myo = e.Myo;
                e.Myo.Vibrate(VibrationType.Long);
                e.Myo.PoseChanged += Myo_PoseChanged;
                e.Myo.Locked      += Myo_Locked;
                e.Myo.Unlocked    += Myo_Unlocked;

                this.myo.Unlock(UnlockType.Hold);

                //Pose in Dictionary mit Sound verbinden (Soundplayerklasse extra)
                this.PoseToSound[Pose.Fist]    = new SoundPlayer("./Sound/Mario.wav");
                this.PoseToSound[Pose.WaveIn]  = new SoundPlayer("./Sound/Glass.wav");
                this.PoseToSound[Pose.WaveOut] = new SoundPlayer("./Sound/Slap.wav");

                //Sequence

                //IPoseSequence sequence0 = PoseSequence.Create(e.Myo, Pose.Fist, Pose.FingersSpread);
                //sequence0.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence0] = new SoundPlayer("./Sound/Mario.wav");

                //IPoseSequence sequence1 = PoseSequence.Create(e.Myo, Pose.WaveIn, Pose.WaveOut);
                //sequence1.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence1] = new SoundPlayer("./Sound/Slap.wav");

                //IPoseSequence sequence2 = PoseSequence.Create(e.Myo, Pose.WaveOut, Pose.WaveIn);
                //sequence2.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence2] = new SoundPlayer("./Sound/Glass.wav");
            };

            Hub.MyoDisconnected += (sender, e) =>
            {
                e.Myo.PoseChanged -= Myo_PoseChanged;
                e.Myo.Locked      -= Myo_Locked;
                e.Myo.Unlocked    -= Myo_Unlocked;
            };
        }
コード例 #36
0
        MainWindow Window; //Forms

        #endregion Fields

        #region Constructors

        public MyoSoundControl(MainWindow Gui)
        {
            this.Window = Gui;
            //Channel und Hub (Schnittstelle) erzeugen
            this.Channel = MyoSharp.Communication.Channel.Create(
                ChannelDriver.Create(ChannelBridge.Create(),
                MyoErrorHandlerDriver.Create(MyoErrorHandlerBridge.Create())));
            this.Hub = MyoSharp.Device.Hub.Create(Channel);
            Hub.MyoConnected += (sender, e) =>
            {
                this.myo = e.Myo;
                e.Myo.Vibrate(VibrationType.Long);
                e.Myo.PoseChanged += Myo_PoseChanged;
                e.Myo.Locked += Myo_Locked;
                e.Myo.Unlocked += Myo_Unlocked;

                this.myo.Unlock(UnlockType.Hold);

                //Pose in Dictionary mit Sound verbinden (Soundplayerklasse extra)
                this.PoseToSound[Pose.Fist] = new SoundPlayer("./Sound/Mario.wav");
                this.PoseToSound[Pose.WaveIn] = new SoundPlayer("./Sound/Glass.wav");
                this.PoseToSound[Pose.WaveOut] = new SoundPlayer("./Sound/Slap.wav");

                //Sequence

                //IPoseSequence sequence0 = PoseSequence.Create(e.Myo, Pose.Fist, Pose.FingersSpread);
                //sequence0.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence0] = new SoundPlayer("./Sound/Mario.wav");

                //IPoseSequence sequence1 = PoseSequence.Create(e.Myo, Pose.WaveIn, Pose.WaveOut);
                //sequence1.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence1] = new SoundPlayer("./Sound/Slap.wav");

                //IPoseSequence sequence2 = PoseSequence.Create(e.Myo, Pose.WaveOut, Pose.WaveIn);
                //sequence2.PoseSequenceCompleted += PoseSequenceCompleted;
                //this.PoseSequenceToSound[sequence2] = new SoundPlayer("./Sound/Glass.wav");
            };

            Hub.MyoDisconnected += (sender, e) =>
            {
                e.Myo.PoseChanged -= Myo_PoseChanged;
                e.Myo.Locked -= Myo_Locked;
                e.Myo.Unlocked -= Myo_Unlocked;
            };
        }
コード例 #37
0
ファイル: MyoInput.cs プロジェクト: SBejga/MyoPilot
        /// <summary>
        /// Initialize the Myo input module. Will throw an exception if no Myo is available
        /// </summary>
        public MyoInput()
        {
            hub = new Hub("de.dhbw.MyoPilot");
            myo = hub.WaitForMyo(TimeSpan.FromSeconds(5));
            if (myo == null)
                throw new TimeoutException("Unable to find a Myo!");

            hub.MyoUnpaired += OnUnpair;

            myo.PoseChanged += OnPoseChanged;
            myo.OrientationDataAcquired += OnOrientationData;
            myo.RecognizedArm += OnRecognizedArm;
            myo.LostArm += OnLostArm;
            myo.Unlock(UnlockType.Hold);

            // hub.Run() needs to run permanently in order to receive events from the Myo
            Thread worker = new Thread(hub.Run) { IsBackground = true, Name = "MyoBackgroundWorker" };
            worker.Start();
        }
コード例 #38
0
        static void Main(string[] args)
        {
            using (var hub = new Hub())
            {
                Console.WriteLine("Attempting to find a Myo...");
                IMyo myo = hub.WaitForMyo(TimeSpan.FromSeconds(10));
                if (myo == null)
                {
                    throw new TimeoutException("Unable to find a Myo!");
                }

                Console.WriteLine("Connected to a Myo armband!\n");

                hub.MyoUnpaired   += OnUnpair;
                hub.RecognizedArm += OnRecognizedArm;
                hub.LostArm       += OnLostArm;

                myo.PoseChanged             += OnPoseChanged;
                myo.OrientationDataAcquired += OnOrientationData;
            }
        }
コード例 #39
0
ファイル: HeldPose.cs プロジェクト: rafme/MyoSharp
        protected virtual void OnTriggered(IMyo myo, DateTime timestamp, Pose pose)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");

            var handler = Triggered;
            if (handler != null)
            {
                var args = new PoseEventArgs(
                    myo,
                    timestamp,
                    pose);
                handler.Invoke(this, args);
            }
        }
コード例 #40
0
 public RssiEventArgs(IMyo myo, DateTime timestamp, sbyte rssi)
     : base(myo, timestamp)
 {
     this.Rssi = rssi;
 }
コード例 #41
0
 public void AddBlob(IMyo myo, Point pos)
 {
     blobs.Add(myo, pos);
     Invalidate();
 }
コード例 #42
0
		public AccelerationChangedEventArgs(RoutedEvent routedEvent, object source, IMyo myo, DateTimeOffset timeStamp, Vector3 acceleration)
			: base(routedEvent, source, myo, timeStamp) 
		{
			Acceleration = acceleration;
		}
コード例 #43
0
		public MyoRoutedEventArgs(RoutedEvent routedEvent, object source, IMyo myo, DateTimeOffset timeStamp) : base(routedEvent, source)
		{
			Myo = myo;
			TimeStamp = timeStamp;
		}
コード例 #44
0
ファイル: EventTypes.cs プロジェクト: st3veV/myo-unity
 public AccelerometerDataEventArgs(IMyo myo, DateTime timestamp, Vector3 accelerometer)
     : base(myo, timestamp)
 {
     this.Accelerometer = accelerometer;
 }
コード例 #45
0
		public OrientationChangedEventArgs(RoutedEvent routedEvent, object source, IMyo myo, DateTimeOffset timeStamp, Quaternion orientation)
			: base(routedEvent, source, myo, timeStamp)
		{
			Orientation = orientation;
		}
コード例 #46
0
 public void DeleteRect(IMyo myo)
 {
     rectangles.Remove(myo);
     Invalidate();
 }
コード例 #47
0
 public EmgDataEventArgs(IMyo myo, DateTime timestamp, Int32[] emg)
     : base(myo, timestamp)
 {
     this.EMG = emg;
 }
コード例 #48
0
 public void AddRect(IMyo myo, Rectangle rect)
 {
     rectangles.Add(myo, rect);
     Invalidate();
 }
コード例 #49
0
ファイル: EventTypes.cs プロジェクト: st3veV/myo-unity
 public ArmSyncedEventArgs(IMyo myo, DateTime timestamp, Arm arm, XDirection xDirection)
     : base(myo, timestamp)
 {
     this.Arm = arm;
     this.XDirection = xDirection;
 }
コード例 #50
0
ファイル: EventTypes.cs プロジェクト: st3veV/myo-unity
 public RssiEventArgs(IMyo myo, DateTime timestamp, sbyte rssi)
     : base(myo, timestamp)
 {
     this.Rssi = rssi;
 }
コード例 #51
0
ファイル: EventTypes.cs プロジェクト: st3veV/myo-unity
 public PoseEventArgs(IMyo myo, DateTime timestamp, Pose pose)
     : base(myo, timestamp)
 {
     this.Pose = pose;
 }
コード例 #52
0
ファイル: EventTypes.cs プロジェクト: st3veV/myo-unity
 public OrientationDataEventArgs(IMyo myo, DateTime timestamp, Quaternion orientation)
     : base(myo, timestamp)
 {
     this.Orientation = orientation;
 }
コード例 #53
0
 public void DeleteBlob(IMyo myo)
 {
     blobs.Remove(myo);
     Invalidate();
 }
コード例 #54
0
ファイル: PoseSequence.cs プロジェクト: VuWall/VuWall-Motion
        protected virtual void OnPoseSequenceCompleted(IMyo myo, DateTime timestamp, IList<Pose> poses)
        {
            Contract.Requires<ArgumentNullException>(myo != null, "myo");
            Contract.Requires<ArgumentNullException>(poses != null, "poses");
            Contract.Requires<ArgumentException>(poses.Count > 0, "The sequence must contain at least one pose.");

            var handler = PoseSequenceCompleted;
            if (handler != null)
            {
                var args = new PoseSequenceEventArgs(
                    myo,
                    timestamp,
                    poses);
                handler.Invoke(this, args);
            }
        }
コード例 #55
0
ファイル: EventTypes.cs プロジェクト: st3veV/myo-unity
 public GyroscopeDataEventArgs(IMyo myo, DateTime timestamp, Vector3 gyroscope)
     : base(myo, timestamp)
 {
     this.Gyroscope = gyroscope;
 }
コード例 #56
0
ファイル: MyoInput.cs プロジェクト: Awoyixiasigema/MyoPilot
 // OnUnpair() is called whenever the Myo is disconnected from Myo Connect by the user.    
 protected void OnUnpair(object sender, MyoEventArgs e)
 {
     lock (myLock)
     {
         myo = null;
         onArm = false;
     }
 }
コード例 #57
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AccelerometerDataEventArgs"/> class.
 /// </summary>
 /// <param name="myo">The Myo that raised the event. Cannot be <c>null</c>.</param>
 /// <param name="timestamp">The timestamp of the event.</param>
 /// <param name="accelerometerData">The accelerometer data. Cannot be <c>null</c>.</param>
 /// <exception cref="System.ArgumentNullException">
 /// The exception that is thrown when <paramref name="myo"/> or <paramref name="accelerometerData"/> is null.
 /// </exception>
 public AccelerometerDataEventArgs(IMyo myo, DateTime timestamp, Vector3F accelerometerData)
     : base(myo, timestamp)
 {
     this.Accelerometer = accelerometerData;
 }
コード例 #58
0
ファイル: EventTypes.cs プロジェクト: st3veV/myo-unity
 public MyoEventArgs(IMyo myo, DateTime timestamp)
 {
     this.Myo = myo;
     this.Timestamp = timestamp;
 }
コード例 #59
0
ファイル: HeldPose.cs プロジェクト: rafme/MyoSharp
        private void Myo_PoseChanged(object sender, PoseEventArgs e)
        {
            var samePose = _lastPose == e.Pose;
            _lastPose = e.Pose;
            _triggeringMyo = e.Myo;

            lock (_timer)
            {
                if (_timerAlive)
                {
                    return;
                }

                if (samePose && _targetPoses.Contains(e.Pose))
                {
                    if (_timerPaused)
                    {
                        _timerPaused = false;
                        _timer.Start();
                    }
                }
                else
                {
                    _timerPaused = true;
                    _timer.Stop();
                }
            }
        }
コード例 #60
0
 public void UpdateRect(IMyo myo, Rectangle rect)
 {
     rectangles[myo] = rect;
     Invalidate();
 }