Buggy bois / Mbed 2 deprecated headache

Dependencies:   mbed

Revision:
11:78c645fb76cd
Parent:
10:acf5cb8d58d5
Child:
13:521d6c6e7042
--- a/WheelControl/Wheel.h	Sun Apr 28 18:27:46 2019 +0000
+++ b/WheelControl/Wheel.h	Sun Apr 28 22:20:28 2019 +0000
@@ -26,7 +26,7 @@
     
     float static const wheelDiameter = 0.18; //used in calculation of Linear velocity i.e never
     
-    Wheel (Encoder* E, PinName M, PinName D, PinName Mode) : Mtr(M), direction(D), polarity(Mode), controller(gain,4.0f,0.00002f,0.0003f)
+    Wheel (Encoder* E, PinName M, PinName D, PinName Mode) : Mtr(M), direction(D), polarity(Mode), controller(gain,4.0f,0.0f,0.0003f)
         {
         maxAngularVel = 0.0f;
         enc = E;
@@ -78,7 +78,7 @@
         maxAngularVel = 75.0f;
         minAngularVel = -1.0f*maxAngularVel;
         controller.setSetPoint(0.0f);
-        updater.attach(callback(this, &Wheel::wheelUpdates),0.0005f);
+        updater.attach(callback(this, &Wheel::wheelUpdates),0.0003f);
     }
     
     void startController()
@@ -93,17 +93,11 @@
     
     void wheelUpdates(void) //sampling rate the ticker is attached I.E the wheel speed is updated everytime this function is called
         {
-            if (br == 0) {
             calculateAngularVelocity();
             //distance += angularVelocity*(wheelDiameter/2)*0.0005f;
             float temp2 = controller.compute(angularVelocity); //another temporary value to store the computed angular velocity
             if (temp2 < 0) {direction = 0;} else {direction = 1;} //change direction according to the computed value
             Mtr.write((1.0f - abs(temp2))); //write the value as a pwm
-            }
-            else
-            {
-                return;
-            }
         }
         
     void adjustAngularVelocity(float W) // W = angular velocity you want, obviously putting a |w| value that is > max angular velocity will set dutcy cycle to max
@@ -145,8 +139,7 @@
     
     void brake()
     {
-        direction = 0;
-        Mtr.write(0);
+        
     }
     
 };
\ No newline at end of file