Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of 7_7Boboobooo by
Revision 15:7f21c08be164, committed 2014-07-10
- Comitter:
- physicsgood
- Date:
- Thu Jul 10 16:38:27 2014 +0000
- Parent:
- 14:8b17b298b4dd
- Commit message:
- QQQQQQQQ
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 Thu Jul 10 14:52:32 2014 +0000 +++ b/camera_api.cpp Thu Jul 10 16:38:27 2014 +0000 @@ -46,8 +46,135 @@ } +void BX_camera::read(void) +{ - void BX_camera::read(void){ + w_f_vL=0x0000; + b_f_vL=0xffff; + + w_f_vR=0x0000; + b_f_vR=0xffff; + + + line_CamR->enable(); + + *si=1; + *cam_clk=1; + + wait_us(30); // tune here + *si=0; + *cam_clk=0; + + + + + + + //input 128 //both + + for(int i=127; i>=0; i--) { + *cam_clk=1; + wait_us(5); + + + line_imageR[i]=line_CamR->read_u16(); + + + + + + // big small + if(line_imageR[i] > w_f_vR) + w_f_vR=line_imageR[i]; + else if(line_imageR[i] < b_f_vR ) + b_f_vR = line_imageR[i]; + + + + + + *cam_clk=0; + wait_us(5); + + + } + line_CamR->disable(); + + *si=1; + *cam_clk=1; + + wait_us(30); // tune here + *si=0; + *cam_clk=0; + + + + line_CamL->enable(); + for(int i=127; i>=0; i--) { + *cam_clk=1; + wait_us(5); + + + + + + + line_imageL[i]=line_CamL->read_u16(); + + // big small + + + if(line_imageL[i] > w_f_vL) + w_f_vL=line_imageL[i]; + else if(line_imageL[i] < b_f_vL ) + b_f_vL = line_imageL[i]; + + + + + *cam_clk=0; + wait_us(5); + + + } + + + + + line_CamL->disable(); + + //filter L R //may change + + for(int i=0; i<128; i++) { + + + if( (line_imageR[i]-b_f_vR) < (w_f_vR - line_imageR[i] ) ) + sign_line_imageR[i]=' '; + else + sign_line_imageR[i]='O'; + + + if( (line_imageL[i]-b_f_vL) < (w_f_vL - line_imageL[i] ) ) + sign_line_imageL[i]=' '; + else + sign_line_imageL[i]='O'; + + + + + + if(i==0) { + sign_line_imageR[i]='X'; + sign_line_imageL[i]='X'; + } + + + } + + + +} +/* void BX_camera::read(void){ w_f_vL=0x0000; b_f_vL=0xffff; @@ -137,4 +264,4 @@ - } \ No newline at end of file + }*/ \ No newline at end of file
--- a/main.cpp Thu Jul 10 14:52:32 2014 +0000 +++ b/main.cpp Thu Jul 10 16:38:27 2014 +0000 @@ -27,7 +27,7 @@ int t = 0; double last = 0.0; double avgg = middle,last_avgg = middle, next_avgg = middle; - double v = 0.4; + double v = 0.5; //char psudo_line[128]; @@ -90,8 +90,8 @@ turn = 0.026; else turn = 0.054; - /*else - turn = middle;*/ + //else + // turn = middle; flag = 0; } else if (black_centerL == 118 && black_centerR != 10){//no left line turn right flag = 1 @@ -158,23 +158,23 @@ times++; t++; - if(times == 2){ + if(times == 5){ avg = last_turn / times; if(avg < 0.042 && avg > 0.034){ - v = 0.4; + v = 0.5; } else{ v = 0.18; } MotorA.rotate(v); MotorB.rotate(v); - servo.set_angle((avg*7 + next_avgg)/8); + servo.set_angle((avg*6 + next_avgg)/7); //servo.set_angle(avg); times = last_turn = 0; } - if(t == 500){ + if(t == 1000){ last_avgg = avgg; avgg = last / t; next_avgg = 2*avgg -last_avgg;