I'm storing a degree reading from a sensor in a type double variable in a WPF application, degreeOutput
from a Thalmic Lab's Myo sensor. The value stored in the variable is constantly changing as the user moves their arm, but I want to store the degree reading at a certain point in a movement when the person makes a fist
pose not the constantly changing value.
In my current implementation, I trigger the value of degreeOutput
to be displayed in the painfulArcStartTbx
to signify the start value of the arc I want to measure, but this doesn't work as planned.
Instead when the fist is held the degree value is output to the textbox but is constantly changing.
I want only the initial reading to be output when a fist is held not any reading after that.
The end reading of the arc is supposed to be output after the fist pose is let go, but I get the same behavior as above.
Does anyone have any advice on how I can store just the current value at the point the fist is held and the current value at which the fist pose is let go?
This is the method where the degree output is processed:
private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
{
App.Current.Dispatcher.Invoke((Action)(() =>
{
//need to record degree reading when pose made that
//signifies begining of painful arc.
//then specify a second pose that signals the end of
//painful arc and store arc reading, eg 92dg - 108dg
//myo indicator must be facing down or degrees will be inverted.
degreeOutput = ((e.Pitch + PITCH_MIN) * CALLIBRATION_FACTOR);
degreeOfAbductionTbx.Text = "Degree: " + degreeOutput;
if(e.Myo.Pose == Pose.Fist)
{
//get the start reading of the painful arc
painfulArcStartTbx.Text = "start: " + degreeOutput;
}
//then get the finish reading of the painful arc
//after the fist pose has been let go, indicating
//end of pain in movement
else
{
painfulArcEndTbx.Text = "end: " + degreeOutput;
}
}));
}
I may be totally wrong here as i've no idea what that sensor is, but it seems you're missing something very basic:
private string startingDegree;
private string endDegree;
private void Myo_OrientationDataAcquired(object sender, OrientationDataEventArgs e)
{
App.Current.Dispatcher.Invoke((Action)(() =>
{
//need to record degree reading when pose made that
//signifies begining of painful arc.
//then specify a second pose that signals the end of
//painful arc and store arc reading, eg 92dg - 108dg
//myo indicator must be facing down or degrees will be inverted.
degreeOutput = ((e.Pitch + PITCH_MIN) * CALLIBRATION_FACTOR);
degreeOfAbductionTbx.Text = "Degree: " + degreeOutput;
if(e.Myo.Pose == Pose.Fist)
{
endDegree = string.Empty;
if(string.IsNullOrEmpty(startingDegree))
{
startingDegree = "start: " + degreeOutput;
}
//get the start reading of the painful arc
painfulArcStartTbx.Text = startingDegree;
}
//then get the finish reading of the painful arc
//after the fist pose has been let go, indicating
//end of pain in movement
else
{
startingDegree = string.Empty;
if(string.IsNullOrEmpty(endDegree))
{
endDegree = "end: " + degreeOutput;
}
painfulArcEndTbx.Text = endDegree;
}
}));
}