ksf
Dependents: kinematics_controlv2 kinematics_controlv4 kinematics_control_copyfds Robot_control
Diff: signalnumber.cpp
- Revision:
- 2:1a677b57ce81
- Parent:
- 1:15543c143a63
- Child:
- 3:f8d57796d69b
diff -r 15543c143a63 -r 1a677b57ce81 signalnumber.cpp --- a/signalnumber.cpp Tue Oct 31 14:34:30 2017 +0000 +++ b/signalnumber.cpp Wed Nov 01 13:42:01 2017 +0000 @@ -4,7 +4,7 @@ //Constants for mean value const int n = 400; //Window size for the mean value -float emg0_filtered[n] = {}; +float emg_filtered[n] = {}; int count = 0; int count2 = 0; float mean = 0.0; @@ -19,7 +19,7 @@ const float RightSlowmin=0.4; const float RightSlowmax=0.65; const float RightFastmin=0.7; -const float RightFastmax=1.5; +const float RightFastmax=10.5; int Number = 0; //const int action =50; @@ -44,31 +44,36 @@ // Determine the mean value of the last "n" amount of numbers. float SignalNumber::getmean(const int n, float input){ - emg0_filtered[count] = input; + emg_filtered[count] = input; count++; if (count == n){ count = 0; } - float mean_math = getsum(emg0_filtered,n)/n; + float mean_math = getsum(emg_filtered,n)/n; return mean_math; } - - +/* +float SignalNumber::getmean(float array[], const int n, float input){ + float sum_math = 0; + + +} +*/ float SignalNumber::calibrate(const int n, float input){ float offset = getmean(n, input); return offset; } - - //Determine the right signal number /* There will be checked in which range the mean value lies. If the value lies within this range for "action" samples the switch will be changed to the right mode. If the mean value changes outside of the region the switch will be set to 0, this is the resting state. Also the counter will be reset. +n is the amount of samples in the window +action is the amount of same mean values */ -int SignalNumber::getnumber(const int n, const int action, double input, float k){ +int SignalNumber::getnumber(const int n, const int action, float input, float k){ mean = getmean(n, input)*k; //Check first case if( mean < LeftFastmin ) { @@ -161,7 +166,7 @@ // In progress -int SignalNumber::getmode(const int n, const int action, double input, float k){ +int SignalNumber::getmode(const int n, const int action, float input, float k){ int mode; mean = getmean(n, input)*k; //Check first case