Buggy bois / Mbed 2 deprecated HEATS_1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
UditSrivastav
Date:
Mon Apr 29 00:57:32 2019 +0000
Parent:
11:78c645fb76cd
Commit message:
WORKS

Changed in this revision

Robot.h Show annotated file Show diff for this revision Revisions of this file
--- a/Robot.h	Sun Apr 28 22:20:28 2019 +0000
+++ b/Robot.h	Mon Apr 29 00:57:32 2019 +0000
@@ -16,9 +16,8 @@
     Ticker updater;
     Timeout timeToStop;
     
-    float endOfLineDetection;
     float Reflec;
-    
+    int endOfLineDetection;
     float RoboticAngularVelocity;
     
     char state;
@@ -27,6 +26,7 @@
     
     Robot(Wheel* LW, Wheel* RW, lineSensor* SA[]) : controller(2.0f, 0.0f, 0.0f, 0.0006f) //this controller actually does nothing atm
     {
+        endOfLineDetection = 0;
         updater.detach();
         timeToStop.detach();
         AF  = 0.7f; //change this value to change max speedzzzzzzzzzzzzzzzzz
@@ -143,27 +143,27 @@
         {
         case 0:
             lineVoltages[lvIndex%numberOfSamples] = (reading * -260.0f); 
-            if (reading <= Reflec*8){endOfLineDetection++;}
+            if (reading <= 0.1f){endOfLineDetection++;}
             break;
         case 1:
             lineVoltages[lvIndex%numberOfSamples] += (reading * -105.0f);
-            if (reading <= Reflec*8) {endOfLineDetection++;}
+            if (reading <= 0.1f) {endOfLineDetection++;}
             break;
         case 2:
             lineVoltages[lvIndex%numberOfSamples] += (reading * -32.5f);
-            if (reading <= Reflec*8) {endOfLineDetection++;}
+            if (reading <= 0.1f) {endOfLineDetection++;}
             break;
         case 3:
             lineVoltages[lvIndex%numberOfSamples] += (reading * 32.5f);
-            if (reading <= Reflec*8) {endOfLineDetection++;}
+            if (reading <= 0.1f) {endOfLineDetection++;}
             break;
         case 4: 
             lineVoltages[lvIndex%numberOfSamples] += (reading * 75.0f);
-            if (reading <= Reflec*8) {endOfLineDetection++;}
+            if (reading <= 0.1f) {endOfLineDetection++;}
             break;
         case 5:
             lineVoltages[lvIndex%numberOfSamples] += (reading * 175.0f);
-            if (reading <= Reflec*8) {endOfLineDetection++;}
+            if (reading <= 0.1f) {endOfLineDetection++;}
             break;
         }
                 
@@ -171,10 +171,9 @@
         if (sensorNumber >= numberOfSensors)
         {
             sensorNumber = 0;
-            if (endOfLineDetection < 6)
+            if (endOfLineDetection < 5)
             {
-                //AF = scaler(-180.0f,180.0f, 0.2f, 1.0f, lineVoltages[lvIndex%numberOfSamples]);
-                AF = 0.7f;
+                AF = 0.425f;
                 adjustRbtAngularVelocity(lineVoltages[lvIndex%numberOfSamples]);
                 lvIndex++;
             }