
Wi-Fi追加
Dependencies: RemoteIR TextLCD
Revision 20:02bb875a9b13, committed 2020-08-05
- Comitter:
- tomotsugu
- Date:
- Wed Aug 05 02:31:16 2020 +0000
- Parent:
- 19:c6f9f010bd9e
- Child:
- 21:68d38e8f64b5
- Commit message:
- nnvbbnb
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Aug 05 02:07:18 2020 +0000 +++ b/main.cpp Wed Aug 05 02:31:16 2020 +0000 @@ -257,7 +257,6 @@ if(flag_sp > VERYFAST){ // スピード変更フラグが2より大きいなら flag_sp -= 3 * (flag_sp / 3); // スピード変更フラグ調整 } - //pc.printf(" motor\r\n"); ThisThread::sleep_for(30); // 30ms待つ } } @@ -273,11 +272,8 @@ } /* ライントレーススレッド */ -void trace(/*void const *argument*/){ +void trace(){ while(1){ - //if(mode==LINE_TRACE){ // 現在ライントレースモードなら - //pc.printf("line trace\r\n"); - /* 各センサー値読み取り */ int sensor1 = ss1; int sensor2 = ss2; @@ -330,7 +326,7 @@ } /* 障害物回避走行スレッド */ -void avoidance(/*void const *argument*/){ +void avoidance(){ while(1){ watchsurrounding(); pc.printf("%d %d %d %d %d \r\n",SL,SLD,SC,SRD,SR); @@ -425,12 +421,8 @@ t1=timer.read_ms(); t2=timer.read_ms(); while(echo.read() == 0&&(t1-t2)<10){ - t1=timer.read_ms(); led1 = 1; - if(mode!=AVOIDANCE){ // 現在障害物回避モードでないなら - break; - } } timer.stop(); timer.reset(); @@ -447,16 +439,14 @@ } if((t1-t2)>=10){ - DT=100; + run = STOP; } - //pc.printf("私はDTである。%d\r\n",DT); led1 = 0; return DT; } /* 障害物検知関数 */ void watchsurrounding(){ - //pc.printf("watchsurrounding\r\n"); SC = watch(); if(SC < limit){ // 正面20cm以内に障害物がある場合 run = STOP; // 停止 @@ -465,19 +455,13 @@ ThisThread::sleep_for(180); // 250ms待つ SLD = watch(); if(SLD < limit){ // 左前20cm以内に障害物がある場合 - //if(mode == AVOIDANCE) // 現在障害物回避モードなら - run = STOP; // 停止 - //else - //return; + run = STOP; // 停止 } servo.pulsewidth_us(2400); // サーボを左に90度回転 ThisThread::sleep_for(120); // 250ms待つ SL = watch(); if(SL < limit){ // 左20cm以内に障害物がある場合 - //if(mode == AVOIDANCE) // 現在障害物回避モードなら - run = STOP; // 停止 - //else - //return; + run = STOP; // 停止 } servo.pulsewidth_us(1450); ThisThread::sleep_for(120); @@ -486,29 +470,22 @@ run = STOP; } servo.pulsewidth_us(925); // サーボを右に40度回転 - ThisThread::sleep_for(180); // 250ms待つ + ThisThread::sleep_for(190); // 250ms待つ SRD = watch(); if(SRD < limit){ // 右前20cm以内に障害物がある場合 - //if(mode == AVOIDANCE) // 現在障害物回避モードなら - run = STOP; // 停止 - //else - //return; + run = STOP; // 停止 } servo.pulsewidth_us(500); // サーボを右に90度回転 ThisThread::sleep_for(120); // 250ms待つ SR = watch(); if(SR < limit){ // 右20cm以内に障害物がある場合 - //if(mode == AVOIDANCE) // 現在障害物回避モードなら - run = STOP; // 停止 - //else - //return; + run = STOP; // 停止 } servo.pulsewidth_us(1450); // サーボを中央位置に戻す ThisThread::sleep_for(120); // 100ms待つ if(SC < limit || SLD < limit || SL < limit || SRD < limit || SR < limit){ // 20cm以内に障害物を検知した場合 flag_a = 1; // 障害物有無フラグに1をセット } - //pc.printf(" watchsurrounding\r\n"); } /* ディスプレイ表示関数 */