[[2015b/MemberOnly]]
*ボール打ち出しロボット [#ucbc2881]
**目的 [#gb654b97]
今回は2つのロボットを用いて一つがボールをつかみ缶にあてる。もう一つがそのボールを回収する。という課題だった。
そのためにロボットにボールを固定して投げるためアームを取り付けた。
**ロボット本体 [#ib05a45e]
ロボット本体はライントレースができるようにドライブベースを使った。そして
**プログラム [#ye1e08ae]

int light_max = 0;
int turn_time = 500;
int time_max = 0;
int t = 0;
int s = 0;
   
sub light(){
         SetSensor(SENSOR_1, SENSOR_LIGHT);
         SetSensor(SENSOR_2, SENSOR_LIGHT);
   
   
         ClearTimer(0);
         OnFwd(OUT_A);OnRev(OUT_C);
   
         while(FastTimer(0) < turn_time){
             if(SENSOR_2 > light_max){
                 light_max = SENSOR_2;
                 time_max = FastTimer(0);
               }
          }
   
          Off(OUT_AC);Wait(100);
          OnFwd(OUT_C);OnRev(OUT_A);Wait(turn_time - time_max);
          Off(OUT_AC);Wait(100);
}
   
task main(){
          SetSensor(SENSOR_2,SENSOR_LIGHT);
          SetSensor(SENSOR_1,SENSOR_LIGHT);
   

          SetPower(OUT_B,5);OnFwd(OUT_B);Wait(50);

                OnRev(OUT_AC);Wait(200);
               OnRev(OUT_A);OnFwd(OUT_C);Wait(100);
              OnRev(OUT_AC);Wait(200);
   
          Off(OUT_AC);Wait(100);
   
          SetPower(OUT_B, 1);OnRev(OUT_B);Wait(100); 
   
          OnRev(OUT_C);OnFwd(OUT_A);Wait(150);
          OnRev(OUT_AC);Wait(300);

            while(light_max < 65){
               
                     OnRev(OUT_AC);Wait(50);Off(OUT_AC);
                      light();
              }

            PlaySound(SOUND_CLICK);
            light();
   
          SetPower(OUT_B,5);OnFwd(OUT_B);Wait(50);
   
          OnFwd(OUT_C);OnRev(OUT_A);Wait(150);
          Off(OUT_AC);Wait(100);
   
          OnRev(OUT_AC);Wait(200);
          OnRev(OUT_AC);until(SENSOR_1 < 41); Off(OUT_AC);
          PlaySound(SOUND_CLICK);Wait(100);
   
          ClearTimer(1);
   
          while(FastTimer(1) < 50){
             if(SENSOR_1 > 49){
                 OnRev(OUT_A);OnFwd(OUT_C);
   
             } else if(SENSOR_1 > 46){
                 OnRev(OUT_A);Off(OUT_C);
   
             } else if(SENSOR_1 > 40){
                 OnRev(OUT_AC);ClearTimer(1);
   
             } else if(SENSOR_1 > 37){
                 OnRev(OUT_C);Off(OUT_A);ClearTimer(1);
   
             } else{
                 OnRev(OUT_C);OnFwd(OUT_A);ClearTimer(1);
   
               }

           }
          OnRev(OUT_A);OnFwd(OUT_C);Wait(80);
          OnRev(OUT_AC);Wait(150);Off(OUT_AC);Wait(100);
  
 
          SetPower(OUT_B,5);OnFwd(OUT_B);Wait(50);
          SetPower(OUT_B,1);OnRev(OUT_B);Wait(100);Off(OUT_B);

          OnFwd(OUT_A);OnRev(OUT_C);Wait(350);
          OnRev(OUT_AC);Wait(200);
   
          while(SENSOR_2 < 50){
               OnRev(OUT_AC);Wait(50);Off(OUT_AC);
               light();
            }
          PlaySound(SOUND_CLICK);
          light();OnRev(OUT_A);OnFwd(OUT_C);Wait(35);
          Off(OUT_AC);Wait(100);
   
          SetPower(OUT_B,5);OnFwd(OUT_B);Wait(50);
   
          OnFwd(OUT_AC);Wait(100);
          Off(OUT_AC);
}


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS