chia-hsun wu / Mbed 2 deprecated Boboobooov10

Dependencies:   mbed-rtos mbed

Fork of Boboobooov4 by kao yi

Files at this revision

API Documentation at this revision

Comitter:
backman
Date:
Sun Jun 29 14:32:30 2014 +0000
Parent:
15:585df3979be8
Child:
17:3dac99cf2b89
Commit message:
two cam;

Changed in this revision

camera_api.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/camera_api.cpp	Sun Jun 29 14:02:25 2014 +0000
+++ b/camera_api.cpp	Sun Jun 29 14:32:30 2014 +0000
@@ -70,6 +70,61 @@
 }   
 
 
+int BX_camera::black_centerL(void)
+{
+
+    int l_care=10;
+    int r_care=118;
+    int b_start=0;
+    int b_end=0;
+    bool l_f1=false;
+    bool l_f2=false;
+    bool find=false;
+    int b_thr_up=32;
+    int b_thr_dn=5;
+    int b_w=0;
+    
+     for(int i=r_care;i>l_care;i--){
+         
+         
+          if(l_f1==false&&sign_line_imageL[i]==' '){
+               
+              b_start=i;
+              l_f1=true;
+          }
+          if(l_f1==true && sign_line_imageL[i]=='O'){
+              b_end=i-1;
+              l_f2=true;   
+           }
+         
+           if(l_f1==true && l_f2== true){
+               b_w=b_start-b_end;
+               if( b_thr_up>b_w&&b_w> b_thr_dn){
+                   
+                   find=true;     
+                   break;
+                }
+                else{
+                   l_f1=false;
+                   l_f2=false;
+                   
+                } 
+                
+                   
+            }
+               
+               
+    }
+         
+         
+         
+     
+
+  if(find)
+     return (b_start+b_end)/2;
+  else
+     return -1;  
+}   
 
 
 
--- a/main.cpp	Sun Jun 29 14:02:25 2014 +0000
+++ b/main.cpp	Sun Jun 29 14:32:30 2014 +0000
@@ -15,8 +15,8 @@
 #define task_ma_time
 
 
-#define car_center 64
-
+#define R_target 20
+#define L_target 108
 
 
 
@@ -54,6 +54,7 @@
 
 
 static int b_r_c=64;
+static int b_l_c=64;
 static int pre_b_r_c;
 
 static double v_motor;
@@ -71,11 +72,11 @@
         
      
             b_r_c=cam.black_centerR();
+            b_l_c=cam.black_centerL();
+            //if(b_r_c==-1)
+             //  b_r_c=pre_b_r_c;
             
-            if(b_r_c==-1)
-               b_r_c=pre_b_r_c;
-            
-            pre_b_r_c=b_r_c;
+            //pre_b_r_c=b_r_c;
             Thread::wait(t_cam);
         
         }
@@ -144,8 +145,11 @@
 
         while(1){
         
-      
-         v_servo=cam_to_M_ctrlr.compute(b_r_c,car_center);        
+        if(b_r_c!=-1)
+         v_servo=cam_to_M_ctrlr.compute(b_r_c,R_target);     
+        if(b_l_c!=-1)
+         v_servo=cam_to_M_ctrlr.compute(b_l_c,L_target);     
+            
          
          
             
@@ -211,7 +215,7 @@
    //   Thread thread(ctrl_thread);  
       Thread th_s(servo_thread);  
       Thread th_m(motor_thread);     
-     Thread th_de(de_thread);  
+   //  Thread th_de(de_thread);  
      while(1){