*ロボットの紹介 [#xad7c17c]

-タッチセンサーと缶をつかむハサミの部分をつけたらロボット本体が大きくなり、前が重くなってしまった。

*コース攻略 [#b8c0055d]
-時間を、円の手前(缶をつかむ)、1個目の円、2個目の円、残りとかんを離す作業の4つにわけて攻略しようとしたが、あまり上手くいかなかった。

*プログラムの説明 [#ab8ab5e8]
#define BLACK1 37
#define BLACK2 41
#define WHITE1 44
#define WHITE2 48
#define HIPOWER 6
#define LOWPOWER 1
#define set_power_H SetPower(OUT_AC,HIPOWER);
#define set_power_L SetPower(OUT_AC,LOWPOWER);
#define go_forward set_power_H; OnFwd(OUT_AC);
#define turn_left2 set_power_L;\
  OnFwd(OUT_C); OnRev(OUT_A);
#define turn_left1 set_power_L;\
  OnFwd(OUT_C); Off(OUT_A);
#define turn_right1 set_power_L;\
  OnFwd(OUT_A); Off(OUT_C);
#define turn_right2 set_power_L;\
  OnFwd(OUT_A); OnRev(OUT_C);
#define STEP 1
#define nMAX 300
#define short_break Off(OUT_AC);Wait(100);
#define CROSS_TIME 30

#define cross_line set_power_L;\
        OnFwd (OUT_AC);Wait (CROSS_TIME);short_break;
#define timeA 1600
#define timeB 3400
#define timeC 4600
#define timeD 5400
#define timeE 10000

task main()
{
  SetSensor(SENSOR_1,SENSOR_LIGHT);
  SetSensor(SENSOR_2,SENSOR_TOUCH);
   int nOnline=0;
   ClearTimer(0);
    if (SENSOR_2==0){
     OnRev(OUT_B);
     }

   while (FastTimer(0)<=timeA) {
     if (SENSOR_2==1){
     OnFwd(OUT_B);
      }if (SENSOR_1<BLACK1){
        turn_left2;
      }else if (SENSOR_1 < BLACK2) {
         turn_left1;
       }else if (SENSOR_1 < WHITE1) {
         go_forward;
       }else if (SENSOR_1 < WHITE2) {
           turn_right1;
   }else{
     turn_right2;
 }
  Wait(STEP);
}
while (FastTimer(0) > timeA) {
   while (FastTimer(0) <= timeB) {
      while (nOnline < nMAX){
           if(SENSOR_1 < BLACK1) {
        turn_left2;
        nOnline++;
        } else {
            if (SENSOR_1 < BLACK2) {
            turn_left1;
          } else if (SENSOR_1 < WHITE1) {
            go_forward;
          } else if (SENSOR_1 < WHITE2) {
          turn_right1;
          } else {
             turn_right2;
            }
           nOnline=0;
            }
             Wait(STEP);
             }
            short_break;
              turn_right1;Wait(nMAX*STEP);
                cross_line;
                  nOnline=0;
              }
               }
while (FastTimer(0) > timeB) {
   while (FastTimer(0) <= timeC) {
       while (nOnline < nMAX){
            if (SENSOR_1 < BLACK1) {
                  turn_left2;
          } else if (SENSOR_1 < BLACK2) {
               turn_left1;
            } else if (SENSOR_1 < WHITE1) {
                   go_forward;
             } else if (SENSOR_1 < WHITE2) {
                    turn_right1;
             } else {
                    turn_right2;
                }
              Wait(STEP);
                 }
             while (FastTimer(0) > timeC){
                while (FastTimer(0) <= timeD) {
                      while (nOnline < nMAX) {
                  if (SENSOR_1 < BLACK1){
                  turn_left2;
                      nOnline++;
                  } else {
                       if (SENSOR_1 < BLACK2) {
                          turn_left1;
                       } else if (SENSOR_1 < WHITE1) {
                             go_forward;
                      } else if (SENSOR_1 < WHITE2) {
                             turn_right1;
                            } else {
                             turn_right2;
                               }
  nOnline=0;
  }
   Wait(STEP);
    }
   short_break;
   turn_right1;Wait(nMAX*STEP);
   cross_line;
   nOnline=0;
   }
  }
  while (FastTimer(0) > timeD) {
    while (FastTimer(0) <= timeE) {
      while (nOnline < nMAX){
      if (SENSOR_1 < BLACK1){
          turn_left2;
       } else if (SENSOR_1 < BLACK2) {
           turn_left1;
       } else if (SENSOR_1 < WHITE1) {
           go_forward;
        } else if (SENSOR_1 < WHITE2) {
            turn_right1;
         } else {
              turn_right2;
         }
       Wait(STEP);
        }
       Off(OUT_AC);
        Wait(100);
        OnFwd(OUT_A);
        OnRev(OUT_C);
          Wait(150);
         Off(OUT_AC);
         OnRev(OUT_B);
        OnRev(OUT_AC);
      Wait(150);
       while(true){
        if(SENSOR_1 < BLACK1) {
           turn_left2;
          } else if (SENSOR_1 < BLACK2) {
            turn_left1;
         } else if (SENSOR_1 < WHITE1) {
              go_forward;
       } else if (SENSOR_1 < WHITE2) {
             turn_right1;
        } else {
            turn_right2;
          }
         Wait(STEP);
}
}
}
*まとめ [#rc4a5766]
-成功するときもあったが、失敗のが多いので、次の課題でこの失敗を活かしたい。

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