Calling the pose triggered event using Myo arm band

我的未来我决定 提交于 2019-12-25 06:25:26

问题


I'm developing a project in WPF using a Myo arm band which works so far in recognizing the device has connected and updates info to the textbox, but when I set up the event handler for recognizing if a pose is triggered the event never fires.

I debugged this by making poses with the device and holding them, also I set a break point on this line pose.Triggered += Pose_Triggered; and the start of the pose triggered event.

The break point triggers on the first line where the but it doesn't trigger the breakpoint on the actual event private void Pose_Triggered(object sender, PoseEventArgs e)

This is the C# wrapper I'm using for the project: https://github.com/tayfuzun/MyoSharp

Does anyone know why the event doesn't trigger although the poses are being made?

This is the method where pose_triggered is called and the event:

// 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;



                    }));

                };

Code for triggered event:

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;

            }));    
        }

Here is the complete code for the class: http://hastebin.com/xinirugufo.cs


回答1:


I compare the sample code from GitHub and your. Did you forget to call pose.Start()?

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


来源:https://stackoverflow.com/questions/27953938/calling-the-pose-triggered-event-using-myo-arm-band

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!