Buggy bois / Mbed 2 deprecated headache

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
UditSrivastav
Date:
Mon Apr 29 09:40:30 2019 +0000
Parent:
12:11d203351eb0
Commit message:
Anythign um

Changed in this revision

PID.h Show annotated file Show diff for this revision Revisions of this file
Robot.h Show annotated file Show diff for this revision Revisions of this file
SensorControl/lineSensor.h Show annotated file Show diff for this revision Revisions of this file
WheelControl/Wheel.h Show annotated file Show diff for this revision Revisions of this file
--- a/PID.h	Mon Apr 29 00:57:32 2019 +0000
+++ b/PID.h	Mon Apr 29 09:40:30 2019 +0000
@@ -82,6 +82,13 @@
         return   prevControlAction;
     }
     
+    void reset()
+    {
+        prevControlAction = 0;
+        PrevPrevErr = 0;
+        PrevErr = 0;
+    }
+    
 };
 
 //(((temp-inMin)/(inMax - inMin))*(outMax-outMin))+outMin
\ No newline at end of file
--- a/Robot.h	Mon Apr 29 00:57:32 2019 +0000
+++ b/Robot.h	Mon Apr 29 09:40:30 2019 +0000
@@ -173,13 +173,15 @@
             sensorNumber = 0;
             if (endOfLineDetection < 5)
             {
-                AF = 0.425f;
+                AF = 0.5f;
                 adjustRbtAngularVelocity(lineVoltages[lvIndex%numberOfSamples]);
                 lvIndex++;
             }
             else
             {
-               stopMovement(); 
+               stopMovement();
+               rightWheel->resetPID();
+               leftWheel->resetPID();
             }
         endOfLineDetection = 0;
         }
@@ -187,10 +189,13 @@
     
     void turn180()
     {
+        stopMovement();
+        rightWheel->resetPID();
+        leftWheel->resetPID();
         updater.detach();
         rightWheel->adjustAngularVelocity(rightWheel->returnMaxAngularVel()*0.3f);
         leftWheel->adjustAngularVelocity(rightWheel->returnMaxAngularVel()*-0.3f);
-        timeToStop.attach(callback(this, &Robot::reAttach),1.1f);
+        timeToStop.attach(callback(this, &Robot::reAttach),1.0f);
         state = 'S';
     }
     
--- a/SensorControl/lineSensor.h	Mon Apr 29 00:57:32 2019 +0000
+++ b/SensorControl/lineSensor.h	Mon Apr 29 09:40:30 2019 +0000
@@ -9,7 +9,7 @@
     Timeout sampler;
     
     public:
-    float static const sampleTime = 0.00004f;
+    float static const sampleTime = 0.00009f;
     
     lineSensor(PinName E, PinName R):emitter(E), receiver(R)
     {   
--- a/WheelControl/Wheel.h	Mon Apr 29 00:57:32 2019 +0000
+++ b/WheelControl/Wheel.h	Mon Apr 29 09:40:30 2019 +0000
@@ -60,6 +60,11 @@
         return angularVelocity;
     }
     
+    void resetPID()
+    {
+        controller.reset();
+    }
+    
     //only called once during initialization to calculate max angular velocity 
     //dir = direction, do opposite for each wheel just so your buggy doesn't move FORWARD but rather rotates
     void init(int dir)