car using PID from centre line

Dependencies:   FRDM-TFC mbed CBuffer XBEE mbed_angular_speed motor2 MMA8451Q

Fork of KL25Z_Camera_Test by GDP 4

Revision:
46:6806ea59ffed
Parent:
45:3435bdd2d487
Child:
47:6a58dcef714f
--- a/main.cpp	Thu Mar 23 09:36:39 2017 +0000
+++ b/main.cpp	Mon Mar 27 17:53:17 2017 +0000
@@ -80,10 +80,10 @@
                 accc = checkAcc();
             }
             
-            if(accc < 0.18f) {
+            if(accc < 0.2f) {
                 handleStartStop(); 
             } else {    
-                sendString("up %f", accc);    
+                //sendString("up %f", accc);    
             }
             
             
@@ -165,17 +165,17 @@
                     break;
                 case 1:
                      initPID(&servo_pid, 2.2f, 0.6f, 0.f);
-                     speed = 120;
+                     speed = 80;
                      ed_tune = 1.0f;
                     break;
                 case 2:
                      initPID(&servo_pid, 2.2f, 0.6f, 0.f);
-                     speed = 130;
+                     speed = 100;
                      ed_tune = 1.0f;
                     break;
                 case 3:
                      initPID(&servo_pid, 2.2f, 0.6f, 0.f);
-                     speed = 140;
+                     speed = 120;
                      ed_tune = 1.0f;
                     break;
             }
@@ -201,8 +201,8 @@
 void initVariables() {
     // Initialise three PID controllers for the servo and each wheel.
     initPID(&servo_pid, 0.f, 0.f, 0.f);
-    initPID(&left_motor_pid, 0.007f, 0.f, 0.f);
-    initPID(&right_motor_pid, 0.007f, 0.f, 0.f);
+    initPID(&left_motor_pid, 0.01f, 0.f, 0.f);
+    initPID(&right_motor_pid, 0.01f, 0.f, 0.f);
     
     right_motor_pid.desired_value=0;
     left_motor_pid.desired_value=0;
@@ -438,6 +438,9 @@
     if(left_motor_pid.output > 1.0f) {
        left_motor_pid.output = 1.0f; 
     }
+    if(left_motor_pid.output > 0.75f) {
+        left_motor_pid.output = 0.75f;
+    }
     if(left_motor_pid.output < 0.0f) {
        left_motor_pid.output = 0.0f; 
     }
@@ -445,6 +448,10 @@
     if(right_motor_pid.output > 1.0f) {
         right_motor_pid.output = 1.0f;
     }
+    
+     if(right_motor_pid.output > 0.75f) {
+        right_motor_pid.output = 0.75f;
+    }
     if(right_motor_pid.output < 0.0f) {
         right_motor_pid.output = 0.0f;
     }