[[2016a/Member]]

float GetAngle(float d) /* d¤Ë¤Ï¿Ê¤ß¤¿¤¤µ÷Î¥¤¬Æþ¤ë */
{
 const float diameter=5.45;  //¥¿¥¤¥ä¤Îľ·Â(­Ñ)
 const float pi=3.1415;      //±ß¼þΨ(¦Ð)
 float ang =d/(diameter*pi)*360.0;  //³ÑÅÙ¤ò·×»»¤¹¤ë
 return ang;                 //³ÑÅÙ¤òÊÖ¤¹¡¡
}

#define Tozire RotateMotor(OUT_A,50,800);
#define Hirake RotateMotor(OUT_A,-25,800);

#define Ninety GetAngle(8.25)
#define Turn_r RotateMotorEx(OUT_BC,35,Ninety,-100,true,false);
#define Turn_l RotateMotorEx(OUT_BC,35,Ninety,100,true,false);

#define Rotary(l) GetAngle(l)
#define Go_F(l) RotateMotorEx(OUT_BC,25,Rotary(l),0,true,true);
#define Go_B(l) RotateMotorEx(OUT_BC,-25,Rotary(l),0,true,true);

sub Papercop()
{
 SetSensorLowspeed(S1);
 int n=0;
 while(n<1){
  if (SensorUS(S1)<=10){
   Go_F(5);
   Tozire;
   Turn_r;
   OnRev(OUT_B,50);
   Wait(100);
   Go_F(10);
   Hirake;
   Go_B(10);
   OnRev(OUT_C,50);
   Wait(200);
   Turn_l;
   OnFwd(OUT_B,50);
   Wait(100);
   Off(OUT_B);
   Go_B(5);
   n++;
   Off(OUT_BC);
  }else{
   OnFwd(OUT_BC,50);  
  }
 }
 n=0;
}

#define CONN 1
#define Boot 11

task main()
{
 Go_F(25);
 Turn_r;
 OnFwd(OUT_C,50);
 Wait(100);
 Off(OUT_C);
 Go_F(15);
 OnRev(OUT_C,50);
 Wait(100);
 Off(OUT_C);
 Turn_l;
 Off(OUT_BC);
 OnFwd(OUT_B,50);
 Wait(100);
 Off(OUT_B);
 Go_B(8);
 Off(OUT_BC);
 
 int x=0;
 while(x<6){
  int msg;
  ReceiveRemoteNumber(MAILBOX1,true,msg);
  
  if(msg == Boot){
   Wait(1000);
   Papercop();
   x++;
  }else{
   Off(OUT_BC);
  }
 }
}

¥È¥Ã¥×   ¿·µ¬ °ìÍ÷ ¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS