Generates reference based on analog input
Dependents: locomotion_pid_action_refactor_EMG
Diff: refGen.cpp
- Revision:
- 4:38af2aa14a3f
- Parent:
- 3:43d9f8db93b7
- Child:
- 5:7186da6f562f
diff -r 43d9f8db93b7 -r 38af2aa14a3f refGen.cpp --- a/refGen.cpp Fri Oct 20 16:28:30 2017 +0000 +++ b/refGen.cpp Sun Oct 22 08:01:03 2017 +0000 @@ -1,12 +1,13 @@ #include "refGen.h" #include "mbed.h" +#include "biquadChain.h" // Member function definitions refGen::refGen(PinName a, float maxAngle):refPin(a), maxAngle(maxAngle), r_direction(false){ } -float refGen :: getReferencePosition(){ +float refGen :: getReference(){ float r; if(r_direction == false){ // Clockwise rotation yields positive reference @@ -17,4 +18,19 @@ r = -1*maxAngle*refPin.read(); } return r; + } + +float refGen :: getFilteredReference(biquadChain BQC){ + float r; + if(r_direction == false){ + // Clockwise rotation yields positive reference + r = maxAngle*refPin.read(); + r = BQC.applyFilter(r); + } + if(r_direction == true){ + // Counterclockwise rotation yields negative reference + r = -1*maxAngle*refPin.read(); + r = BQC.applyFilter(r); + } + return r; } \ No newline at end of file