[[2013b/kk/missoin]]

*ロボコン [#rc648b11]

***今回のロボコンの課題 [#p3d4f813]
~ライン上に設置された缶を集めポイントの枠内にどれだけ積み上げれるかを競います。
&br;私たちのグループの方針としてはロボットを「缶を集める」役と「積み上げる」役に
&br;それぞれロボットを分け2段の缶を複数積みあげて得点を稼ぎます。

*ロボットの説明 [#bc577471]
~缶を集めてくる側のロボットです。基本形はライントレースのときのものを応用しています。 [#b15fe7fb]
&br;大きな特徴としては缶の受け渡しのため、つかんだ缶を押し出しハサミの外に出す仕組みです。
&br;機体の底を最大のタイヤを使用して持ち上げ、缶を押し出すのに使用するモーターを取りつ
けました。この時、重たいモーターを固定するのに苦労しました。L字のブロックと蝶番のブロックを使用して強固にしました。このモーターにはライントレースをする光センサーもついています。
&br;ハサミの先についた光センサーで缶を掴んだことを感知します。センサーの位置は、初め機体の中央:黒い受信ポート下:に位置していましたが蛍光灯や紙からの反射光によって値が30〜40とばらつきが生じてしまったため、より缶に近い歯先に取り付けました。
*プログラム [#be5c1e54]
-定義文
 #define WHITE 46
 #define BLACK 40
 #define CATCH 44
 #define power SetPower(OUT_AC,1);
 #define go_forward power;OnFwd(OUT_AC);
 #define go_back power;OnRev(OUT_AC);
 #define LEFT power;OnRev(OUT_A);OnFwd(OUT_C);
 #define left power;Off(OUT_A);OnFwd(OUT_C);
 #define RIGHT power;OnFwd(OUT_A);OnRev(OUT_C);
 #define right power;OnFwd(OUT_A);Off(OUT_C);
 #define PUSH power;OnRev(OUT_B);Wait(3);Off(OUT_B);Wait(20);OnFwd(OUT_B);Wait(10);Float(OUT_B);

-サブルーチン

 ライントレース(右側)
 sub trace1_R(){
       if (SENSOR_1 < BLACK){
                 RIGHT;
         } else if (SENSOR_1 < BLACK +2){
                 right;
         } else if (SENSOR_1 > WHITE -2){
                 left;
         } else if (SENSOR_1 > WHITE){
                 LEFT;
           }
   }

 ライントレース(左側)
 sub trace1_L(){
       if (SENSOR_1 < BLACK){
                 LEFT;
         } else if (SENSOR_1 < BLACK +2){
                 left;
         } else if (SENSOR_1 > WHITE -2){
                 right;
         } else if (SENSOR_1 > WHITE){
                 RIGHT;
           }
   }

 交差点を判断するライントレース(右側)
 sub trace2_R(){
         while (FastTimer(0) < 25){
    if (SENSOR_1 < BLACK){
       RIGHT;
    }else if (SENSOR_1 < BLACK +2){
       ClearTimer(0);
       right;
    }else if (SENSOR_1 > WHITE -2){
       ClearTimer(0);
       left;
    }else if (SENSOR_1 > WHITE){
       ClearTimer(0);
       LEFT;
    }else{
       ClearTimer(0);
       go_forward;
     }
  }

 if(FastTimer(0) >= 25){
   ClearTimer(0);
   LEFT;
   Wait(40);
   go_forward;
   Wait(20);
   Off(OUT_AC);
   ClearTimer(0);
  }
 }

 交差点を判断するライントレース(左側)
 sub trace2_L(){
         while (FastTimer(0) < 25){
    if (SENSOR_1 < BLACK){
       LEFT;
    }else if (SENSOR_1 < BLACK +2){
       ClearTimer(0);
       left;
    }else if (SENSOR_1 > WHITE -2){
       ClearTimer(0);
       right;
    }else if (SENSOR_1 > WHITE){
       ClearTimer(0);
       RIGHT;
    }else{
       ClearTimer(0);
       go_forward;
     }
  }

 if(FastTimer(0) >= 25){
   ClearTimer(0);
   RIGHT;
   Wait(40);
   go_forward;
   Wait(20);
   Off(OUT_AC);
   ClearTimer(0);
  }
 }

 缶の受け渡し(右側)
 sub trace3_R(){
             while (FastTimer(0) < 25){
    if (SENSOR_1 < BLACK){
       RIGHT;
    }else if (SENSOR_1 < BLACK +2){
       ClearTimer(0);
       right;
    }else if (SENSOR_1 > WHITE -2){
       ClearTimer(0);
       left;
    }else if (SENSOR_1 > WHITE){
       ClearTimer(0);
       LEFT;
    }else{
       ClearTimer(0);
       go_forward;
     }
  }

 if(FastTimer(0) >= 25){
      go_forward;
      Wait(10);
      LEFT;
      Wait(70);
      Off(OUT_AC);
      Wait(100);

      PUSH;
      go_back;
      Wait(100);
      Off(OUT_AC);
      ClearTimer(0);
  }
 }

 缶の受け渡し(左側)
 sub trace3_L(){
             while (FastTimer(0) < 25){
    if (SENSOR_1 < BLACK){
       LEFT;
    }else if (SENSOR_1 < BLACK +2){
       ClearTimer(0);
       left;
    }else if (SENSOR_1 > WHITE -2){
       ClearTimer(0);
       right;
    }else if (SENSOR_1 > WHITE){
       ClearTimer(0);
       RIGHT;
    }else{
       ClearTimer(0);
       go_forward;
     }
  }

 if(FastTimer(0) >= 25){
      RIGHT;
      Wait(70);
      Off(OUT_AC);
      PUSH;
      go_back;
      Wait(50);
      Off(OUT_AC);
     ClearTimer(0);
  }
 }

メインタスク
  task main()
 {
  SetSensor(SENSOR_1, SENSOR_LIGHT);
  SetSensor(SENSOR_3, SENSOR_LIGHT);
  ClearTimer(0);
  int n=0;
 
  while(n==0){
               Wait(100);                   //相手を待つ時間
               until(SENSOR_1 < BLACK){     //黒になるまで直進
                       go_forward;}
               Off(OUT_AC);
               Wait(100);
               go_back;
               Wait(15);
               Off(OUT_AC);
               Wait(30);
           n++;
  }
 
  while(n==1){
            if (SENSOR_3 > CATCH){
                      PlaySound(SOUND_UP);
                      ClearTimer(0);
                      until(FastTimer(0) > 500){
                           trace1_R();}
                      LEFT;
                      Wait(55);
                      go_forward;
                      Wait(20);
                      until(SENSOR_1 < BLACK){
                       go_forward;}
                       ClearTimer(0);
                      until(FastTimer(0) > 500){
                               trace1_R();}
                      ClearTimer(0);
                      trace3_R();
                      n++;
          } else if (SENSOR_1 < BLACK){
                  RIGHT;
          } else if (SENSOR_1 < BLACK +2){
                  right;
          } else if (SENSOR_1 > WHITE -2){
                  left;
          } else if (SENSOR_1 > WHITE){
                  LEFT;
            }
  }
 
  while(n==2){
              RIGHT;
              Wait(40);
              go_forward;
              Wait(150);
              until(SENSOR_1 < BLACK){
                       right;}
             if (SENSOR_3 > CATCH){
                    until(SENSOR_1 < BLACK){
                      LEFT;}
                    ClearTimer(0);
                    trace3_L();
                    n++;
            } else if (SENSOR_1 < BLACK){
                  LEFT;
          } else if (SENSOR_1 < BLACK +2){
                  left;
          } else if (SENSOR_1 > WHITE -2){
                  right;
          } else if (SENSOR_1 > WHITE){
                  RIGHT;
            }
  }
 }
*課題・結果 [#lc992438]
|結果|缶の個数|得点|
|  |    |  |

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