#contents
*課題3 [#wdc46bbe]
ピンポン玉と紙コップをそれぞれ所定の位置に運ぶ。
#ref(2017b-mission3.png)
左上のピンポン玉と中央上の紙コップをねらうことにした。
*ロボット説明 [#dea40a76]
*プログラム [#je5439fe]
**アームを上下させるRIS [#x599a4ba]
 #define up(t) OnRev(OUT_A);Wait(t);Off(OUT_AC);
 #define down(t) OnFwd(OUT_A);Wait(t);Off(OUT_AC);
 #define st(t) Off(OUT_AC);Wait(t);
 task main ()
 {
     Wait(870);
     up(30);
     st(200);
     down(30);
 }

**本体の移動と光センサーと紙コップをつかませるRIS [#v34cc71d]
 #define rightSENKAI OnFwd(OUT_C);OnRev(OUT_A);
 #define rightMAGARU OnFwd(OUT_C);Off(OUT_A);
 #define carb 46
 #define ch OnFwd(OUT_B);Wait(30);Off(OUT_B);
 #define re OnRev(OUT_B);Wait(20);Off(OUT_B);
 #define go(t) OnFwd(OUT_AC);Wait(t);Off(OUT_AC);
 #define back(t) OnRev(OUT_AC);Wait(t);Off(OUT_AC);
 #define cross_stop Off(OUT_AC);Wait(100);
 sub r()
 {
  SetSensor(SENSOR_2,SENSOR_LIGHT);
  ClearTimer(0);
  while(FastTimer(0)<=24)
  {
   if(SENSOR_2>carb+5)    
    {
     leftSENKAI
     ClearTimer(0);
    }
   else if(SENSOR_2>carb+3)    
    {
     leftMAGARU
     ClearTimer(0);
    }
   else if(SENSOR_2>carb)   
    {
     OnFwd(OUT_AC);
     ClearTimer(0);
    }
   else if(SENSOR_2>carb-3)    
    {
     rightMAGARU
     ClearTimer(0);
    }
   else    
    {
     rightSENKAI
     }
   }
 Off(OUT_AC);
 } 
 
 task main ()
 {
    go(30);
    r();
    leftSENKAI;
    Wait(5);
    re;
    go(160);
    cross_stop;
    ch;
    rightSENKAI;
    Wait(140);
    cross_stop;
    ch;
    go(90);
    cross_stop;
    re;
    back(100);
    leftSENKAI;
    Wait(30);
    go(200);
    rightSENKAI;
    Wait(40);
    re;
    go(250);
 }
*感想まとめ [#b119d611]

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