使用 Myo 臂带调用姿势触发事件

Calling the pose triggered event using Myo arm band

我正在使用 Myo 臂带在 WPF 中开发一个项目,到目前为止,它可以识别设备已连接并将信息更新到文本框,但是当我设置事件处理程序以识别姿势是否被触发时事件永远不会触发。

我通过用设备摆姿势并按住它们来调试这个,我还在这条线 pose.Triggered += Pose_Triggered; 和姿势触发事件的开始设置了一个断点。

断点在第一行触发,但不会在实际事件上触发断点private void Pose_Triggered(object sender, PoseEventArgs e)

这是我用于项目的 C# 包装器:https://github.com/tayfuzun/MyoSharp

有谁知道为什么虽然正在摆姿势但事件没有触发?

这是调用 pose_triggered 的方法和事件:

// listen for when the Myo connects
                hub.MyoConnected += (sender, e) =>
                {

                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        statusTbx.Text = "Myo has connected! " + e.Myo.Handle;
                        e.Myo.Vibrate(VibrationType.Short);

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

                        // setup for the pose we want to watch for
                        var pose = HeldPose.Create(e.Myo, Pose.Fist);


                        pose.Triggered += Pose_Triggered;
                        e.Myo.OrientationDataAcquired += Myo_OrientationDataAcquired;



                    }));

                };

触发事件代码:

private void Pose_Triggered(object sender, PoseEventArgs e)
        {
            App.Current.Dispatcher.Invoke((Action)(() =>
            {
                //need to measure abduction of arm from 0 to 180 degrees.
                poseStatusTbx.Text = "{0} arm Myo holding pose {1}" + e.Myo.Arm + e.Myo.Pose;

                pitch = pitchCentre;

            }));    
        }

这是 class 的完整代码:http://hastebin.com/xinirugufo.cs

我比较了 sample code from GitHub 和你的。你忘了打电话给 pose.Start() 了吗?

var pose = HeldPose.Create(e.Myo, Pose.Fist);
pose.Interval = TimeSpan.FromSeconds(0.5); 
pose.Start(); //this???
pose.Triggered += Pose_Triggered;