中央線です。松本駅から名古屋まで直通っす。

**ロボコン [#ead41f2e]

 #define blackline 40
 #define blackline 30
 int frag;
 sub linetrace ()
 {
  if ((SENSOR_1<=blackline)&&(SENSOR_3>=blackline)){
       OnFwd (OUT_C);OnRev (OUT_A);
 int stage;
 int timer;
 sub linetrace (){
  if ((SENSOR_1 <= blackline) && (SENSOR_3 <= blackline)){
    OnRev(OUT_A + OUT_C);
    Wait(030);
    frag++;
  }
  if ((SENSOR_1>=blackline)&&(SENSOR_3<=blackline)){
       OnFwd (OUT_A);OnRev (OUT_C);
  else{
    if ((SENSOR_1 <= blackline) && (SENSOR_3 >= blackline)){
      OnFwd (OUT_A);OnRev (OUT_C);
    }
    if ((SENSOR_1 >= blackline) && (SENSOR_3 <= blackline)){
      OnFwd (OUT_C);OnRev (OUT_A);
    }
    if ((SENSOR_1 >= blackline) && (SENSOR_3 >= blackline)){
      OnRev (OUT_A + OUT_C);
    }
  }
  if ((SENSOR_1<=blackline)&&(SENSOR_3<=blackline))
  {
  frag++;
  OnFwd (OUT_A+OUT_C); Wait(020);
  }
  if ((SENSOR_1>=blackline)&&(SENSOR_3>=blackline))
  {
 }
 sub hold_can (){
  OnFwd (OUT_A+OUT_C);
  }

  Wait (timer);
  Off (OUT_A+OUT_C);
  Wait (020);
  OnRev (OUT_B);
  Wait (150);
 }
 sub turn_c90 (){
  OnFwd (OUT_A+OUT_C);Wait(050);
  OnRev (OUT_C);Wait(150);Off(OUT_A+OUT_C);
 }

 task main()
 {
  SetSensor (SENSOR_1, SENSOR_LIGHT);
  SetSensor (SENSOR_3, SENSOR_LIGHT);
  frag=0;
  while (true){
  linetrace ();
  if (frag==3)
  {
   frag=4;
   turn_c90 ();
 sub port_can (){
  OnFwd (OUT_A+OUT_C);
  Wait (timer);
  Off (OUT_A+OUT_C);
  OnFwd (OUT_B);
  Wait (250);
  Off (OUT_B);
  ClearTimer (1);
  while (FastTimer (1) <= 300){
    SendMessage (1);
  }
  }
  
 }



#define blackline 40
int frag;
int stage;
int t;
int step;
int s;
int timer;
sub linetrace (){
  if ((SENSOR_1<=blackline)&&(SENSOR_3>=blackline)){
    OnFwd (OUT_C);OnRev (OUT_A);
  }
  if ((SENSOR_1>=blackline)&&(SENSOR_3<=blackline)){
    OnFwd (OUT_A);OnRev (OUT_C);
  }
  if ((SENSOR_1<=blackline)&&(SENSOR_3<=blackline)){
    frag++;
    OnFwd (OUT_A+OUT_C); Wait(010);
  }
  if ((SENSOR_1>=blackline)&&(SENSOR_3>=blackline)){
    OnFwd (OUT_A+OUT_C);
  }
}
sub go_straight (){
  OnFwd (OUT_A+OUT_C);
  Wait (440);
  Wait (040);
  Off (OUT_A+OUT_C);
}
sub go_down (){
 }
 sub go_straight (){
  OnFwd (OUT_A+OUT_C);
 }
 sub go_down (){
  OnRev (OUT_A+OUT_C);
  Wait (440);
  Off (OUT_A+OUT_C);
 }
 sub turn_R (){
  Off (OUT_A + OUT_C);OnRev (OUT_A+OUT_C);Wait (007);OnFwd (OUT_A);Wait (080);Off (OUT_A+OUT_C);
}
sub turn_R (){
  OnFwd (OUT_A+OUT_C);Wait(025);
  OnRev (OUT_C);Wait(060);Off(OUT_A+OUT_C);
}
sub turn_L (){
  OnFwd (OUT_C+OUT_A);Wait(025);
  OnRev (OUT_A);Wait(060);Off(OUT_A+OUT_C);
}
task main(){
  Off (OUT_A + OUT_C);OnRev (OUT_C+OUT_A);Wait (007);OnFwd (OUT_C);Wait (080);Off (OUT_A+OUT_C);
 }
 task main(){
  SetSensor (SENSOR_1, SENSOR_LIGHT);
  SetSensor (SENSOR_3, SENSOR_LIGHT);
  frag=0;
  stage=1;
  t=0;
  s=0;
  step=1;
  timer=0;
  while (true){
    if (stage <= 2){
      if (step==1){
        Wait(050);
        go_down ();
        turn_L ();
        step=2;
    if (stage == 1){
      if (frag == 0 || 3 || 4 || 7){
        linetrace ();
      }
      if (step==2){
      if (frag == 1){
        linetrace ();
        if (frag==3){
          OnFwd (OUT_A+OUT_C);
          Wait (t);
          Off (OUT_A+OUT_C);
          frag=4;
        ClearTimer (0);
      }
      if (frag == 2){
        timer = FastTimer (0);
        turn_R ();
        frag = 3;
      }
      if (frag == 5){
        turn_L ();
        hold_can ();
        linetrace ();
      }
      if (frag == 6){
        turn_L ();
        frag = 7;
      }
      if (frag == 8){
          turn_R ();
          step=3;
        }
          port_can ();
          stage++;
          frag = 0;
      }
      if (step==3){
    }
    if (stage == 2){
      if (frag == 0 || 3 || 7){
        linetrace ();
      }
        if (frag==5){
          Wait(020);
          OnFwd (OUT_A+OUT_C);
          Wait (050);
          Off (OUT_A+OUT_C);
          OnFwd (OUT_B);
          Wait (050);
          OnFwd (OUT_A+OUT_C);
          Wait (010);
          OnRev (OUT_A+OUT_C);
          Wait (050);
          Off (OUT_A+OUT_C);
          OnFwd (OUT_A);
          OnRev (OUT_C);
          Wait(110);
          linetrace ();
        }
        if (frag==6){
          turn_L ();
          linetrace ();
        }
        if (frag==8){
          turn_L ();
        }
      if (frag == 1){
        linetrace ();
        ClearTimer (0);
      }
      if (frag == 2){
        timer = FastTimer (0);
        turn_R ();
        frag = 3;
      }
      if (frag == 4){
        OnFwd (OUT_A+OUT_C);
        Wait (timer/2);
        Off (OUT_A+OUT_C);
        turn_L ();
        hold_can ();
        linetrace ();
      }
      if (frag == 5){
        turn_L ();
        frag = 7;
      }
      if (frag == 8){
          turn_R ();
          port_can ();
          stage++;
          frag = 0;
      }
    }

  }
}


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