Updates error values
Dependents: locomotion_pid_action_refactor_EMG
Diff: errorFetch.cpp
- Revision:
- 4:2af658a4e54b
- Parent:
- 3:71a7dd98fb2c
diff -r 71a7dd98fb2c -r 2af658a4e54b errorFetch.cpp --- a/errorFetch.cpp Sun Oct 22 08:01:40 2017 +0000 +++ b/errorFetch.cpp Thu Oct 26 14:02:01 2017 +0000 @@ -7,11 +7,13 @@ errorFetch::errorFetch(float N, float Ts):gearRatio(N), Ts(Ts), e_pos(0), e_int(0), e_der(0), e_prev(0){ } + +double errorFetch::fetchMotorPosition(int counts){ + double motorPosition = 2*3.14*(counts/(gearRatio*64.0f)); + return motorPosition; + } -void errorFetch::fetchError(int counts, float ref){ - // Calculating motor position based on encoder counts - double motorPosition = 2*3.14*(counts/(gearRatio*64.0f)); - +void errorFetch::fetchError(double motorPosition, double ref){ // Computing position error e_pos = ref - motorPosition;