Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed AQM1602 HMC6352 PID
main_processing/strategy/strategy.cpp@33:aa115c30892e, 2016-03-24 (annotated)
- Committer:
- lilac0112_1
- Date:
- Thu Mar 24 11:50:01 2016 +0000
- Revision:
- 33:aa115c30892e
- Parent:
- 32:367b16d69a32
- Child:
- 34:1c86c1299ea4
drib
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lilac0112_1 | 0:ea35c18c85fc | 1 | #include "mbed.h" |
| lilac0112_1 | 0:ea35c18c85fc | 2 | #include "extern.h" |
| lilac0112_1 | 0:ea35c18c85fc | 3 | |
| lilac0112_1 | 0:ea35c18c85fc | 4 | //Atk |
| lilac0112_1 | 0:ea35c18c85fc | 5 | void modeAttack4(void){ |
| lilac0112_1 | 24:34ef6379b0df | 6 | //irの値に影響するモーター補正値 |
| lilac0112_1 | 25:a7460e23e02e | 7 | //uint8_t ir_pow; |
| lilac0112_1 | 25:a7460e23e02e | 8 | uint8_t ir_pow_x, ir_pow_y; |
| lilac0112_1 | 10:6df631c39f9b | 9 | double ir_x_dir, ir_y_dir; |
| lilac0112_1 | 11:3efae754e6ef | 10 | double ir_x_turn, ir_y_turn; |
| lilac0112_1 | 11:3efae754e6ef | 11 | double ir_x, ir_y; |
| lilac0112_1 | 24:34ef6379b0df | 12 | //lineの値に影響するモーター補正値 |
| lilac0112_1 | 14:b510adcb6065 | 13 | double LineSlowPower[2]; |
| lilac0112_1 | 14:b510adcb6065 | 14 | double LineReturnPower[2]; |
| lilac0112_1 | 33:aa115c30892e | 15 | |
| lilac0112_1 | 24:34ef6379b0df | 16 | //モーターの出力値 |
| lilac0112_1 | 10:6df631c39f9b | 17 | int vx,vy,vs; |
| lilac0112_1 | 11:3efae754e6ef | 18 | |
| lilac0112_1 | 24:34ef6379b0df | 19 | ////初期値を決める等 |
| lilac0112_1 | 10:6df631c39f9b | 20 | if(sys.KickOffFlag==1){ |
| lilac0112_1 | 30:5998ba42237e | 21 | /* |
| lilac0112_1 | 24:34ef6379b0df | 22 | ///Blindシリーズ.1を代入であらゆるセンサーなどの値を反映させないようにする. |
| lilac0112_1 | 27:825c6835e3db | 23 | sys.IrBlind=0; |
| lilac0112_1 | 10:6df631c39f9b | 24 | sys.LineBlind=0; |
| lilac0112_1 | 10:6df631c39f9b | 25 | sys.PingBlind=0; |
| lilac0112_1 | 10:6df631c39f9b | 26 | |
| lilac0112_1 | 26:6ca88eeaa2b4 | 27 | sys.HomeBlind=1; |
| lilac0112_1 | 26:6ca88eeaa2b4 | 28 | sys.DriBlind=1; |
| lilac0112_1 | 30:5998ba42237e | 29 | //defence |
| lilac0112_1 | 30:5998ba42237e | 30 | sys.DefenceFlag=0; |
| lilac0112_1 | 30:5998ba42237e | 31 | */ |
| lilac0112_1 | 30:5998ba42237e | 32 | |
| lilac0112_1 | 30:5998ba42237e | 33 | |
| lilac0112_1 | 24:34ef6379b0df | 34 | //Kick |
| lilac0112_1 | 24:34ef6379b0df | 35 | sys.KickStopFlag=0; |
| lilac0112_1 | 24:34ef6379b0df | 36 | //Ir |
| lilac0112_1 | 18:3a42a931c95a | 37 | sys.ir_pow_table = 0; |
| lilac0112_1 | 24:34ef6379b0df | 38 | //Line |
| lilac0112_1 | 30:5998ba42237e | 39 | //data.lnCorner[L_LINE]=data.lnCorner[R_LINE]=data.lnCorner[F_LINE]=data.lnCorner[B_LINE]=LINE_EMPTY; |
| lilac0112_1 | 18:3a42a931c95a | 40 | data.lnRepeat = 0; |
| lilac0112_1 | 24:34ef6379b0df | 41 | data.lnStay[X_LINE]=data.lnStay[Y_LINE]=1; |
| lilac0112_1 | 30:5998ba42237e | 42 | data.lnStayNow[X_LINE]=data.lnStayNow[Y_LINE]=0; |
| lilac0112_1 | 18:3a42a931c95a | 43 | data.lnStop[X_LINE]=data.lnStop[Y_LINE]=1; |
| lilac0112_1 | 30:5998ba42237e | 44 | |
| lilac0112_1 | 30:5998ba42237e | 45 | //data.FieldSpot = LINE_INSIDE; |
| lilac0112_1 | 30:5998ba42237e | 46 | //LineLiberate(); |
| lilac0112_1 | 30:5998ba42237e | 47 | //LineRankClear(); |
| lilac0112_1 | 27:825c6835e3db | 48 | |
| lilac0112_1 | 27:825c6835e3db | 49 | LineRawRankClear(); |
| lilac0112_1 | 30:5998ba42237e | 50 | |
| lilac0112_1 | 30:5998ba42237e | 51 | //data.lnRawMemory[A_SPOT]=0; |
| lilac0112_1 | 30:5998ba42237e | 52 | //data.lnRawMemory[B_SPOT]=0; |
| lilac0112_1 | 30:5998ba42237e | 53 | //data.lnRawMemory[C_SPOT]=0; |
| lilac0112_1 | 27:825c6835e3db | 54 | |
| lilac0112_1 | 27:825c6835e3db | 55 | data.lnRawReturn=0; |
| lilac0112_1 | 27:825c6835e3db | 56 | |
| lilac0112_1 | 27:825c6835e3db | 57 | LineRawLogReset(); |
| lilac0112_1 | 25:a7460e23e02e | 58 | //backhome |
| lilac0112_1 | 25:a7460e23e02e | 59 | sys.HomeStayFlag[X_PING]=0; |
| lilac0112_1 | 25:a7460e23e02e | 60 | sys.HomeStayFlag[Y_PING]=0; |
| lilac0112_1 | 24:34ef6379b0df | 61 | //pid |
| lilac0112_1 | 24:34ef6379b0df | 62 | sys.TurnStopFlag=0; |
| lilac0112_1 | 25:a7460e23e02e | 63 | cmps_set.AtkDeg=0; |
| lilac0112_1 | 25:a7460e23e02e | 64 | cmps_set.HoldDeg=0; |
| lilac0112_1 | 30:5998ba42237e | 65 | cmps_set.GoalDeg=0; |
| lilac0112_1 | 24:34ef6379b0df | 66 | //ドリブラー |
| lilac0112_1 | 25:a7460e23e02e | 67 | sys.BallHoldJudgeFlag=0; |
| lilac0112_1 | 25:a7460e23e02e | 68 | sys.BallHoldFlag=0; |
| lilac0112_1 | 19:967207de919d | 69 | |
| lilac0112_1 | 24:34ef6379b0df | 70 | //初期値設定の終了 |
| lilac0112_1 | 10:6df631c39f9b | 71 | sys.KickOffFlag=0; |
| lilac0112_1 | 0:ea35c18c85fc | 72 | } |
| lilac0112_1 | 24:34ef6379b0df | 73 | ////DataRetrieve |
| lilac0112_1 | 19:967207de919d | 74 | if(sys.InfoFlag==1){ReadInfo();sys.InfoFlag=0;} |
| lilac0112_1 | 11:3efae754e6ef | 75 | data.lnRaw = LineRaw; |
| lilac0112_1 | 11:3efae754e6ef | 76 | data.lnHold = LineHold; |
| lilac0112_1 | 21:378470320524 | 77 | data.ball = ReadBall(); |
| lilac0112_1 | 19:967207de919d | 78 | |
| lilac0112_1 | 24:34ef6379b0df | 79 | //ボールがなければ自分のゴールに戻る |
| lilac0112_1 | 24:34ef6379b0df | 80 | if(data.irNotice==IR_NONE){ |
| lilac0112_1 | 33:aa115c30892e | 81 | |
| lilac0112_1 | 33:aa115c30892e | 82 | cmps_set.GoalDeg=0; |
| lilac0112_1 | 24:34ef6379b0df | 83 | sys.BackHomeFlag=(sys.HomeBlind==0); |
| lilac0112_1 | 24:34ef6379b0df | 84 | } |
| lilac0112_1 | 24:34ef6379b0df | 85 | else{ |
| lilac0112_1 | 24:34ef6379b0df | 86 | sys.BackHomeFlag=0; |
| lilac0112_1 | 25:a7460e23e02e | 87 | sys.HomeStayFlag[X_PING]=0; |
| lilac0112_1 | 25:a7460e23e02e | 88 | sys.HomeStayFlag[Y_PING]=0; |
| lilac0112_1 | 24:34ef6379b0df | 89 | } |
| lilac0112_1 | 24:34ef6379b0df | 90 | //回り込みの値を代入 |
| lilac0112_1 | 30:5998ba42237e | 91 | if(sys.DefenceFlag==1){ |
| lilac0112_1 | 30:5998ba42237e | 92 | |
| lilac0112_1 | 30:5998ba42237e | 93 | if((data.irNotice==IR_NONE)||(data.irNotice==IR_FAR)){ |
| lilac0112_1 | 30:5998ba42237e | 94 | |
| lilac0112_1 | 30:5998ba42237e | 95 | if((data.ping[L_PING]>=50)&&(data.ping[R_PING]>=50)){ |
| lilac0112_1 | 30:5998ba42237e | 96 | ir_x_dir = ir_move_val[5][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 97 | ir_x_turn = ir_move_val[5][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 98 | |
| lilac0112_1 | 30:5998ba42237e | 99 | if(data.ping[B_PING]>=10){ |
| lilac0112_1 | 30:5998ba42237e | 100 | ir_y_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 101 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 102 | } |
| lilac0112_1 | 30:5998ba42237e | 103 | else{ |
| lilac0112_1 | 30:5998ba42237e | 104 | ir_y_dir = 0; |
| lilac0112_1 | 30:5998ba42237e | 105 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 106 | } |
| lilac0112_1 | 30:5998ba42237e | 107 | } |
| lilac0112_1 | 30:5998ba42237e | 108 | else if((data.ping[L_PING]>=50)&&(data.ping[R_PING]<50)){ |
| lilac0112_1 | 30:5998ba42237e | 109 | ir_x_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 110 | ir_x_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 111 | |
| lilac0112_1 | 30:5998ba42237e | 112 | if(data.ping[B_PING]>=45){ |
| lilac0112_1 | 30:5998ba42237e | 113 | ir_y_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 114 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 115 | } |
| lilac0112_1 | 30:5998ba42237e | 116 | else{ |
| lilac0112_1 | 30:5998ba42237e | 117 | ir_y_dir = 0; |
| lilac0112_1 | 30:5998ba42237e | 118 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 119 | } |
| lilac0112_1 | 30:5998ba42237e | 120 | } |
| lilac0112_1 | 30:5998ba42237e | 121 | else if((data.ping[L_PING]<50)&&(data.ping[R_PING]>=50)){ |
| lilac0112_1 | 30:5998ba42237e | 122 | ir_x_dir = 1; |
| lilac0112_1 | 30:5998ba42237e | 123 | ir_x_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 124 | |
| lilac0112_1 | 30:5998ba42237e | 125 | if(data.ping[B_PING]>=45){ |
| lilac0112_1 | 30:5998ba42237e | 126 | ir_y_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 127 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 128 | } |
| lilac0112_1 | 30:5998ba42237e | 129 | else{ |
| lilac0112_1 | 30:5998ba42237e | 130 | ir_y_dir = 0; |
| lilac0112_1 | 30:5998ba42237e | 131 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 132 | } |
| lilac0112_1 | 30:5998ba42237e | 133 | } |
| lilac0112_1 | 30:5998ba42237e | 134 | else if((data.ping[L_PING]<50)&&(data.ping[R_PING]<50)){ |
| lilac0112_1 | 30:5998ba42237e | 135 | ir_x_dir = 0; |
| lilac0112_1 | 30:5998ba42237e | 136 | ir_x_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 137 | |
| lilac0112_1 | 30:5998ba42237e | 138 | if(data.ping[B_PING]>=45){ |
| lilac0112_1 | 30:5998ba42237e | 139 | ir_y_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 140 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 141 | } |
| lilac0112_1 | 30:5998ba42237e | 142 | else{ |
| lilac0112_1 | 30:5998ba42237e | 143 | ir_y_dir = 0; |
| lilac0112_1 | 30:5998ba42237e | 144 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 145 | } |
| lilac0112_1 | 30:5998ba42237e | 146 | } |
| lilac0112_1 | 30:5998ba42237e | 147 | } |
| lilac0112_1 | 30:5998ba42237e | 148 | else{ |
| lilac0112_1 | 30:5998ba42237e | 149 | |
| lilac0112_1 | 30:5998ba42237e | 150 | ir_x_dir = ir_move_val[5][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 151 | ir_x_turn = ir_move_val[5][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 152 | |
| lilac0112_1 | 30:5998ba42237e | 153 | if((data.ping[B_PING]>=5)&&(data.ping[R_PING]>=50)&&(data.ping[L_PING]>=50)){ |
| lilac0112_1 | 30:5998ba42237e | 154 | ir_y_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 155 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 156 | } |
| lilac0112_1 | 30:5998ba42237e | 157 | else{ |
| lilac0112_1 | 30:5998ba42237e | 158 | ir_y_dir = 0; |
| lilac0112_1 | 30:5998ba42237e | 159 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 160 | } |
| lilac0112_1 | 30:5998ba42237e | 161 | } |
| lilac0112_1 | 30:5998ba42237e | 162 | /* |
| lilac0112_1 | 30:5998ba42237e | 163 | if((data.ping[L_PING]>=50)&&(data.ping[R_PING]>=50)&&(data.ping[B_PING]>10)){ |
| lilac0112_1 | 30:5998ba42237e | 164 | ir_y_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 165 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 166 | |
| lilac0112_1 | 30:5998ba42237e | 167 | if(data.ping[B_PING]>=10){ |
| lilac0112_1 | 30:5998ba42237e | 168 | ir_y_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 169 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 170 | } |
| lilac0112_1 | 30:5998ba42237e | 171 | else{ |
| lilac0112_1 | 30:5998ba42237e | 172 | ir_y_dir = 0; |
| lilac0112_1 | 30:5998ba42237e | 173 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 174 | } |
| lilac0112_1 | 30:5998ba42237e | 175 | |
| lilac0112_1 | 30:5998ba42237e | 176 | ir_x_dir = ir_move_val[2][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 177 | ir_x_turn = ir_move_val[2][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 178 | } |
| lilac0112_1 | 30:5998ba42237e | 179 | else{ |
| lilac0112_1 | 30:5998ba42237e | 180 | |
| lilac0112_1 | 30:5998ba42237e | 181 | } |
| lilac0112_1 | 30:5998ba42237e | 182 | */ |
| lilac0112_1 | 30:5998ba42237e | 183 | /* |
| lilac0112_1 | 30:5998ba42237e | 184 | if((data.ping[B_PING]>=45)&&(data.irNotice!=IR_NONE)&&(15<=data.irPosition)&&(data.irPosition<=19)){ |
| lilac0112_1 | 30:5998ba42237e | 185 | //sys.ir_pow_table=1; |
| lilac0112_1 | 30:5998ba42237e | 186 | ir_x_dir = 0; |
| lilac0112_1 | 30:5998ba42237e | 187 | ir_y_dir = -1; |
| lilac0112_1 | 30:5998ba42237e | 188 | ir_x_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 189 | ir_y_turn = 0; |
| lilac0112_1 | 30:5998ba42237e | 190 | } |
| lilac0112_1 | 30:5998ba42237e | 191 | else{ |
| lilac0112_1 | 30:5998ba42237e | 192 | if(data.irValPhase[IR_SHORT]>=DIS_4){ |
| lilac0112_1 | 30:5998ba42237e | 193 | sys.ir_pow_table=2;//直進 |
| lilac0112_1 | 30:5998ba42237e | 194 | ir_x_dir = ir_move_val[2][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 195 | ir_y_dir = ir_move_val[2][data.irNotice][data.irPosition][IR_Y_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 196 | ir_x_turn = ir_move_val[2][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 197 | ir_y_turn = ir_move_val[2][data.irNotice][data.irPosition][IR_Y_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 198 | } |
| lilac0112_1 | 30:5998ba42237e | 199 | else{ |
| lilac0112_1 | 30:5998ba42237e | 200 | if(data.irValPhase[IR_SHORT]<=DIS_1){ |
| lilac0112_1 | 30:5998ba42237e | 201 | sys.ir_pow_table=0;//3 |
| lilac0112_1 | 30:5998ba42237e | 202 | ir_x_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 203 | ir_y_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 204 | ir_x_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 205 | ir_y_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 206 | } |
| lilac0112_1 | 30:5998ba42237e | 207 | else{ |
| lilac0112_1 | 30:5998ba42237e | 208 | sys.ir_pow_table=0; |
| lilac0112_1 | 30:5998ba42237e | 209 | ir_x_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 210 | ir_y_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 211 | ir_x_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 212 | ir_y_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 213 | } |
| lilac0112_1 | 30:5998ba42237e | 214 | } |
| lilac0112_1 | 30:5998ba42237e | 215 | }*/ |
| lilac0112_1 | 24:34ef6379b0df | 216 | } |
| lilac0112_1 | 24:34ef6379b0df | 217 | else{ |
| lilac0112_1 | 30:5998ba42237e | 218 | if((data.ping[B_PING]>40)&&(0)){ |
| lilac0112_1 | 30:5998ba42237e | 219 | sys.ir_pow_table=0; |
| lilac0112_1 | 30:5998ba42237e | 220 | ir_x_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 221 | ir_y_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 222 | ir_x_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 223 | ir_y_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_TURN]; |
| lilac0112_1 | 29:e8bafe48aa90 | 224 | } |
| lilac0112_1 | 29:e8bafe48aa90 | 225 | else{ |
| lilac0112_1 | 30:5998ba42237e | 226 | if((data.ping[B_PING]>60)&&(data.irValPhase[IR_SHORT]>=DIS_4)){ |
| lilac0112_1 | 30:5998ba42237e | 227 | sys.ir_pow_table=2;//直進 |
| lilac0112_1 | 30:5998ba42237e | 228 | ir_x_dir = ir_move_val[2][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 229 | ir_y_dir = ir_move_val[2][data.irNotice][data.irPosition][IR_Y_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 230 | ir_x_turn = ir_move_val[2][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 231 | ir_y_turn = ir_move_val[2][data.irNotice][data.irPosition][IR_Y_TURN]; |
| lilac0112_1 | 29:e8bafe48aa90 | 232 | } |
| lilac0112_1 | 29:e8bafe48aa90 | 233 | else{ |
| lilac0112_1 | 30:5998ba42237e | 234 | if(data.irValPhase[IR_SHORT]<=DIS_1){ |
| lilac0112_1 | 30:5998ba42237e | 235 | sys.ir_pow_table=0;//3 |
| lilac0112_1 | 30:5998ba42237e | 236 | ir_x_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 237 | ir_y_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 238 | ir_x_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 239 | ir_y_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 240 | } |
| lilac0112_1 | 30:5998ba42237e | 241 | else{ |
| lilac0112_1 | 30:5998ba42237e | 242 | sys.ir_pow_table=0; |
| lilac0112_1 | 30:5998ba42237e | 243 | ir_x_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 244 | ir_y_dir = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_DIR]; |
| lilac0112_1 | 30:5998ba42237e | 245 | ir_x_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 246 | ir_y_turn = ir_move_val[0][data.irNotice][data.irPosition][IR_Y_TURN]; |
| lilac0112_1 | 30:5998ba42237e | 247 | } |
| lilac0112_1 | 29:e8bafe48aa90 | 248 | } |
| lilac0112_1 | 29:e8bafe48aa90 | 249 | } |
| lilac0112_1 | 32:367b16d69a32 | 250 | if((sys.HomeBlind==0)){ |
| lilac0112_1 | 32:367b16d69a32 | 251 | if(((data.irNotice==IR_CLOSE)||(data.irNotice==IR_CLOSER))&&(data.ping[B_PING]<60)&& |
| lilac0112_1 | 32:367b16d69a32 | 252 | ( |
| lilac0112_1 | 32:367b16d69a32 | 253 | (data.irPosition==11)|| |
| lilac0112_1 | 32:367b16d69a32 | 254 | (data.irPosition==(ir_posi_s[(11-8+24+1)%12]))|| |
| lilac0112_1 | 32:367b16d69a32 | 255 | (data.irPosition==(ir_posi_s[(11-8+24-1)%12]))|| |
| lilac0112_1 | 32:367b16d69a32 | 256 | (data.irPosition==(ir_posi_s[(11-8+24+2)%12]))|| |
| lilac0112_1 | 32:367b16d69a32 | 257 | (data.irPosition==(ir_posi_s[(11-8+24-2)%12]))|| |
| lilac0112_1 | 32:367b16d69a32 | 258 | (data.irPosition==(ir_posi_s[(11-8+24+3)%12]))|| |
| lilac0112_1 | 32:367b16d69a32 | 259 | (data.irPosition==(ir_posi_s[(11-8+24-3)%12])) |
| lilac0112_1 | 32:367b16d69a32 | 260 | ) |
| lilac0112_1 | 32:367b16d69a32 | 261 | ){ |
| lilac0112_1 | 32:367b16d69a32 | 262 | sys.ir_pow_table=2;//直進 |
| lilac0112_1 | 32:367b16d69a32 | 263 | ir_x_dir = ir_move_val[2][data.irNotice][data.irPosition][IR_X_DIR]; |
| lilac0112_1 | 32:367b16d69a32 | 264 | ir_y_dir = ir_move_val[2][data.irNotice][data.irPosition][IR_Y_DIR]; |
| lilac0112_1 | 32:367b16d69a32 | 265 | ir_x_turn = ir_move_val[2][data.irNotice][data.irPosition][IR_X_TURN]; |
| lilac0112_1 | 32:367b16d69a32 | 266 | ir_y_turn = ir_move_val[2][data.irNotice][data.irPosition][IR_Y_TURN]; |
| lilac0112_1 | 32:367b16d69a32 | 267 | } |
| lilac0112_1 | 32:367b16d69a32 | 268 | } |
| lilac0112_1 | 24:34ef6379b0df | 269 | } |
| lilac0112_1 | 30:5998ba42237e | 270 | |
| lilac0112_1 | 24:34ef6379b0df | 271 | //Irの検出値によって出力を調整 |
| lilac0112_1 | 24:34ef6379b0df | 272 | if(data.irNotice==IR_CLOSER){ |
| lilac0112_1 | 25:a7460e23e02e | 273 | //ir_pow = sys.s_pow; |
| lilac0112_1 | 25:a7460e23e02e | 274 | ir_pow_x = ir_pow_y = sys.s_pow; |
| lilac0112_1 | 24:34ef6379b0df | 275 | } |
| lilac0112_1 | 24:34ef6379b0df | 276 | else if(data.irNotice==IR_CLOSE){ |
| lilac0112_1 | 25:a7460e23e02e | 277 | //ir_pow = sys.m_pow; |
| lilac0112_1 | 25:a7460e23e02e | 278 | ir_pow_x = ir_pow_y = sys.m_pow; |
| lilac0112_1 | 24:34ef6379b0df | 279 | } |
| lilac0112_1 | 24:34ef6379b0df | 280 | else if(data.irNotice==IR_FAR){ |
| lilac0112_1 | 25:a7460e23e02e | 281 | //ir_pow = sys.l_pow; |
| lilac0112_1 | 25:a7460e23e02e | 282 | ir_pow_x = ir_pow_y = sys.l_pow; |
| lilac0112_1 | 24:34ef6379b0df | 283 | } |
| lilac0112_1 | 24:34ef6379b0df | 284 | else{//data.irNotice==IR_NONE |
| lilac0112_1 | 25:a7460e23e02e | 285 | //ir_pow = 0; |
| lilac0112_1 | 25:a7460e23e02e | 286 | ir_pow_x = ir_pow_y = 0; |
| lilac0112_1 | 24:34ef6379b0df | 287 | } |
| lilac0112_1 | 30:5998ba42237e | 288 | |
| lilac0112_1 | 30:5998ba42237e | 289 | if(sys.DefenceFlag==1){ |
| lilac0112_1 | 30:5998ba42237e | 290 | ir_pow_x = 30; |
| lilac0112_1 | 30:5998ba42237e | 291 | ir_pow_y = 30; |
| lilac0112_1 | 30:5998ba42237e | 292 | if(data.ping[L_PING]<=60){ |
| lilac0112_1 | 30:5998ba42237e | 293 | ir_pow_y = 30; |
| lilac0112_1 | 30:5998ba42237e | 294 | } |
| lilac0112_1 | 30:5998ba42237e | 295 | if(data.ping[L_PING]<=40){ |
| lilac0112_1 | 30:5998ba42237e | 296 | ir_pow_y = 25; |
| lilac0112_1 | 30:5998ba42237e | 297 | } |
| lilac0112_1 | 30:5998ba42237e | 298 | if(data.ping[L_PING]<=30){ |
| lilac0112_1 | 30:5998ba42237e | 299 | ir_pow_y = 20; |
| lilac0112_1 | 30:5998ba42237e | 300 | } |
| lilac0112_1 | 30:5998ba42237e | 301 | if(data.ping[L_PING]<15){ |
| lilac0112_1 | 30:5998ba42237e | 302 | ir_pow_y = 15; |
| lilac0112_1 | 30:5998ba42237e | 303 | } |
| lilac0112_1 | 30:5998ba42237e | 304 | if(data.ping[L_PING]<10){ |
| lilac0112_1 | 30:5998ba42237e | 305 | ir_pow_y = 10; |
| lilac0112_1 | 30:5998ba42237e | 306 | } |
| lilac0112_1 | 30:5998ba42237e | 307 | } |
| lilac0112_1 | 33:aa115c30892e | 308 | ////ドリブラーdribbler |
| lilac0112_1 | 33:aa115c30892e | 309 | //ホールド判定hold |
| lilac0112_1 | 25:a7460e23e02e | 310 | JudgeBallHolding(); |
| lilac0112_1 | 33:aa115c30892e | 311 | //JudgeBallHold(); |
| lilac0112_1 | 33:aa115c30892e | 312 | //sys.BallHoldFlag = data.ball; |
| lilac0112_1 | 25:a7460e23e02e | 313 | //ドリブラー駆動 |
| lilac0112_1 | 33:aa115c30892e | 314 | /*if((sys.TurnDriBlind==0)&&(data.lnRawOrderLog1[0]!=LINE_EMPTY)&&(data.lnRawOrder[0]==LINE_EMPTY)){ |
| lilac0112_1 | 33:aa115c30892e | 315 | if(sys.TurnDriBlind==0){ |
| lilac0112_1 | 32:367b16d69a32 | 316 | if( |
| lilac0112_1 | 32:367b16d69a32 | 317 | ((data.lnRawOrderLog1[0]==A_SPOT)&&(data.lnRawOrderLog1[1]==B_SPOT))|| |
| lilac0112_1 | 32:367b16d69a32 | 318 | ((data.lnRawOrderLog1[0]==B_SPOT)&&(data.lnRawOrderLog1[1]==A_SPOT)) |
| lilac0112_1 | 32:367b16d69a32 | 319 | ){ |
| lilac0112_1 | 32:367b16d69a32 | 320 | cmps_set.GoalDeg=0; |
| lilac0112_1 | 32:367b16d69a32 | 321 | } |
| lilac0112_1 | 32:367b16d69a32 | 322 | else if((data.lnRawOrderLog1[0]==A_SPOT)&&(1)){ |
| lilac0112_1 | 32:367b16d69a32 | 323 | cmps_set.GoalDeg=-30; |
| lilac0112_1 | 32:367b16d69a32 | 324 | } |
| lilac0112_1 | 32:367b16d69a32 | 325 | else if((data.lnRawOrderLog1[0]==B_SPOT)&&(1)){ |
| lilac0112_1 | 32:367b16d69a32 | 326 | cmps_set.GoalDeg=30; |
| lilac0112_1 | 32:367b16d69a32 | 327 | } |
| lilac0112_1 | 32:367b16d69a32 | 328 | else{ |
| lilac0112_1 | 32:367b16d69a32 | 329 | cmps_set.GoalDeg=0; |
| lilac0112_1 | 32:367b16d69a32 | 330 | } |
| lilac0112_1 | 30:5998ba42237e | 331 | } |
| lilac0112_1 | 33:aa115c30892e | 332 | }*/ |
| lilac0112_1 | 33:aa115c30892e | 333 | if((sys.TurnDriBlind==0)&&(/*data.lnRaw==0*/1)&&((data.irNotice==IR_CLOSER)||(data.irNotice==IR_CLOSE))&&(/*data.ping[B_PING]>90*/1)&& |
| lilac0112_1 | 33:aa115c30892e | 334 | ( |
| lilac0112_1 | 33:aa115c30892e | 335 | (data.irPosition==11)|| |
| lilac0112_1 | 33:aa115c30892e | 336 | (data.irPosition==(ir_posi_s[(11-8+24+1)%12]))|| |
| lilac0112_1 | 33:aa115c30892e | 337 | (data.irPosition==(ir_posi_s[(11-8+24-1)%12]))|| |
| lilac0112_1 | 33:aa115c30892e | 338 | (data.irPosition==(ir_posi_s[(11-8+24+2)%12]))|| |
| lilac0112_1 | 33:aa115c30892e | 339 | (data.irPosition==(ir_posi_s[(11-8+24-2)%12])) |
| lilac0112_1 | 33:aa115c30892e | 340 | ) |
| lilac0112_1 | 33:aa115c30892e | 341 | |
| lilac0112_1 | 33:aa115c30892e | 342 | ){ |
| lilac0112_1 | 33:aa115c30892e | 343 | if(sys.TurnDriBlind==0){ |
| lilac0112_1 | 33:aa115c30892e | 344 | if( |
| lilac0112_1 | 33:aa115c30892e | 345 | ((data.ping[L_PING]<40)&&(data.ping[R_PING]>70)) |
| lilac0112_1 | 33:aa115c30892e | 346 | ){ |
| lilac0112_1 | 33:aa115c30892e | 347 | cmps_set.GoalDeg=60; |
| lilac0112_1 | 33:aa115c30892e | 348 | } |
| lilac0112_1 | 33:aa115c30892e | 349 | else if( |
| lilac0112_1 | 33:aa115c30892e | 350 | ((data.ping[R_PING]<40)&&(data.ping[L_PING]>70)) |
| lilac0112_1 | 33:aa115c30892e | 351 | ){ |
| lilac0112_1 | 33:aa115c30892e | 352 | cmps_set.GoalDeg=-60; |
| lilac0112_1 | 33:aa115c30892e | 353 | } |
| lilac0112_1 | 33:aa115c30892e | 354 | else{ |
| lilac0112_1 | 33:aa115c30892e | 355 | cmps_set.GoalDeg=0; |
| lilac0112_1 | 33:aa115c30892e | 356 | } |
| lilac0112_1 | 33:aa115c30892e | 357 | } |
| lilac0112_1 | 30:5998ba42237e | 358 | } |
| lilac0112_1 | 25:a7460e23e02e | 359 | if((sys.DriBlind==0)&&(data.irNotice==IR_CLOSER)&&((data.irPosition==10)||(data.irPosition==11)||(data.irPosition==12))){ |
| lilac0112_1 | 25:a7460e23e02e | 360 | sys.DribbleFlag=1; |
| lilac0112_1 | 30:5998ba42237e | 361 | if((sys.BallHoldFlag==1)||(data.ball==1)){ |
| lilac0112_1 | 25:a7460e23e02e | 362 | //ir_pow=20; |
| lilac0112_1 | 25:a7460e23e02e | 363 | ir_pow_x = ir_pow_y = 20; |
| lilac0112_1 | 19:967207de919d | 364 | } |
| lilac0112_1 | 19:967207de919d | 365 | } |
| lilac0112_1 | 19:967207de919d | 366 | else{ |
| lilac0112_1 | 19:967207de919d | 367 | sys.DribbleFlag=0; |
| lilac0112_1 | 25:a7460e23e02e | 368 | cmps_set.HoldDeg=0; |
| lilac0112_1 | 19:967207de919d | 369 | } |
| lilac0112_1 | 19:967207de919d | 370 | |
| lilac0112_1 | 24:34ef6379b0df | 371 | ////Kick |
| lilac0112_1 | 25:a7460e23e02e | 372 | /*if((data.ball==1)&&(data.irNotice==IR_CLOSER)&&((data.irPosition==10)||(data.irPosition==11)||(data.irPosition==12))){ |
| lilac0112_1 | 24:34ef6379b0df | 373 | DriveTurn(); |
| lilac0112_1 | 25:a7460e23e02e | 374 | }*/ |
| lilac0112_1 | 25:a7460e23e02e | 375 | /*if((data.ball==1)&&(data.irNotice==IR_CLOSER)&&((data.irPosition==10)||(data.irPosition==11)||(data.irPosition==12))){ |
| lilac0112_1 | 25:a7460e23e02e | 376 | DriveTurn(); |
| lilac0112_1 | 25:a7460e23e02e | 377 | DriveSolenoid(); |
| lilac0112_1 | 25:a7460e23e02e | 378 | }*/ |
| lilac0112_1 | 30:5998ba42237e | 379 | if( |
| lilac0112_1 | 30:5998ba42237e | 380 | /*(sys.BallHoldFlag==1)&& |
| lilac0112_1 | 30:5998ba42237e | 381 | (data.ball==1)&& |
| lilac0112_1 | 30:5998ba42237e | 382 | (data.irNotice==IR_CLOSER)&& |
| lilac0112_1 | 30:5998ba42237e | 383 | ((data.irPosition==10)||(data.irPosition==11)||(data.irPosition==12))&& |
| lilac0112_1 | 30:5998ba42237e | 384 | (data.ping[B_PING]>100)&& |
| lilac0112_1 | 30:5998ba42237e | 385 | ( |
| lilac0112_1 | 30:5998ba42237e | 386 | ((data.ping[L_PING]<60)&&(data.ping[R_PING]>60))|| |
| lilac0112_1 | 30:5998ba42237e | 387 | ((data.ping[L_PING]>60)&&(data.ping[R_PING]<60))|| |
| lilac0112_1 | 30:5998ba42237e | 388 | (data.lnRawOrderLog1[0]==A_SPOT)|| |
| lilac0112_1 | 30:5998ba42237e | 389 | (data.lnRawOrder[0]==A_SPOT)|| |
| lilac0112_1 | 30:5998ba42237e | 390 | (data.lnRawOrderLog1[0]==B_SPOT)|| |
| lilac0112_1 | 30:5998ba42237e | 391 | (data.lnRawOrder[0]==B_SPOT) |
| lilac0112_1 | 30:5998ba42237e | 392 | )&& |
| lilac0112_1 | 30:5998ba42237e | 393 | (data.lnRaw==0)*/ |
| lilac0112_1 | 30:5998ba42237e | 394 | (sys.DriBlind==0)&& |
| lilac0112_1 | 30:5998ba42237e | 395 | (data.ping[R_PING]<30)&& |
| lilac0112_1 | 30:5998ba42237e | 396 | (data.ping[L_PING]<30) |
| lilac0112_1 | 30:5998ba42237e | 397 | ){ |
| lilac0112_1 | 32:367b16d69a32 | 398 | //DriveTurn(); |
| lilac0112_1 | 32:367b16d69a32 | 399 | //DriveSolenoid(); |
| lilac0112_1 | 30:5998ba42237e | 400 | } |
| lilac0112_1 | 19:967207de919d | 401 | |
| lilac0112_1 | 24:34ef6379b0df | 402 | //Irの細かい補正値の処理.基本的にLineの補正値を演算する処理が始まる前にIrのモーター出力値補正をすべて終わらせる. |
| lilac0112_1 | 25:a7460e23e02e | 403 | //if(sys.IrBlind==1) ir_pow=0; |
| lilac0112_1 | 25:a7460e23e02e | 404 | if(sys.IrBlind==1) ir_pow_x=ir_pow_y=0; |
| lilac0112_1 | 28:f246a5fbf6a5 | 405 | if((data.ping[R_PING]<data.ping[L_PING])&&(data.irPosition==17)&&(data.irNotice==IR_CLOSER)){ |
| lilac0112_1 | 18:3a42a931c95a | 406 | ir_x_turn = -ir_x_turn; |
| lilac0112_1 | 18:3a42a931c95a | 407 | ir_y_turn = -ir_y_turn; |
| lilac0112_1 | 18:3a42a931c95a | 408 | } |
| lilac0112_1 | 25:a7460e23e02e | 409 | |
| lilac0112_1 | 26:6ca88eeaa2b4 | 410 | if((sys.BackHomeFlag==1)&&(sys.HomeBlind==0)){ |
| lilac0112_1 | 25:a7460e23e02e | 411 | ir_pow_x = ir_pow_y = 25; |
| lilac0112_1 | 25:a7460e23e02e | 412 | //x |
| lilac0112_1 | 25:a7460e23e02e | 413 | if((abs(data.ping[L_PING]-data.ping[R_PING])>20)&&(sys.HomeStayFlag[X_PING]==0)){ |
| lilac0112_1 | 25:a7460e23e02e | 414 | if(data.ping[L_PING]>data.ping[R_PING]){ |
| lilac0112_1 | 25:a7460e23e02e | 415 | ir_x = -1; |
| lilac0112_1 | 25:a7460e23e02e | 416 | } |
| lilac0112_1 | 25:a7460e23e02e | 417 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 418 | ir_x = 1; |
| lilac0112_1 | 25:a7460e23e02e | 419 | } |
| lilac0112_1 | 25:a7460e23e02e | 420 | if((data.ping[L_PING]<WhiteToWallPlus[X_PING])&&(data.ping[R_PING]<WhiteToWallPlus[X_PING])){ |
| lilac0112_1 | 25:a7460e23e02e | 421 | ir_x = 0; |
| lilac0112_1 | 25:a7460e23e02e | 422 | } |
| lilac0112_1 | 25:a7460e23e02e | 423 | } |
| lilac0112_1 | 25:a7460e23e02e | 424 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 425 | ir_x = 0; |
| lilac0112_1 | 25:a7460e23e02e | 426 | //sys.HomeStayFlag[X_PING]=1; |
| lilac0112_1 | 25:a7460e23e02e | 427 | } |
| lilac0112_1 | 25:a7460e23e02e | 428 | //y |
| lilac0112_1 | 31:745a775cfc20 | 429 | if((data.ping[B_PING]>60)&&(1)&&(sys.HomeStayFlag[Y_PING]==0)){ |
| lilac0112_1 | 25:a7460e23e02e | 430 | ir_y = -1; |
| lilac0112_1 | 25:a7460e23e02e | 431 | } |
| lilac0112_1 | 25:a7460e23e02e | 432 | else{ |
| lilac0112_1 | 32:367b16d69a32 | 433 | if((data.ping[B_PING]>40)&&(data.ping[R_PING]>55)&&(data.ping[L_PING]>55)){ |
| lilac0112_1 | 32:367b16d69a32 | 434 | ir_y = -1; |
| lilac0112_1 | 32:367b16d69a32 | 435 | ir_pow_y = 15; |
| lilac0112_1 | 32:367b16d69a32 | 436 | } |
| lilac0112_1 | 32:367b16d69a32 | 437 | else{ |
| lilac0112_1 | 32:367b16d69a32 | 438 | ir_y = 0; |
| lilac0112_1 | 32:367b16d69a32 | 439 | } |
| lilac0112_1 | 25:a7460e23e02e | 440 | //sys.HomeStayFlag[Y_PING]=1; |
| lilac0112_1 | 25:a7460e23e02e | 441 | } |
| lilac0112_1 | 25:a7460e23e02e | 442 | } |
| lilac0112_1 | 25:a7460e23e02e | 443 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 444 | ir_x = (ir_x_dir + ir_x_turn); |
| lilac0112_1 | 25:a7460e23e02e | 445 | ir_y = (ir_y_dir + ir_y_turn); |
| lilac0112_1 | 25:a7460e23e02e | 446 | } |
| lilac0112_1 | 31:745a775cfc20 | 447 | if((sys.HomeBlind==0)&&(data.irNotice==IR_FAR)){ |
| lilac0112_1 | 31:745a775cfc20 | 448 | ir_pow_x = ir_pow_y = 25; |
| lilac0112_1 | 31:745a775cfc20 | 449 | if(ir_y>0) ir_y=0; |
| lilac0112_1 | 31:745a775cfc20 | 450 | if((data.ping[B_PING]>60)&&(1)){ |
| lilac0112_1 | 31:745a775cfc20 | 451 | ir_y = -1; |
| lilac0112_1 | 32:367b16d69a32 | 452 | ir_pow_y = 15; |
| lilac0112_1 | 31:745a775cfc20 | 453 | } |
| lilac0112_1 | 31:745a775cfc20 | 454 | } |
| lilac0112_1 | 30:5998ba42237e | 455 | if( |
| lilac0112_1 | 30:5998ba42237e | 456 | (sys.DefenceFlag==1)&& |
| lilac0112_1 | 30:5998ba42237e | 457 | (ir_y>0)&& |
| lilac0112_1 | 31:745a775cfc20 | 458 | (data.ping[B_PING]>60)&& |
| lilac0112_1 | 30:5998ba42237e | 459 | (data.ping[B_PING]<225)&& |
| lilac0112_1 | 30:5998ba42237e | 460 | (sys.BackHomeFlag==0) |
| lilac0112_1 | 30:5998ba42237e | 461 | ){ |
| lilac0112_1 | 30:5998ba42237e | 462 | ir_pow_y=0; |
| lilac0112_1 | 30:5998ba42237e | 463 | } |
| lilac0112_1 | 33:aa115c30892e | 464 | ///dribbler |
| lilac0112_1 | 33:aa115c30892e | 465 | if((sys.DriBlind==0)&&(data.irNotice==IR_CLOSER)&&(/*sys.BallHoldFlag==1*/data.ball==1)&&((data.irPosition==10)||(data.irPosition==11)||(data.irPosition==12))){ |
| lilac0112_1 | 33:aa115c30892e | 466 | |
| lilac0112_1 | 33:aa115c30892e | 467 | |
| lilac0112_1 | 33:aa115c30892e | 468 | if((1/*data.ping[L_PING]<60*/)&&(data.ping[R_PING]>90)){ |
| lilac0112_1 | 33:aa115c30892e | 469 | ir_x = 1; |
| lilac0112_1 | 33:aa115c30892e | 470 | } |
| lilac0112_1 | 33:aa115c30892e | 471 | else{ |
| lilac0112_1 | 33:aa115c30892e | 472 | if(data.lnRawOrderLog1[0]==B_SPOT){ |
| lilac0112_1 | 33:aa115c30892e | 473 | ir_x = 1; |
| lilac0112_1 | 33:aa115c30892e | 474 | } |
| lilac0112_1 | 33:aa115c30892e | 475 | } |
| lilac0112_1 | 33:aa115c30892e | 476 | if((1/*data.ping[R_PING]<60*/)&&(data.ping[L_PING]>90)){ |
| lilac0112_1 | 33:aa115c30892e | 477 | ir_x = -1; |
| lilac0112_1 | 33:aa115c30892e | 478 | } |
| lilac0112_1 | 33:aa115c30892e | 479 | else{ |
| lilac0112_1 | 33:aa115c30892e | 480 | if(data.lnRawOrderLog1[0]==A_SPOT){ |
| lilac0112_1 | 33:aa115c30892e | 481 | ir_x = -1; |
| lilac0112_1 | 33:aa115c30892e | 482 | } |
| lilac0112_1 | 33:aa115c30892e | 483 | } |
| lilac0112_1 | 33:aa115c30892e | 484 | if((data.ping[F_PING]<50)&&(data.ping[B_PING]>100)){ |
| lilac0112_1 | 33:aa115c30892e | 485 | ir_y = -1; |
| lilac0112_1 | 33:aa115c30892e | 486 | } |
| lilac0112_1 | 33:aa115c30892e | 487 | if( |
| lilac0112_1 | 33:aa115c30892e | 488 | ((data.ping[L_PING]<55)&&(data.ping[R_PING]<55))|| |
| lilac0112_1 | 33:aa115c30892e | 489 | ((data.ping[L_PING]>55)&&(data.ping[R_PING]>55)) |
| lilac0112_1 | 33:aa115c30892e | 490 | ){ |
| lilac0112_1 | 33:aa115c30892e | 491 | DriveSolenoid(); |
| lilac0112_1 | 33:aa115c30892e | 492 | } |
| lilac0112_1 | 33:aa115c30892e | 493 | |
| lilac0112_1 | 33:aa115c30892e | 494 | } |
| lilac0112_1 | 24:34ef6379b0df | 495 | ////Lineセンサーの値を評価しモーターの出力補正値を演算 |
| lilac0112_1 | 14:b510adcb6065 | 496 | if(sys.LineBlind==1){ |
| lilac0112_1 | 14:b510adcb6065 | 497 | |
| lilac0112_1 | 14:b510adcb6065 | 498 | LineSlowPower[X_LINE] = 1.0; |
| lilac0112_1 | 14:b510adcb6065 | 499 | LineSlowPower[Y_LINE] = 1.0; |
| lilac0112_1 | 14:b510adcb6065 | 500 | |
| lilac0112_1 | 14:b510adcb6065 | 501 | LineReturnPower[X_LINE] = 0.0; |
| lilac0112_1 | 14:b510adcb6065 | 502 | LineReturnPower[Y_LINE] = 0.0; |
| lilac0112_1 | 14:b510adcb6065 | 503 | |
| lilac0112_1 | 14:b510adcb6065 | 504 | data.lnStop[X_LINE] = 1; |
| lilac0112_1 | 14:b510adcb6065 | 505 | data.lnStop[Y_LINE] = 1; |
| lilac0112_1 | 14:b510adcb6065 | 506 | |
| lilac0112_1 | 15:17502a27a60b | 507 | data.FieldSpot = LINE_INSIDE; |
| lilac0112_1 | 14:b510adcb6065 | 508 | } |
| lilac0112_1 | 14:b510adcb6065 | 509 | else{ |
| lilac0112_1 | 28:f246a5fbf6a5 | 510 | /* |
| lilac0112_1 | 18:3a42a931c95a | 511 | LineJudgeReset(ir_x, ir_y, &LineSlowPower[X_LINE], &LineSlowPower[Y_LINE]); |
| lilac0112_1 | 18:3a42a931c95a | 512 | LineJudgeSlow(ir_x, ir_y, &LineSlowPower[X_LINE], &LineSlowPower[Y_LINE]); |
| lilac0112_1 | 28:f246a5fbf6a5 | 513 | LineJudgeReturn(ir_x*LineSlowPower[X_LINE], ir_y*LineSlowPower[Y_LINE], &LineReturnPower[X_LINE], &LineReturnPower[Y_LINE]); |
| lilac0112_1 | 28:f246a5fbf6a5 | 514 | */ |
| lilac0112_1 | 28:f246a5fbf6a5 | 515 | LineJudgeReset2(ir_x, ir_y, &LineSlowPower[X_LINE], &LineSlowPower[Y_LINE]); |
| lilac0112_1 | 28:f246a5fbf6a5 | 516 | LineJudgeSlow2(ir_x, ir_y, &LineSlowPower[X_LINE], &LineSlowPower[Y_LINE], &ir_pow_x, &ir_pow_y); |
| lilac0112_1 | 27:825c6835e3db | 517 | LineJudgeReturn2(ir_x*LineSlowPower[X_LINE], ir_y*LineSlowPower[Y_LINE], &LineReturnPower[X_LINE], &LineReturnPower[Y_LINE]); |
| lilac0112_1 | 14:b510adcb6065 | 518 | } |
| lilac0112_1 | 24:34ef6379b0df | 519 | ////LEDデバッグ |
| lilac0112_1 | 19:967207de919d | 520 | //if(data.FieldSpot==LINE_OUTSIDE) LED = 0x9; |
| lilac0112_1 | 19:967207de919d | 521 | //if(data.FieldSpot==LINE_INSIDE) LED = 0x6; |
| lilac0112_1 | 27:825c6835e3db | 522 | //LED = ((data.lnRawMemory[0]!=0)<<2) | ((data.lnRawMemory[1]!=0)<<1) | ((data.lnRawMemory[2]!=0)<<0); |
| lilac0112_1 | 30:5998ba42237e | 523 | //LED = ((data.lnRawOrder[0]!=LINE_EMPTY)<<2) | ((data.lnRawOrder[1]!=LINE_EMPTY)<<1) | ((data.lnRawOrder[2]!=LINE_EMPTY)<<0); |
| lilac0112_1 | 27:825c6835e3db | 524 | //LED = ((data.lnOrder[0]!=LINE_EMPTY)<<2) | ((data.lnOrder[1]!=LINE_EMPTY)<<1) | ((data.lnOrder[2]!=LINE_EMPTY)<<0); |
| lilac0112_1 | 19:967207de919d | 525 | |
| lilac0112_1 | 25:a7460e23e02e | 526 | //LED = sys.BallHoldFlag*15; |
| lilac0112_1 | 33:aa115c30892e | 527 | if(sys.BallHoldFlag==0) LED=15; |
| lilac0112_1 | 32:367b16d69a32 | 528 | else LED=10; |
| lilac0112_1 | 19:967207de919d | 529 | |
| lilac0112_1 | 33:aa115c30892e | 530 | //if(data.ball==1) LED=15; |
| lilac0112_1 | 33:aa115c30892e | 531 | //else LED=10; |
| lilac0112_1 | 33:aa115c30892e | 532 | |
| lilac0112_1 | 32:367b16d69a32 | 533 | //if(data.lnRepeat>=1) LED=15; |
| lilac0112_1 | 32:367b16d69a32 | 534 | //else LED=10; |
| lilac0112_1 | 30:5998ba42237e | 535 | |
| lilac0112_1 | 21:378470320524 | 536 | //LED = 0xFF*(data.ping[B_PING]<30); |
| lilac0112_1 | 14:b510adcb6065 | 537 | |
| lilac0112_1 | 16:4fadb7a87497 | 538 | //LED = ((data.lnOrder[0]!=LINE_EMPTY)<<2) | ((data.lnOrder[1]!=LINE_EMPTY)<<1) | ((data.lnOrder[2]!=LINE_EMPTY)<<0); |
| lilac0112_1 | 14:b510adcb6065 | 539 | |
| lilac0112_1 | 14:b510adcb6065 | 540 | //else LED = 0xA; |
| lilac0112_1 | 14:b510adcb6065 | 541 | //LED = LineHold; |
| lilac0112_1 | 14:b510adcb6065 | 542 | |
| lilac0112_1 | 24:34ef6379b0df | 543 | |
| lilac0112_1 | 24:34ef6379b0df | 544 | ////最終的なモーターの出力を演算 |
| lilac0112_1 | 32:367b16d69a32 | 545 | vx = (ir_pow_x*ir_x)*data.lnStop[X_LINE]*(data.lnStay[X_LINE])*LineSlowPower[X_LINE]*(sys.TurnStopFlag==0) + LineReturnPower[X_LINE]; |
| lilac0112_1 | 32:367b16d69a32 | 546 | vy = (ir_pow_y*ir_y)*data.lnStop[Y_LINE]*(data.lnStay[Y_LINE])*LineSlowPower[Y_LINE]*(sys.TurnStopFlag==0) + LineReturnPower[Y_LINE]; |
| lilac0112_1 | 10:6df631c39f9b | 547 | vs = cmps_set.OutputPID; |
| lilac0112_1 | 10:6df631c39f9b | 548 | move( |
| lilac0112_1 | 10:6df631c39f9b | 549 | vx, |
| lilac0112_1 | 10:6df631c39f9b | 550 | vy, |
| lilac0112_1 | 10:6df631c39f9b | 551 | vs |
| lilac0112_1 | 10:6df631c39f9b | 552 | ); |
| lilac0112_1 | 24:34ef6379b0df | 553 | //モーターに信号を出力 |
| lilac0112_1 | 10:6df631c39f9b | 554 | if(sys.MotorFlag==1){tx_motor();sys.MotorFlag=0;} |
| lilac0112_1 | 24:34ef6379b0df | 555 | |
| lilac0112_1 | 0:ea35c18c85fc | 556 | if(sys.stopflag==1){ |
| lilac0112_1 | 24:34ef6379b0df | 557 | //コマンドモードに戻る際の処理 |
| lilac0112_1 | 0:ea35c18c85fc | 558 | } |
| lilac0112_1 | 0:ea35c18c85fc | 559 | return; |
| lilac0112_1 | 0:ea35c18c85fc | 560 | } |
| lilac0112_1 | 30:5998ba42237e | 561 | |
| lilac0112_1 | 0:ea35c18c85fc | 562 | void modeAttack5(void){ |
| lilac0112_1 | 30:5998ba42237e | 563 | ////初期値を決める等 |
| lilac0112_1 | 30:5998ba42237e | 564 | if(sys.KickOffFlag==1){ |
| lilac0112_1 | 30:5998ba42237e | 565 | |
| lilac0112_1 | 30:5998ba42237e | 566 | ///Blindシリーズ.1を代入であらゆるセンサーなどの値を反映させないようにする. |
| lilac0112_1 | 30:5998ba42237e | 567 | sys.IrBlind=0; |
| lilac0112_1 | 30:5998ba42237e | 568 | sys.LineBlind=0; |
| lilac0112_1 | 30:5998ba42237e | 569 | sys.PingBlind=0; |
| lilac0112_1 | 30:5998ba42237e | 570 | |
| lilac0112_1 | 30:5998ba42237e | 571 | sys.HomeBlind=1; |
| lilac0112_1 | 30:5998ba42237e | 572 | sys.DriBlind=1; |
| lilac0112_1 | 30:5998ba42237e | 573 | //defence |
| lilac0112_1 | 30:5998ba42237e | 574 | sys.DefenceFlag=1; |
| lilac0112_1 | 30:5998ba42237e | 575 | |
| lilac0112_1 | 30:5998ba42237e | 576 | |
| lilac0112_1 | 30:5998ba42237e | 577 | //初期値設定の終了 |
| lilac0112_1 | 30:5998ba42237e | 578 | //sys.KickOffFlag=0; |
| lilac0112_1 | 0:ea35c18c85fc | 579 | } |
| lilac0112_1 | 30:5998ba42237e | 580 | modeAttack4(); |
| lilac0112_1 | 0:ea35c18c85fc | 581 | } |