2006a/C3/ロボコン

#define blackline 40
int frag;
int step;
task linetrace (){
 if ((SENSOR_1<=blackline)&&(SENSOR_3>=blackline)){
   OnFwd (OUT_C);OnRev (OUT_A);
 }
 if ((SENSOR_1>=blackline)&&(SENSOR_3<=blackline)){
   OnFwd (OUT_A);OnRev (OUT_C);
 }
 if ((SENSOR_1<=blackline)&&(SENSOR_3<=blackline)){
   frag++;
   OnFwd (OUT_A+OUT_C); Wait(010);
 }
 if ((SENSOR_1>=blackline)&&(SENSOR_3>=blackline)){
   OnFwd (OUT_A+OUT_C);
 }
}
sub go_straight (){
 OnFwd (OUT_A+OUT_C);
}
sub go_back (){
 OnRev (OUT_A+OUT_C);
}
sub turn_R (){
 OnFwd (OUT_A+OUT_C);Wait(025);
 OnRev (OUT_C);Wait(200);Off(OUT_A+OUT_C);
}
sub turn_L (){
 OnFwd (OUT_C+OUT_A);Wait(025);
 OnRev (OUT_A);Wait(200);Off(OUT_A+OUT_C);
}
sub hold_can()
{
OnFwd(OUT_B);Wait(200);Off(OUT_B);
}  
sub part_can()
{
OnRev(OUT_B);Wait(300);Off(OUT_B);
}
task main(){
 SetSensor (SENSOR_1, SENSOR_LIGHT);
 SetSensor (SENSOR_3, SENSOR_LIGHT);
 frag=0;
 step=1;
 while (true){
 
    Wait(500);
    hold_can();
    while (step==1){
       Wait(050);
       go_back ();Wait(400);
       turn_R ();Wait(200);
       step=step+1;
     }
     while (step==2){
       start linetrace;
       if (frag==2){
         frag=3;
         turn_L ();
         step=step++;
       }
     }
     while (step==3){
         OnFwd(OUT_A+OUT_C);Wait(100);
         part_can();
         OnFwd(OUT_A+OUT_C);Wait(50);
         step=step++;
        }
        
       while(step==4){
         OnRev(OUT_A+OUT_C);Wait(150);
           turn_L ();
           step=step++; 
       
       }
       while(step==5){
           start linetrace;
           if(frag==5){
           turn_R();
           frag=6;
           step=step++;
           }
           }
      while(step==6){
           start linetrace;
           if(frag==7){
           go_straight();Wait(50);
           frag=8;
           step=step++;
          }
          }
        while(step==7){
           step=1;
           frag=0;
        }  
          
         
   }
 }

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2006-08-12 (土) 03:24:28