Alexander Lüthard / Mbed 2 deprecated Micromouse

Dependencies:   mbed

Fork of Micromouse by Helvijs Kiselis

Revision:
2:f898adf2d817
Parent:
1:2b5f79285a3e
Child:
3:076dd7ec7eb4
--- a/Motion.cpp	Thu Apr 19 06:19:43 2018 +0000
+++ b/Motion.cpp	Thu Apr 19 11:26:51 2018 +0000
@@ -165,7 +165,120 @@
         
         stop();
 }
-
+/**
+ * Links abbiegen
+ */
+void Motion::turnL() {
+    
+        
+        controller.counterReset();
+        countsLOld = counterLeft.read();
+        countsROld = counterRight.read();
+        countsL = counterLeft.read();
+        countsR = counterRight.read();
+        
+        controller.setDesiredSpeedLeft(50.0f);
+        controller.setDesiredSpeedRight(-50.0f);
+        
+        while ((countsL - countsLOld)  < 824 || (countsR - countsROld) > -824) {
+            
+            countsL = counterLeft.read();
+            countsR = counterRight.read();
+        
+            if (enableMotorDriver == 0) {enableMotorDriver = 1;}
+        }      
+        
+        controller.counterReset();
+        countsLOld = counterLeft.read();
+        countsROld = counterRight.read();
+        countsL = counterLeft.read();
+        countsR = counterRight.read();
+        
+        controller.setDesiredSpeedLeft(17.0f);
+        controller.setDesiredSpeedRight(-83.0f);  
+        
+        while ((countsL - countsLOld)  < 440 || (countsR - countsROld) > -2148) {
+            
+            countsL = counterLeft.read();
+            countsR = counterRight.read();
+        
+            if (enableMotorDriver == 0) {enableMotorDriver = 1;}
+        } 
+        
+        controller.counterReset();
+        countsLOld = counterLeft.read();
+        countsROld = counterRight.read();
+        countsL = counterLeft.read();
+        countsR = counterRight.read();
+        
+        controller.setDesiredSpeedLeft(50.0f);
+        controller.setDesiredSpeedRight(-50.0f);  
+        
+        while ((countsL - countsLOld)  < 824 || (countsR - countsROld) > -824) {
+            
+            countsL = counterLeft.read();
+            countsR = counterRight.read();
+        
+            if (enableMotorDriver == 0) {enableMotorDriver = 1;}
+        }         
+}
+/**
+ * Rechts abbiegen
+ */
+void Motion::turnR() {
+    
+        
+        controller.counterReset();
+        countsLOld = counterLeft.read();
+        countsROld = counterRight.read();
+        countsL = counterLeft.read();
+        countsR = counterRight.read();
+        
+        controller.setDesiredSpeedLeft(50.0f);
+        controller.setDesiredSpeedRight(-50.0f);
+        
+        while ((countsL - countsLOld)  < 824 || (countsR - countsROld) > -824) {
+            
+            countsL = counterLeft.read();
+            countsR = counterRight.read();
+        
+            if (enableMotorDriver == 0) {enableMotorDriver = 1;}
+        }      
+        
+        controller.counterReset();
+        countsLOld = counterLeft.read();
+        countsROld = counterRight.read();
+        countsL = counterLeft.read();
+        countsR = counterRight.read();
+        
+        controller.setDesiredSpeedLeft(83.0f);
+        controller.setDesiredSpeedRight(-17.0f);
+        
+        while ((countsL - countsLOld)  < 2148 || (countsR - countsROld) > -440) {
+            
+            countsL = counterLeft.read();
+            countsR = counterRight.read();
+        
+            if (enableMotorDriver == 0) {enableMotorDriver = 1;}
+        }    
+        
+        controller.counterReset();
+        countsLOld = counterLeft.read();
+        countsROld = counterRight.read();
+        countsL = counterLeft.read();
+        countsR = counterRight.read();
+        
+        controller.setDesiredSpeedLeft(50.0f);
+        controller.setDesiredSpeedRight(-50.0f);
+        
+        while ((countsL - countsLOld)  < 824 || (countsR - countsROld) > -824) {
+            
+            countsL = counterLeft.read();
+            countsR = counterRight.read();
+        
+            if (enableMotorDriver == 0) {enableMotorDriver = 1;}
+        }      
+}
 /**
  * Motor Stop
  */