#contents

*課題について [#k66c90e8]
**課題の内容 [#n7252d32]
 今回の課題は,決められたコースを進み,交差点を越え,ボールを回収し,最終的にボールをゴールにシュートし本体もゴールするといったものである.

#ref(2019a/Member/kimu/Mission2/2019a-mission2.png,50%,コース)

(以下のリンクを参照)

 [[2019a/Mission2:http://yakushi.shinshu-u.ac.jp/robotics/?2019a%2FMission2]]
**コースの内容 [#hfc7e975]
 今回の課題では,私たちの班は「A地点から出発 → B → C(直進) → D(一時停止の後、直進) → E → F → G(一時停止の後、右折) → H → I → J(右折) → K(左折) → L(ピンポン玉をつかむ) → K(直進) → M(一時停止) → シュート→ A地点に入る(ゴール)」というコースを選んだ.
 
*ロボットの構造について [#r5345b48]
**全体の構造 [#gf81e03c]
#ref(2019a/Member/kimu/Mission2/zentaizu_1,50%,全体図)

**アームの構造 [#t15836a4]
#ref(2019a/Member/kimu/Mission2/arm_2.png,50%,アーム1)

*プログラムについて [#zf14414b]
 #define MOVE_TIME 250
 #define SPEED_H 35
 #define SPEED_L 20
 #define OnRL(speedR,speedL) OnFwd(OUT_B,speedR);OnFwd(OUT_C,speedL);
 #define go_straight OnRL(SPEED_H,SPEED_H);
 #define rot_r OnRL(-SPEED_L,SPEED_L);
 #define turn_r OnRL(0,SPEED_L);
 #define rot_l OnRL(SPEED_L,-SPEED_L);
 #define turn_l OnRL(SPEED_L,0);
 #define B1 43
 #define G 53
 #define W1 59
 #define W2 61
 #define arm_open OnRev(OUT_A,20);Wait(1000);Off(OUT_A);
 #define arm_close OnFwd(OUT_A,30);Wait(600);Off(OUT_A);

**黒い線の右側をトレースする [#ke279ead]
 sub follow_line_r()
 {
     SetSensorLight(S1);
     long t0=CurrentTick();
     while(CurrentTick()-t0<MOVE_TIME){
         if(SENSOR_1>W1){
             rot_l;t0=CurrentTick();
         }
         else if(SENSOR_1>W2){
             turn_l;t0=CurrentTick();
         }
         else if(SENSOR_1>G){
             go_straight;t0=CurrentTick();
         }
         else if(SENSOR_1>B1){
             turn_r;t0=CurrentTick();
         }
         else{
             rot_r;
         }
     }
 }

**黒い線の左側をトレースする [#ba86b0af]
 sub follow_line_l()
 {
     SetSensorLight(S1);
     long t0=CurrentTick();
     while(CurrentTick()-t0<MOVE_TIME){
         if(SENSOR_1>W1){
             rot_r;t0=CurrentTick();
         }
         else if(SENSOR_1>W2){
             turn_r;t0=CurrentTick();
         }
         else if(SENSOR_1>G){
             go_straight;t0=CurrentTick();
         }
         else if(SENSOR_1>B1){
             turn_l;t0=CurrentTick();
         }
         else{
             rot_l;
         }
     }
 }

**交差点を越える [#f3d9fa96]
 sub cross_line_1()
 {
     while(SENSOR_1<W1){
         go_straight;
     }
     while(SENSOR_1>G){
         turn_l;
     }
     Off(OUT_BC);
 }

**ボールをつかむ [#mde78bd9]
 sub ball_catch()
 {
     rot_l;
     Wait(350);
     Off(OUT_BC);
     go_straight;
     Wait(2000);
     Off(OUT_BC);
     OnRL(-SPEED_L,0);
     Wait(1000);
     Off(OUT_B);
     OnRL(-SPEED_L,-SPEED_L);
     Wait(1500);
     Off(OUT_BC);
     arm_close;
     rot_r;
     Wait(1300);
     go_straight;
     Wait(800);
     Off(OUT_BC);
 }

**ボールをゴールにシュートする [#d57f1319]
 sub shoot_goal()
 {
     rot_l;
     Wait(300);
     Off(OUT_BC);
     go_straight;
     Wait(1300);
     arm_open;
     rot_l;
     Wait(500);
     Off(OUT_BC);
     go_straight;
     Wait(500);
     Off(OUT_BC);
 }

**交差点を認識し,一時停止する [#a1fd9fc0]
 sub short_break()
 {
     Off(OUT_BC);
     Wait(1000);
 }

 task main()
 {
     go_straight;
     Wait(1000);
     Off(OUT_BC);
     follow_line_r();
     cross_line_1();
     follow_line_r();
     short_break();
     cross_line_1();
     follow_line_r();
     follow_line_r();
     follow_line_r();
     follow_line_r();
     follow_line_r();
     cross_line_2();
     follow_line_r();
     cross_line_2();
     follow_line_r();
     follow_line_r();
     ball_catch();
     follow_line_l();
     shoot_goal();
 }

*考察 [#g4a3fd65]

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