READY TO RUMBLE

Dependencies:   mbed

Fork of Micromouse_alpha_copy_copy by PES2_R2D2.0

Revision:
2:592f01278db4
Parent:
1:d9e840c48b1e
Child:
3:2ec7cf8bc3fc
--- a/main.cpp	Sat Mar 31 16:45:57 2018 +0000
+++ b/main.cpp	Wed Apr 04 15:24:28 2018 +0000
@@ -8,7 +8,7 @@
 #include "Drive.h"
 #include "CheckWalls.h"
 #include "Turn.h"
-#include "Parallel.h"
+
 
 
 //Initialisierung LEDs Blinker/Surri/Button
@@ -75,19 +75,20 @@
 {
 
 
-
+    
 
     enableMotorDriver = 1; // Schaltet den Leistungstreiber ein
     enable = 1;
 
+
     while(1) { // Wiederholungsschleife
 
         //Ablauf ist jeweils immer Feldweise...Waende checken, allenfalls drehen (Ausrichten), waehrend der Fahrt nur Ausrichtung der Geradeausfahrt...
     
-        printf("WARTE AUF START....");
+        //printf("WARTE AUF START....");
 
         while (button) {
-            wait(1.0f); //Die Ruhe vor dem Sturm...
+           wait(1.0f); //Die Ruhe vor dem Sturm...
         }
 
 
@@ -109,8 +110,8 @@
             //Decide??
             Turn turn(counterLeft, counterRight, controller, wallRight, wallFront, wallLeft);   //Nach Ausrichtung bewegt sich der Roboter um ein Feld weiter und die Ausrichutung beginnt von vorne
             KontrastSensor kontrastSensor(kontrast, blackLine); 
-            Drive drive(kontrastSensor, counterLeft, counterRight, controller, distanceLeftFront, distanceLeftBack, distanceFront); //20cm nach vorne...
-            Parallel parallel(distanceLeftFront, distanceLeftBack);                                                 
+            Drive drive(kontrastSensor, counterLeft, counterRight, controller, distanceRight, distanceFront, distanceLeftFront, distanceLeftBack,); //20cm nach vorne...
+                                                           
             
             switch(state) { //Ausrichten
                 case 0: {
@@ -122,28 +123,30 @@
                 }
                 case 1: {//Fahrzyklus
                     
-                    //checkWalls.check(); //prueft wo Waende vorhanden sind
+                    checkWalls.check(); //prueft wo Waende vorhanden sind
                     
                     //wallRight = 1;
                     //wallFront = 1;
                     //wallLeft = 1;
                     
-                    //turn.turning(); //entscheidet welche Richtung und Wendet dann zu dieser...
+                    turn.turning(); //entscheidet welche Richtung und Wendet dann zu dieser...
                     
-                    controller.setDesiredSpeedRight(0.5f);
-                    controller.setDesiredSpeedLeft(-0.5f);
-                    //drive.driving(); //faehrt, kontrolliert ob richtig steht und achtet auch schwarze Linie am Boden
+
+                    drive.driving(); //faehrt, kontrolliert ob richtig steht und achtet auch schwarze Linie am Boden
 
+                   
                     
-                    blackLine = 1;
+                    //blackLine = 1;
                     if(blackLine == 1){  //ist schwarze Linie ueberfahren...stoppt der Fahrzyklus hier.
                     
-                        state = 2;
+                       state = 2;
                     }
                     break;
                 }
                 case 2: { //Ziel erreicht
                     
+                        controller.setDesiredSpeedRight(0.0f);
+                        controller.setDesiredSpeedLeft(0.0f);
                     
                     //"Stop"
                     //mode=2
@@ -155,24 +158,27 @@
                 }
             }
 
-            printf("iSumLeft: %f, iSumRight: %f, counterDiff; %d , SpeedRight: %f, SpeedLeft: %f, ProportionalRight: %f, ProportionalLeft: %f \n\r", controller.getIntegralLeft(), controller.getIntegralRight(), (counterLeft.read()+counterRight.read()), controller.getSpeedRight(), controller.getSpeedLeft(), controller.getProportionalRight(), controller.getProportionalLeft());
-           
-            
-            //printf("DistanzRechts = %.0f mm\n", distanceRight);
-            //printf("DistanzVorne = %.0f mm\n", distanceFront);
-           // printf("DistanzLinksVorne = %.0f mm\n", distanceLeftFront);
-           // printf("DistanzLinksHinten = %.0f mm\n", distanceLeftBack);
-           // printf("WandRechts = %d \n", wallRight);
-           // printf("WandVorne = %d \n", wallFront);
-           // printf("WandLinks = %d \n", wallLeft);
-            
-            //printf("CountsRight = %d\n", counterRight.read());
-            //printf("CountsLeft = %d\n", counterLeft.read());  
+                    
+
+
+            printf("DistanzRechts = %.0f mm\n\r", distanceRight);
+            printf("DistanzVorne = %.0f mm\n\r", distanceFront);
+            printf("DistanzLinksVorne = %.0f mm\n\r", distanceLeftFront);
+            printf("DistanzLinksHinten = %.0f mm\n\r", distanceLeftBack);
+            printf("WandRechts = %d \n\r", wallRight);
+            printf("WandVorne = %d \n\r", wallFront);
+            printf("WandLinks = %d \n\r", wallLeft);
+                      
+             
+           // printf("CountsRight = %d\n", counterRight.read());
+           // printf("CountsLeft = %d\n", counterLeft.read());  
             //kontrastSensor.check();
             //printf("SchwarzeLinie  =  %d", blackLine);
             myled =! myled; // LED is ON Heartbeat
-            wait(0.5f); 
+           // wait(0.5f); 
 
-        }
+        }//Ende while mode==1
+        
+
     }
 }