Updates error values

Dependents:   locomotion_pid_action_refactor_EMG

Revision:
2:d22c458a8a78
Parent:
1:9e2c9237d88b
Child:
3:71a7dd98fb2c
diff -r 9e2c9237d88b -r d22c458a8a78 errorFetch.cpp
--- a/errorFetch.cpp	Fri Oct 20 16:29:30 2017 +0000
+++ b/errorFetch.cpp	Sun Oct 22 07:56:59 2017 +0000
@@ -5,16 +5,16 @@
 #include "refGen.h"
 
 // Member function definitions
-errorFetch::errorFetch(refGen REF, float N, float Ts):ref(REF), gearRatio(N), Ts(Ts), e_pos(0), e_int(0), e_der(0), e_prev(0){
+errorFetch::errorFetch(float N, float Ts):gearRatio(N), Ts(Ts), e_pos(0), e_int(0), e_der(0), e_prev(0){
 
     }
     
-void errorFetch::fetchError(int counts){
+void errorFetch::fetchError(int counts, float ref){
     // Calculating motor position based on encoder counts
     double motorPosition = 2*3.14*(counts/(gearRatio*64.0f));
-
+    
     // Computing position error
-    e_pos = ref.getReferencePosition() - motorPosition;
+    e_pos = ref - motorPosition;
     
     // Limiting the integral error to prevent integrator saturation
     if(fabs(e_int) <= 5){
@@ -24,4 +24,5 @@
     // Derivative error   
     e_der = (e_pos - e_prev)/Ts;
     e_prev = e_pos; // Store current position error as we'll need it to compute the next derivative error
-    }
\ No newline at end of file
+    }
+