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:
39:7b28ee39185d
Parent:
37:3baddde964db
Child:
40:10e8e80af7da
diff -r 72a174cccd43 -r 7b28ee39185d main.cpp
--- a/main.cpp	Fri Jan 13 10:14:40 2017 +0000
+++ b/main.cpp	Fri Jan 13 10:21:07 2017 +0000
@@ -226,7 +226,7 @@
         //dutyCycleCorner(speed, servo_pid.output);
         // This activates the electronic differential so that it runs whilst cornering. 
         // this changes the desired desired speed of each of the wheels according to the angle of the servo.
-        sensorCorner(left_motor_pid.desired_value, right_motor_pid.desired_value , servo_pid.output, speed,1);  
+        sensorCorner(left_motor_pid.desired_value, right_motor_pid.desired_value , servo_pid.output, speed,ed_tune);  
     }
     
     /*
@@ -307,7 +307,7 @@
     t.start();
     handlePID(&servo_pid);
     //enables the ED
-    sensorCorner(left_motor_pid.desired_value,right_motor_pid.desired_value, servo_pid.output,speed,1);
+    sensorCorner(left_motor_pid.desired_value,right_motor_pid.desired_value, servo_pid.output,speed,ed_tune);
     handlePID(&left_motor_pid);
     handlePID(&right_motor_pid);
 
@@ -523,6 +523,17 @@
                         left_motor_pid.desired_value=speed;
                     }
                 break;
+                
+                case 'L':
+                 if(xb.cBuffer->available() >= 4) {
+                        byte_float_union.bytes[0] = xb.cBuffer->read();
+                        byte_float_union.bytes[1] = xb.cBuffer->read();
+                        byte_float_union.bytes[2] = xb.cBuffer->read();
+                        byte_float_union.bytes[3] = xb.cBuffer->read();
+                        ed_tune = byte_float_union._float; 
+                        curr_cmd = 0;
+                    }
+                break;
                   
                 default:
                 // Unrecognised command
@@ -565,6 +576,8 @@
                 curr_cmd = 'F';    
             } else if(cmd == 'K') {
                 sendCam = ~sendCam;    
+            } else if(cmd == 'L') {
+                curr_cmd = 'L'
             }
             
         }