ksf
Dependents: kinematics_controlv2 kinematics_controlv4 kinematics_control_copyfds Robot_control
Revision 2:1a677b57ce81, committed 2017-11-01
- Comitter:
- peterknoben
- Date:
- Wed Nov 01 13:42:01 2017 +0000
- Parent:
- 1:15543c143a63
- Child:
- 3:f8d57796d69b
- Commit message:
- This works, sort of;
Changed in this revision
signalnumber.cpp | Show annotated file Show diff for this revision Revisions of this file |
signalnumber.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
--- a/signalnumber.h Tue Oct 31 14:34:30 2017 +0000 +++ b/signalnumber.h Wed Nov 01 13:42:01 2017 +0000 @@ -17,9 +17,9 @@ float getmean(const int n, float input); - int getnumber(const int n, const int action, double input, float k); + int getnumber(const int n, const int action, float input, float k); - int getmode(const int n, const int action, double input, float k); // In progress + int getmode(const int n, const int action, float input, float k); // In progress private: