PES 2 - Gruppe 1 / Mbed 2 deprecated Robocode_Random

Dependencies:   mbed

Fork of Robocode by PES 2 - Gruppe 1

Revision:
23:4ddc4216f335
Parent:
22:c8e187b9d949
Child:
24:6c2fec64f890
diff -r c8e187b9d949 -r 4ddc4216f335 source/movement.cpp
--- a/source/movement.cpp	Fri Mar 03 20:44:01 2017 +0000
+++ b/source/movement.cpp	Sat Mar 04 13:57:41 2017 +0000
@@ -35,8 +35,8 @@
     pwmL.period(0.00005f); // Setzt die Periode auf 50 μs
     pwmR.period(0.00005f);
 
-    pwmL = 0.5f; // Setzt die Duty-Cycle auf 50%
-    pwmR = 0.5f;
+    pwmL.write(0.5f); // Setzt die Duty-Cycle auf 50%
+    pwmR.write(0.5f);
     enableMotorDriver = 1;
 
     EncoderCounterLeft = 0;
@@ -46,8 +46,8 @@
 
 void move_forward_slow(float correction_value)
 {
-   pwmL = power_value_slow;
-   pwmR = 1-power_value_slow*correction_value;
+    pwmL.write(power_value_slow);
+    pwmR.write(1-power_value_slow*correction_value);
 
 }
 
@@ -91,7 +91,7 @@
 void highPulseDetectedL()
 {
     EncoderCounterLeft += 1;
-   // led = 1;
+    // led = 1;
 }
 
 void highPulseDetectedR()
@@ -102,24 +102,27 @@
 void sync_movement(bool speed, bool direction)
 {
 
- /*   if(EncoderLeftA) {
-        led = 1;
-    } else {
-        led = 0;
-    }*/
+    /*   if(EncoderLeftA) {
+           led = 1;
+       } else {
+           led = 0;
+       }*/
 
 
 // PID correction Value calcualtion
 
-       if(EncoderCounterLeft > EncoderCounterRight) {
-           PID_correction_value += 0.0001f;
+    if(EncoderCounterLeft > EncoderCounterRight) {
+        PID_correction_value += 0.0001f;
 
-           printf("Left higher");
-       } else {
-
-           PID_correction_value -= 0.0001f;
-           printf("right higher");
-       }
+        printf("Left higher");
+    } else {
+        if(EncoderCounterLeft < EncoderCounterRight) {
+            PID_correction_value -= 0.0001f;
+            printf("Right higher");
+        } else {
+            printf("Even");
+        }
+    }
 
     /*    if(PID_correction_value < 0.0f) {
             PID_correction_value = 0;