问题
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