[[2019a/Member]]
目次
#contents



*課題について [#n09c5be2]
次のようなコースを作ります。

そして、4つのボールを空の弁当箱に集めます。
#ref(2019a-mission3.png)

詳しくは[[2019a/Mission3]]を参照してください。

*基本的な作戦 [#jf8b7958]











1つのつかむ機構では、床のボールと弁当箱に入っているボールの両方を回収することはできない。

もともとは、1つのアームに2のつかむ機構を搭載し、ボールを4つ回収できるようなロボットを作成した。

しかし、アームが重すぎて上がらなくなってしまったことで、アームを作り直す必要が出てきてしまい、プログラムにかけられる時間が少なくなってきてしまったことから、床に置いてあるボールを諦め、点数の高い弁当箱に入っている2つのボールを確実に回収できるようなロボットを目指した。







*ロボットの本体の説明 [#y99352ff]

#ref(IMG_4905.jpg)






#ref(IMG_4932.jpg)

















*プログラムの説明 [#l0b5f21e]


マスター側
 #define CONN 1
 #define on1 1
 #define on2 2
 #define on3 3
 #define zenshin OnFwd(OUT_BC,60); //前進
 #define koushin OnFwd(OUT_BC,-60); //後進
 #define migikaiten OnFwd(OUT_B,-70);OnFwd(OUT_C,40); //右回転 
 #define hidarikaiten OnFwd(OUT_B,40);OnFwd(OUT_C,-70); //左回転
 #define migi OnFwd(OUT_C,40);Off(OUT_B);//右に進む
 #define hidari OnFwd(OUT_B,40);Off(OUT_C); //左に進む
 #define tomaru Off(OUT_BC); //ストップ
 long A=0;//コーナーで止まる時間を計測する変数
 long B=0;//ライントレースしている時間を計測する変数
 
 void re_stop_corner(){
     SetSensorLight(S1);
     while(A<400){
         if(SENSOR_1>40){
             hidari;
             A=0;         
             B=B+1;
         }else{
             migi;
             A=A+1;
             B=B+1;
          }
     }
     tomaru;
     Wait(1000);
     B=0;
 }//交差点で止まるライントレース(ラインの右側を進む)
 
 void re_cross_line(){
     SetSensorLight(S1);
         if(SENSOR_1>40){
             hidari;
             B=B+1;
         }else{
             migi;
             B=B+1;
         }
 }//交差点を直進するライントレース(ラインの右側を進む)
 
 task main()
 {
     SetSensorLight(S1);
 
     while(B<8000){
         re_cross_line();//逆側のライントレース
     }
 
     while(B>=8000){
         re_stop_corner();
     }//逆側のライントレース
 
     tomaru;
     Wait(500);
     koushin;
     Wait(1600);
     migi;
     Wait(300);
     zenshin;
     Wait(1300);  
     migikaiten;
     Wait(1300);
     tomaru;
     Wait(100);
     koushin;
     Wait(300);
     tomaru;
     Wait(100);
     zenshin;
     Wait(300);
     tomaru;
     Wait(100);
 
     SendRemoteNumber(CONN,MAILBOX1,on2);
     Wait(18000);
 
     zenshin;
     Wait(300);
     tomaru;
     Wait(100);
  
     SendRemoteNumber(CONN,MAILBOX1,on1); //tukamu
     Wait(30000);
      
     OnFwd(OUT_B,50);OnFwd(OUT_C,-80); 
     Wait(400);
     tomaru;
     Wait(100);
     koushin;
     Wait(1500);
     tomaru;
     Wait(100);
 
     SendRemoteNumber(CONN,MAILBOX1,on3);
     Wait(1000);
 
     tomaru;
     Wait(100);
 }

スレーブ側

 #define on1 1
 #define on2 2
 #define on3 3
 #define tomaru Off(OUT_AB);Wait(100);//ストップ
 
 task main()
 {
     int msg1;
     int msg2;
     while(1){
         ReceiveRemoteNumber(MAILBOX1,true,msg1);
         if(msg1==on1){
             OnFwd(OUT_B,50);
             Wait(1500);
             tomaru;
             OnFwd(OUT_A,-100);
             Wait(20000);   
             OnFwd(OUT_A,100);
             Wait(20000);
             tomaru;
             OnFwd(OUT_B,-50);
             Wait(1500);
             tomaru;
     
              msg1=100;
         }   
 
         if(msg1==on3){
             OnFwd(OUT_C,-30);
             Wait(200);
 
             msg1=100;
         }
 
         if(msg1==on2){
             OnFwd(OUT_A,100);
             Wait(20000);
 
             msg1=1;
         }
     }
 }

*難しかったところ [#q17bbad3]

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