涼太郎 中村
/
f3rc2
めいん
Diff: main.cpp
- Revision:
- 3:3a1b0dda8c6c
- Parent:
- 1:a1e592eca305
--- a/main.cpp Tue Aug 30 06:51:41 2016 +0000 +++ b/main.cpp Thu Sep 01 05:49:45 2016 +0000 @@ -1,144 +1,18 @@ //受渡前での妨害に対応したい - #include"header.h" - -int team;//(-1)は青 +Serial pc(SERIAL_TX, SERIAL_RX); -int main(void){ - - teamSW.mode(PullUp); - if(teamSW){ - team=1; - teamledred=1; - teamledblue=0; - }else{ - team=-1; - teamledred=0; - teamledblue=1; - } - initmotor(); +int main() { initencorder(); - - move(0,0); - close_arm(); - /*以下redteamのフィールドマップを読み込む(mm) - - blue team の場合はすべてのy座標に(-1)をかける - - */ - - //オブジェクトの位置 - //原点はスタートゾーンの中心 - int targetx[9] = { 600,600,600,1200,900,1200,900,1200,900 }; - int targety[9] = { team*300,team*600,team*900,team*1200,team*900,team*600,team*600,0,team*300 }; - - //ハブの位置 - int hub1x = 600; - int hub1y = 0; - - int hub2x = 900; - int hub2y = 0; - - - int goalx = 0, goaly = team*1200;//受け渡しゾーンの中心 - //定義終了 - - int retry=0; + initmotor(); - //ここでretryに数値を代入 - - switch(retry){ - case 0: - open_hand(); - moveto(hub1x, hub1y); - - moveto(targetx[0], targety[0]); - close_hand(); - lift(1); - - case 1: - open_hand(); - moveto(targetx[1], targety[1]); - close_hand(); - lift(1); - - case 2: - open_hand(); - moveto(targetx[2], targety[2]); - close_hand(); - - moveto(goalx,goaly); - open_arm(); - release(); - back(); - //3つリリースした - case 3: - open_arm(); - open_hand(); - moveto(targetx[3], targety[3]); - close_arm(); - close_hand(); - lift(2); - - case 4: - open_hand(); - moveto(targetx[4], targety[4]); - close_hand(); - - moveto(goalx,goaly); - open_arm(); - release(); - back(); - //3つリリースした - case 5: - moveto(targetx[3], targety[3]);//ハブとして利用 - - open_arm(); - open_hand(); - moveto(targetx[5], targety[5]); - - close_arm(); - close_hand(); - lift(2); - - case 6: - open_hand(); - moveto(targetx[6], targety[6]); - close_hand(); - - - moveto(goalx,goaly); - open_arm(); - release(); - - back(); + move(31,29); + update(-right.getPulses(), left.getPulses()); + pc.printf("r:%d, l:%d, x:%d y:%d t:%f \n\r",right.getPulses(), left.getPulses(),x,y,theta*180/PI); + while(1){ + if(coordinateX()>300){move(0,0);} + } - case 7: - moveto(targetx[3], targety[3]);//ハブとして利用 - - open_arm(); - open_hand(); - moveto(targetx[7], targety[7]); - close_hand(); - lift(2); - - moveto(hub2x, hub2y); - - case 8: - open_hand(); - moveto(targetx[8], targety[8]); - close_hand(); - - - moveto(goalx,goaly); - open_arm(); - - back(); - - moveto(1800,team*1200);//invade - - return 0;//終了 - } -} \ No newline at end of file +}