我正在WPF中开发一个项目,使用Myo arm带,到目前为止,它可以识别设备已经连接并更新到textbox的信息,但是当我设置事件处理程序来识别是否触发一个姿势时,事件永远不会触发。
我通过用设备摆姿势并拿着它们来调试这个问题,我还在这条线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;
}));
}下面是该类的完整代码:http://hastebin.com/xinirugufo.cs
发布于 2015-01-15 02:57:33
我比较了来自GitHub的示例代码和你的。你忘了给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
复制相似问题