めいん

Dependencies:   mbed

Committer:
choutin
Date:
Tue Aug 30 06:51:41 2016 +0000
Revision:
1:a1e592eca305
Parent:
0:df2659fd8031
Child:
2:b204cf2f9b60
Child:
3:3a1b0dda8c6c
abosu

Who changed what in which revision?

UserRevisionLine numberNew contents of line
choutin 0:df2659fd8031 1 //受渡前での妨害に対応したい
choutin 0:df2659fd8031 2
choutin 0:df2659fd8031 3 #include"header.h"
choutin 0:df2659fd8031 4
choutin 1:a1e592eca305 5 int team;//(-1)は青
choutin 1:a1e592eca305 6
choutin 0:df2659fd8031 7 int main(void){
choutin 0:df2659fd8031 8
choutin 1:a1e592eca305 9 teamSW.mode(PullUp);
choutin 1:a1e592eca305 10 if(teamSW){
choutin 1:a1e592eca305 11 team=1;
choutin 1:a1e592eca305 12 teamledred=1;
choutin 1:a1e592eca305 13 teamledblue=0;
choutin 1:a1e592eca305 14 }else{
choutin 1:a1e592eca305 15 team=-1;
choutin 1:a1e592eca305 16 teamledred=0;
choutin 1:a1e592eca305 17 teamledblue=1;
choutin 1:a1e592eca305 18 }
choutin 1:a1e592eca305 19 initmotor();
choutin 1:a1e592eca305 20 initencorder();
choutin 0:df2659fd8031 21
choutin 0:df2659fd8031 22 move(0,0);
choutin 0:df2659fd8031 23 close_arm();
choutin 0:df2659fd8031 24 /*以下redteamのフィールドマップを読み込む(mm)
choutin 0:df2659fd8031 25
choutin 0:df2659fd8031 26 blue team の場合はすべてのy座標に(-1)をかける
choutin 0:df2659fd8031 27
choutin 0:df2659fd8031 28 */
choutin 0:df2659fd8031 29
choutin 0:df2659fd8031 30 //オブジェクトの位置
choutin 0:df2659fd8031 31 //原点はスタートゾーンの中心
choutin 0:df2659fd8031 32 int targetx[9] = { 600,600,600,1200,900,1200,900,1200,900 };
choutin 1:a1e592eca305 33 int targety[9] = { team*300,team*600,team*900,team*1200,team*900,team*600,team*600,0,team*300 };
choutin 0:df2659fd8031 34
choutin 0:df2659fd8031 35 //ハブの位置
choutin 0:df2659fd8031 36 int hub1x = 600;
choutin 0:df2659fd8031 37 int hub1y = 0;
choutin 0:df2659fd8031 38
choutin 0:df2659fd8031 39 int hub2x = 900;
choutin 0:df2659fd8031 40 int hub2y = 0;
choutin 0:df2659fd8031 41
choutin 0:df2659fd8031 42
choutin 1:a1e592eca305 43 int goalx = 0, goaly = team*1200;//受け渡しゾーンの中心
choutin 0:df2659fd8031 44 //定義終了
choutin 0:df2659fd8031 45
choutin 0:df2659fd8031 46 int retry=0;
choutin 0:df2659fd8031 47
choutin 0:df2659fd8031 48
choutin 0:df2659fd8031 49 //ここでretryに数値を代入
choutin 0:df2659fd8031 50
choutin 0:df2659fd8031 51 switch(retry){
choutin 0:df2659fd8031 52 case 0:
choutin 0:df2659fd8031 53 open_hand();
choutin 0:df2659fd8031 54 moveto(hub1x, hub1y);
choutin 0:df2659fd8031 55
choutin 0:df2659fd8031 56 moveto(targetx[0], targety[0]);
choutin 0:df2659fd8031 57 close_hand();
choutin 0:df2659fd8031 58 lift(1);
choutin 0:df2659fd8031 59
choutin 0:df2659fd8031 60 case 1:
choutin 0:df2659fd8031 61 open_hand();
choutin 0:df2659fd8031 62 moveto(targetx[1], targety[1]);
choutin 0:df2659fd8031 63 close_hand();
choutin 0:df2659fd8031 64 lift(1);
choutin 0:df2659fd8031 65
choutin 0:df2659fd8031 66 case 2:
choutin 0:df2659fd8031 67 open_hand();
choutin 0:df2659fd8031 68 moveto(targetx[2], targety[2]);
choutin 0:df2659fd8031 69 close_hand();
choutin 0:df2659fd8031 70
choutin 0:df2659fd8031 71 moveto(goalx,goaly);
choutin 0:df2659fd8031 72 open_arm();
choutin 0:df2659fd8031 73 release();
choutin 0:df2659fd8031 74 back();
choutin 0:df2659fd8031 75 //3つリリースした
choutin 0:df2659fd8031 76 case 3:
choutin 0:df2659fd8031 77 open_arm();
choutin 0:df2659fd8031 78 open_hand();
choutin 0:df2659fd8031 79 moveto(targetx[3], targety[3]);
choutin 0:df2659fd8031 80 close_arm();
choutin 0:df2659fd8031 81 close_hand();
choutin 0:df2659fd8031 82 lift(2);
choutin 0:df2659fd8031 83
choutin 0:df2659fd8031 84 case 4:
choutin 0:df2659fd8031 85 open_hand();
choutin 0:df2659fd8031 86 moveto(targetx[4], targety[4]);
choutin 0:df2659fd8031 87 close_hand();
choutin 0:df2659fd8031 88
choutin 0:df2659fd8031 89 moveto(goalx,goaly);
choutin 0:df2659fd8031 90 open_arm();
choutin 0:df2659fd8031 91 release();
choutin 0:df2659fd8031 92 back();
choutin 0:df2659fd8031 93 //3つリリースした
choutin 0:df2659fd8031 94
choutin 0:df2659fd8031 95 case 5:
choutin 0:df2659fd8031 96 moveto(targetx[3], targety[3]);//ハブとして利用
choutin 0:df2659fd8031 97
choutin 0:df2659fd8031 98 open_arm();
choutin 0:df2659fd8031 99 open_hand();
choutin 0:df2659fd8031 100 moveto(targetx[5], targety[5]);
choutin 0:df2659fd8031 101
choutin 0:df2659fd8031 102 close_arm();
choutin 0:df2659fd8031 103 close_hand();
choutin 0:df2659fd8031 104 lift(2);
choutin 0:df2659fd8031 105
choutin 0:df2659fd8031 106 case 6:
choutin 0:df2659fd8031 107 open_hand();
choutin 0:df2659fd8031 108 moveto(targetx[6], targety[6]);
choutin 0:df2659fd8031 109 close_hand();
choutin 0:df2659fd8031 110
choutin 0:df2659fd8031 111
choutin 0:df2659fd8031 112 moveto(goalx,goaly);
choutin 0:df2659fd8031 113 open_arm();
choutin 0:df2659fd8031 114 release();
choutin 0:df2659fd8031 115
choutin 0:df2659fd8031 116 back();
choutin 0:df2659fd8031 117
choutin 0:df2659fd8031 118 case 7:
choutin 0:df2659fd8031 119 moveto(targetx[3], targety[3]);//ハブとして利用
choutin 0:df2659fd8031 120
choutin 0:df2659fd8031 121 open_arm();
choutin 0:df2659fd8031 122 open_hand();
choutin 0:df2659fd8031 123 moveto(targetx[7], targety[7]);
choutin 0:df2659fd8031 124 close_hand();
choutin 0:df2659fd8031 125 lift(2);
choutin 0:df2659fd8031 126
choutin 0:df2659fd8031 127 moveto(hub2x, hub2y);
choutin 0:df2659fd8031 128
choutin 0:df2659fd8031 129 case 8:
choutin 0:df2659fd8031 130 open_hand();
choutin 0:df2659fd8031 131 moveto(targetx[8], targety[8]);
choutin 0:df2659fd8031 132 close_hand();
choutin 0:df2659fd8031 133
choutin 0:df2659fd8031 134
choutin 0:df2659fd8031 135 moveto(goalx,goaly);
choutin 0:df2659fd8031 136 open_arm();
choutin 0:df2659fd8031 137
choutin 0:df2659fd8031 138 back();
choutin 0:df2659fd8031 139
choutin 1:a1e592eca305 140 moveto(1800,team*1200);//invade
choutin 0:df2659fd8031 141
choutin 0:df2659fd8031 142 return 0;//終了
choutin 0:df2659fd8031 143 }
choutin 0:df2659fd8031 144 }