2018a/Member 目次

課題

http://yakushi.shinshu-u.ac.jp/robotics/?plugin=attach&refer=2018a%2FMission2&openfile=2018a-mission2.png

第1コース

  1. Aをスタート
  2. Bを直進
  3. Cで一時停止の後、直進
  4. Dで一時停止の後、Xの空き缶をキャッチしてD地点に戻る
  5. DからEに向かい、Eを直進
  6. Fを左折
  7. Gで一時停止の後、左折
  8. Hで一時停止の後、右折
  9. Iで一時停止の後、右折
  10. Lを直進
  11. Kを直進
  12. Jで一時停止の後、空き缶をYに置きてJに戻りBに向かう
  13. Bで一時停止の後、左折
  14. Aで停止

ロボット

全体

ロボティクス3.jpg

アーム(?)の構造

ロボティクス1.jpg

プログラム

交差点判断

定義

#define go OnFwd(OUT_AC);Off(OUT_AC);     
#define turn_right OnFwd(OUT_A);Off(OUT_C);   
#define turn_left OnFwd(OUT_C);Off(OUT_A);     
#define turn_r OnFwd(OUT_A);OnRev(OUT_C);      
#define turn_l OnFwd(OUT_C);OnRev(OUT_A);      
#define black 30                               
#define white 50
#define bw 35
#define wb 47
#define grey 43
#define set_power_A SetPower(OUT_B,3);
#define wait Wait(100);

サブルーチン

sub trace_1()     //左トレース
{   
    int n=0;
    while(n<=3) {
     if(SENSOR_2>=white){
       turn_r;
       n=0;
     }else if(SENSOR_2>=wb){
       turn_right;
       n=0;
     }else if(SENSOR_2>=grey){
       go;
       n=0;
     }else if(SENSOR_2>=bw){
       turn_left;
       n=0;
     }else{
       turn_l;
       n++;
      }
                    }
}
sub trace_2()    // 左トレース(内側急カーブ)
{   
    int x=0;
    while(x<=20) {
     if(SENSOR_2>=white){
       turn_r;
       x=0;
     }else if(SENSOR_2>=wb){
       turn_right;
       x=0;
     }else if(SENSOR_2>=grey){
       go;
       x=0;
     }else if(SENSOR_2>=bw){
       turn_left;
       x=0;
     }else{
       turn_l;
       x++;
      }
                 }
}
sub trace_3()     //右トレース1
{   
    int y=0;
    while(y<=1) {
     if(SENSOR_2>=white){
       turn_l;
       y=0;
     }else if(SENSOR_2>=wb){
       turn_left;
       y=0;
     }else if(SENSOR_2>=grey){
       go;
       y=0;
     }else if(SENSOR_2>=bw){
       turn_right;
       y=0;
     }else{
       turn_r;
       y++;
      }
                 }
}
sub trace_4()     //右トレース2
{   
    int z=0;
    while(z<=2) {
     if(SENSOR_2>=white){
       turn_l;
       z=0;
     }else if(SENSOR_2>=wb){
       turn_left;
       z=0;
     }else if(SENSOR_2>=grey){
       go;
       z=0;
     }else if(SENSOR_2>=bw){
       turn_right;
       z=0;
     }else{
       turn_r;
       z++;
      }
                 }
}

メイン

task main ()
{
   SetSensor(SENSOR_2,SENSOR_LIGHT);
   trace_1();
   Off(OUT_AC);
   wait;        //C
   turn_r;
   Wait(10);
   OnFwd(OUT_AC);
   wait;
   trace_1();
   Off(OUT_AC);     //D
   wait;
   OnFwd(OUT_AC);
   Wait(20);
   Off(OUT_AC);
   wait;
   set_power_A;
   OnRev(OUT_B);     //アームdown
   Wait(30);
   Off(OUT_B);
   OnRev(OUT_AC);
   Wait(20);
   Off(OUT_AC);
   trace_1();
   Off(OUT_AC);      //G
   wait;
   trace_2();
   Off(OUT_AC);
   wait;
   turn_l;
   Wait(10);
   trace_1();
   Off(OUT_AC);      //H
   wait;
   turn_r;
   Wait(95);
   trace_3();
   Off(OUT_AC);      //I
   wait;
   trace_4();
   Off(OUT_AC);
   go;
   Wait(30);
   trace_4();
   Off(OUT_AC);
   go;
   Wait(30);
   trace_4();
   Off(OUT_AC);      //J
   wait;
   turn_l;
   Wait(95);
   set_power_A;
   OnFwd(OUT_B);     //アームup
   Wait(30);
   Off(OUT_B);
   turn_r;
   wait;
   Off(OUT_AC);
   trace_1();
   Off(OUT_AC);      //B
   wait;
   trace_1();
   Off(OUT_AC);  
}

まとめ

結果

反省点

感想


添付ファイル: fileロボティクス3.jpg 95件 [詳細] fileロボティクス2.jpg 105件 [詳細] fileロボティクス1.jpg 114件 [詳細] file20180718_194647-800x600.jpg 63件 [詳細] file20180718_194632-800x600.jpg 64件 [詳細]

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2018-08-19 (日) 05:26:22