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/LineProcess.cpp@25:a7460e23e02e, 2016-03-17 (annotated)
- Committer:
- lilac0112_1
- Date:
- Thu Mar 17 13:00:24 2016 +0000
- Revision:
- 25:a7460e23e02e
- Child:
- 27:825c6835e3db
BackHomeOnly
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lilac0112_1 | 25:a7460e23e02e | 1 | #include "mbed.h" |
| lilac0112_1 | 25:a7460e23e02e | 2 | #include "extern.h" |
| lilac0112_1 | 25:a7460e23e02e | 3 | |
| lilac0112_1 | 25:a7460e23e02e | 4 | void LineJudgeSlow(double pow_x, double pow_y, double *x, double *y){ |
| lilac0112_1 | 25:a7460e23e02e | 5 | uint8_t LineState; |
| lilac0112_1 | 25:a7460e23e02e | 6 | uint8_t LineSum; |
| lilac0112_1 | 25:a7460e23e02e | 7 | |
| lilac0112_1 | 25:a7460e23e02e | 8 | //line |
| lilac0112_1 | 25:a7460e23e02e | 9 | LineState = 0; |
| lilac0112_1 | 25:a7460e23e02e | 10 | |
| lilac0112_1 | 25:a7460e23e02e | 11 | LineSum = ((data.lnHold>>2)&0x1)+((data.lnHold>>1)&0x1)+((data.lnHold>>0)&0x1); |
| lilac0112_1 | 25:a7460e23e02e | 12 | if((LineSum==3)||(data.FieldSpot==LINE_OUTSIDE)){ |
| lilac0112_1 | 25:a7460e23e02e | 13 | LineState = 3; |
| lilac0112_1 | 25:a7460e23e02e | 14 | } |
| lilac0112_1 | 25:a7460e23e02e | 15 | else if(LineSum==2){ |
| lilac0112_1 | 25:a7460e23e02e | 16 | LineState = 2; |
| lilac0112_1 | 25:a7460e23e02e | 17 | } |
| lilac0112_1 | 25:a7460e23e02e | 18 | else if(LineSum==1){ |
| lilac0112_1 | 25:a7460e23e02e | 19 | LineState = 1; |
| lilac0112_1 | 25:a7460e23e02e | 20 | } |
| lilac0112_1 | 25:a7460e23e02e | 21 | else if(LineSum==0){ |
| lilac0112_1 | 25:a7460e23e02e | 22 | LineState = 0; |
| lilac0112_1 | 25:a7460e23e02e | 23 | } |
| lilac0112_1 | 25:a7460e23e02e | 24 | |
| lilac0112_1 | 25:a7460e23e02e | 25 | |
| lilac0112_1 | 25:a7460e23e02e | 26 | if(pow_x>=0){ |
| lilac0112_1 | 25:a7460e23e02e | 27 | if(data.ping[R_PING]<WhiteToWall[X_PING]) (*x)=LineDecline[LineState]; |
| lilac0112_1 | 25:a7460e23e02e | 28 | else *x=1; |
| lilac0112_1 | 25:a7460e23e02e | 29 | } |
| lilac0112_1 | 25:a7460e23e02e | 30 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 31 | if(data.ping[L_PING]<WhiteToWall[X_PING]) (*x)=LineDecline[LineState]; |
| lilac0112_1 | 25:a7460e23e02e | 32 | else *x=1; |
| lilac0112_1 | 25:a7460e23e02e | 33 | } |
| lilac0112_1 | 25:a7460e23e02e | 34 | |
| lilac0112_1 | 25:a7460e23e02e | 35 | if(pow_y>=0){ |
| lilac0112_1 | 25:a7460e23e02e | 36 | if(data.ping[F_PING]<WhiteToWall[Y_PING]) (*y)=LineDecline[LineState]; |
| lilac0112_1 | 25:a7460e23e02e | 37 | else *y=1; |
| lilac0112_1 | 25:a7460e23e02e | 38 | } |
| lilac0112_1 | 25:a7460e23e02e | 39 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 40 | if(data.ping[B_PING]<WhiteToWall[Y_PING]) (*y)=LineDecline[LineState]; |
| lilac0112_1 | 25:a7460e23e02e | 41 | else *y=1; |
| lilac0112_1 | 25:a7460e23e02e | 42 | } |
| lilac0112_1 | 25:a7460e23e02e | 43 | } |
| lilac0112_1 | 25:a7460e23e02e | 44 | void LineJudgeReturn(double pow_x, double pow_y, double *x, double *y){ |
| lilac0112_1 | 25:a7460e23e02e | 45 | const int8_t static LineReturn[5] = {0, 0, 0, 0, 20}; |
| lilac0112_1 | 25:a7460e23e02e | 46 | uint8_t LinePingState[4]; |
| lilac0112_1 | 25:a7460e23e02e | 47 | //◎ボールを追う力とラインから離れる力の向きが違うならばラインから離れる力が優先される. |
| lilac0112_1 | 25:a7460e23e02e | 48 | //◎ボールを追う力とラインから離れる力の向きが同じならばボールを追う力が優先される. |
| lilac0112_1 | 25:a7460e23e02e | 49 | //◎ラインセンサ全てが場外になるまではボールを追う力は作用しない.ボールを追う力は場内に出るまで作用する. |
| lilac0112_1 | 25:a7460e23e02e | 50 | //×ラインのほぼ場外では常時ラインから離れる力が優先される. |
| lilac0112_1 | 25:a7460e23e02e | 51 | //※場外判定を行うには再び場内に戻る必要がある. |
| lilac0112_1 | 25:a7460e23e02e | 52 | |
| lilac0112_1 | 25:a7460e23e02e | 53 | if(data.FieldSpot==LINE_OUTSIDE){ |
| lilac0112_1 | 25:a7460e23e02e | 54 | |
| lilac0112_1 | 25:a7460e23e02e | 55 | LinePingState[L_PING]=(data.ping[L_PING]<WhiteToWall[X_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 56 | LinePingState[R_PING]=(data.ping[R_PING]<WhiteToWall[X_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 57 | LinePingState[F_PING]=(data.ping[F_PING]<WhiteToWall[Y_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 58 | LinePingState[B_PING]=(data.ping[B_PING]<WhiteToWall[Y_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 59 | |
| lilac0112_1 | 25:a7460e23e02e | 60 | //line間際の復帰力以外の力を作用させるか否か |
| lilac0112_1 | 25:a7460e23e02e | 61 | data.lnStop[X_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 62 | data.lnStop[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 63 | |
| lilac0112_1 | 25:a7460e23e02e | 64 | data.ReturnDir[X_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 65 | data.ReturnDir[Y_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 66 | |
| lilac0112_1 | 25:a7460e23e02e | 67 | //x |
| lilac0112_1 | 25:a7460e23e02e | 68 | if(data.ReturnDir[X_LINE]==L_LINE){ |
| lilac0112_1 | 25:a7460e23e02e | 69 | if(pow_x<0){ |
| lilac0112_1 | 25:a7460e23e02e | 70 | *x = 0; |
| lilac0112_1 | 25:a7460e23e02e | 71 | data.lnStop[X_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 72 | } |
| lilac0112_1 | 25:a7460e23e02e | 73 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 74 | *x = -LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 75 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 76 | } |
| lilac0112_1 | 25:a7460e23e02e | 77 | } |
| lilac0112_1 | 25:a7460e23e02e | 78 | else if(data.ReturnDir[X_LINE]==R_LINE){ |
| lilac0112_1 | 25:a7460e23e02e | 79 | if(pow_x>0){ |
| lilac0112_1 | 25:a7460e23e02e | 80 | *x = 0; |
| lilac0112_1 | 25:a7460e23e02e | 81 | data.lnStop[X_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 82 | } |
| lilac0112_1 | 25:a7460e23e02e | 83 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 84 | *x = LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 85 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 86 | } |
| lilac0112_1 | 25:a7460e23e02e | 87 | } |
| lilac0112_1 | 25:a7460e23e02e | 88 | else if(data.ReturnDir[X_LINE]==LINE_EMPTY){ |
| lilac0112_1 | 25:a7460e23e02e | 89 | if((LinePingState[L_PING]==0)&&(LinePingState[R_PING]==0)){ |
| lilac0112_1 | 25:a7460e23e02e | 90 | /*if(pow_x>0){ |
| lilac0112_1 | 25:a7460e23e02e | 91 | *x = -pow_x*(1-0.75); |
| lilac0112_1 | 25:a7460e23e02e | 92 | } |
| lilac0112_1 | 25:a7460e23e02e | 93 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 94 | *x = pow_x*(1-0.75); |
| lilac0112_1 | 25:a7460e23e02e | 95 | }*/ |
| lilac0112_1 | 25:a7460e23e02e | 96 | data.lnStop[X_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 97 | } |
| lilac0112_1 | 25:a7460e23e02e | 98 | if((LinePingState[L_PING]==0)&&(LinePingState[R_PING]==1)){ |
| lilac0112_1 | 25:a7460e23e02e | 99 | |
| lilac0112_1 | 25:a7460e23e02e | 100 | data.ReturnDir[X_LINE]=L_LINE; |
| lilac0112_1 | 25:a7460e23e02e | 101 | |
| lilac0112_1 | 25:a7460e23e02e | 102 | /*if(pow_x<0){ |
| lilac0112_1 | 25:a7460e23e02e | 103 | *x = 0; |
| lilac0112_1 | 25:a7460e23e02e | 104 | data.lnStop[X_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 105 | } |
| lilac0112_1 | 25:a7460e23e02e | 106 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 107 | *x = -LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 108 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 109 | }*/ |
| lilac0112_1 | 25:a7460e23e02e | 110 | *x = -LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 111 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 112 | } |
| lilac0112_1 | 25:a7460e23e02e | 113 | if((LinePingState[L_PING]==1)&&(LinePingState[R_PING]==0)){ |
| lilac0112_1 | 25:a7460e23e02e | 114 | |
| lilac0112_1 | 25:a7460e23e02e | 115 | data.ReturnDir[X_LINE]=R_LINE; |
| lilac0112_1 | 25:a7460e23e02e | 116 | |
| lilac0112_1 | 25:a7460e23e02e | 117 | /*if(pow_x>0){ |
| lilac0112_1 | 25:a7460e23e02e | 118 | *x = 0; |
| lilac0112_1 | 25:a7460e23e02e | 119 | data.lnStop[X_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 120 | } |
| lilac0112_1 | 25:a7460e23e02e | 121 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 122 | *x = LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 123 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 124 | }*/ |
| lilac0112_1 | 25:a7460e23e02e | 125 | *x = LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 126 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 127 | } |
| lilac0112_1 | 25:a7460e23e02e | 128 | if((LinePingState[L_PING]==1)&&(LinePingState[R_PING]==1)){ |
| lilac0112_1 | 25:a7460e23e02e | 129 | |
| lilac0112_1 | 25:a7460e23e02e | 130 | if( |
| lilac0112_1 | 25:a7460e23e02e | 131 | (data.lnOrder[0]==A_SPOT)&&(data.lnOrder[1]==C_SPOT)&&(data.lnOrder[2]==B_SPOT) |
| lilac0112_1 | 25:a7460e23e02e | 132 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 133 | *x = -LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 134 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 135 | } |
| lilac0112_1 | 25:a7460e23e02e | 136 | else if( |
| lilac0112_1 | 25:a7460e23e02e | 137 | (data.lnOrder[0]==B_SPOT)&&(data.lnOrder[1]==C_SPOT)&&(data.lnOrder[2]==A_SPOT) |
| lilac0112_1 | 25:a7460e23e02e | 138 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 139 | *x = LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 140 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 141 | } |
| lilac0112_1 | 25:a7460e23e02e | 142 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 143 | *x = 0; |
| lilac0112_1 | 25:a7460e23e02e | 144 | data.lnStop[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 145 | } |
| lilac0112_1 | 25:a7460e23e02e | 146 | } |
| lilac0112_1 | 25:a7460e23e02e | 147 | } |
| lilac0112_1 | 25:a7460e23e02e | 148 | //y |
| lilac0112_1 | 25:a7460e23e02e | 149 | if(data.ReturnDir[Y_LINE]==F_LINE){ |
| lilac0112_1 | 25:a7460e23e02e | 150 | if(pow_y>0){ |
| lilac0112_1 | 25:a7460e23e02e | 151 | *y = 0; |
| lilac0112_1 | 25:a7460e23e02e | 152 | data.lnStop[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 153 | } |
| lilac0112_1 | 25:a7460e23e02e | 154 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 155 | *y = LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 156 | data.lnStop[Y_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 157 | } |
| lilac0112_1 | 25:a7460e23e02e | 158 | } |
| lilac0112_1 | 25:a7460e23e02e | 159 | else if(data.ReturnDir[Y_LINE]==B_LINE){ |
| lilac0112_1 | 25:a7460e23e02e | 160 | if(pow_y<0){ |
| lilac0112_1 | 25:a7460e23e02e | 161 | *y = 0; |
| lilac0112_1 | 25:a7460e23e02e | 162 | data.lnStop[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 163 | } |
| lilac0112_1 | 25:a7460e23e02e | 164 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 165 | *y = -LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 166 | data.lnStop[Y_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 167 | } |
| lilac0112_1 | 25:a7460e23e02e | 168 | } |
| lilac0112_1 | 25:a7460e23e02e | 169 | else if(data.ReturnDir[Y_LINE]==LINE_EMPTY){ |
| lilac0112_1 | 25:a7460e23e02e | 170 | if((LinePingState[B_PING]==0)&&(LinePingState[F_PING]==0)){ |
| lilac0112_1 | 25:a7460e23e02e | 171 | /*if(pow_y>0){ |
| lilac0112_1 | 25:a7460e23e02e | 172 | *y = -pow_y*(1-0.75); |
| lilac0112_1 | 25:a7460e23e02e | 173 | } |
| lilac0112_1 | 25:a7460e23e02e | 174 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 175 | *y = pow_y*(1-0.75); |
| lilac0112_1 | 25:a7460e23e02e | 176 | }*/ |
| lilac0112_1 | 25:a7460e23e02e | 177 | data.lnStop[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 178 | } |
| lilac0112_1 | 25:a7460e23e02e | 179 | if((LinePingState[B_PING]==0)&&(LinePingState[F_PING]==1)){ |
| lilac0112_1 | 25:a7460e23e02e | 180 | |
| lilac0112_1 | 25:a7460e23e02e | 181 | data.ReturnDir[Y_LINE]=B_LINE; |
| lilac0112_1 | 25:a7460e23e02e | 182 | |
| lilac0112_1 | 25:a7460e23e02e | 183 | if(pow_y<0){ |
| lilac0112_1 | 25:a7460e23e02e | 184 | *y = 0; |
| lilac0112_1 | 25:a7460e23e02e | 185 | data.lnStop[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 186 | } |
| lilac0112_1 | 25:a7460e23e02e | 187 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 188 | *y = -LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 189 | data.lnStop[Y_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 190 | } |
| lilac0112_1 | 25:a7460e23e02e | 191 | } |
| lilac0112_1 | 25:a7460e23e02e | 192 | if((LinePingState[B_PING]==1)&&(LinePingState[F_PING]==0)){ |
| lilac0112_1 | 25:a7460e23e02e | 193 | |
| lilac0112_1 | 25:a7460e23e02e | 194 | data.ReturnDir[Y_LINE]=F_LINE; |
| lilac0112_1 | 25:a7460e23e02e | 195 | |
| lilac0112_1 | 25:a7460e23e02e | 196 | if(pow_y>0){ |
| lilac0112_1 | 25:a7460e23e02e | 197 | *y = 0; |
| lilac0112_1 | 25:a7460e23e02e | 198 | data.lnStop[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 199 | } |
| lilac0112_1 | 25:a7460e23e02e | 200 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 201 | *y = LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 202 | data.lnStop[Y_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 203 | } |
| lilac0112_1 | 25:a7460e23e02e | 204 | } |
| lilac0112_1 | 25:a7460e23e02e | 205 | if((LinePingState[B_PING]==1)&&(LinePingState[F_PING]==1)){ |
| lilac0112_1 | 25:a7460e23e02e | 206 | if( |
| lilac0112_1 | 25:a7460e23e02e | 207 | (data.lnOrder[0]==C_SPOT)&&(data.lnOrder[1]==A_SPOT)&&(data.lnOrder[2]==B_SPOT)|| |
| lilac0112_1 | 25:a7460e23e02e | 208 | (data.lnOrder[0]==C_SPOT)&&(data.lnOrder[1]==B_SPOT)&&(data.lnOrder[2]==A_SPOT) |
| lilac0112_1 | 25:a7460e23e02e | 209 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 210 | *y = LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 211 | data.lnStop[Y_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 212 | } |
| lilac0112_1 | 25:a7460e23e02e | 213 | else if( |
| lilac0112_1 | 25:a7460e23e02e | 214 | (data.lnOrder[0]==A_SPOT)&&(data.lnOrder[1]==B_SPOT)&&(data.lnOrder[2]==C_SPOT)|| |
| lilac0112_1 | 25:a7460e23e02e | 215 | (data.lnOrder[0]==B_SPOT)&&(data.lnOrder[1]==A_SPOT)&&(data.lnOrder[2]==C_SPOT) |
| lilac0112_1 | 25:a7460e23e02e | 216 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 217 | *y = -LineReturn[4]; |
| lilac0112_1 | 25:a7460e23e02e | 218 | data.lnStop[Y_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 219 | } |
| lilac0112_1 | 25:a7460e23e02e | 220 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 221 | *y = 0; |
| lilac0112_1 | 25:a7460e23e02e | 222 | data.lnStop[Y_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 223 | } |
| lilac0112_1 | 25:a7460e23e02e | 224 | } |
| lilac0112_1 | 25:a7460e23e02e | 225 | } |
| lilac0112_1 | 25:a7460e23e02e | 226 | //none |
| lilac0112_1 | 25:a7460e23e02e | 227 | if((LinePingState[L_PING]==1)&&(LinePingState[R_PING]==1)&&(LinePingState[F_PING]==1)&&(LinePingState[B_PING]==1)){ |
| lilac0112_1 | 25:a7460e23e02e | 228 | //turn! |
| lilac0112_1 | 25:a7460e23e02e | 229 | } |
| lilac0112_1 | 25:a7460e23e02e | 230 | |
| lilac0112_1 | 25:a7460e23e02e | 231 | } |
| lilac0112_1 | 25:a7460e23e02e | 232 | else{//data.FieldSpot==LINE_INSIDE |
| lilac0112_1 | 25:a7460e23e02e | 233 | |
| lilac0112_1 | 25:a7460e23e02e | 234 | data.ReturnDir[X_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 235 | data.ReturnDir[Y_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 236 | |
| lilac0112_1 | 25:a7460e23e02e | 237 | *x = 0; |
| lilac0112_1 | 25:a7460e23e02e | 238 | *y = 0; |
| lilac0112_1 | 25:a7460e23e02e | 239 | |
| lilac0112_1 | 25:a7460e23e02e | 240 | //line間際の復帰力以外の力を作用させるか否か |
| lilac0112_1 | 25:a7460e23e02e | 241 | data.lnStop[X_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 242 | data.lnStop[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 243 | } |
| lilac0112_1 | 25:a7460e23e02e | 244 | } |
| lilac0112_1 | 25:a7460e23e02e | 245 | void LineJudgeReset(double pow_x, double pow_y, double *x, double *y){ |
| lilac0112_1 | 25:a7460e23e02e | 246 | //static uint8_t NewLineCorner[4]={LINE_EMPTY, LINE_EMPTY, LINE_EMPTY, LINE_EMPTY}; |
| lilac0112_1 | 25:a7460e23e02e | 247 | //static uint8_t LastLineCorner[4]={LINE_EMPTY, LINE_EMPTY, LINE_EMPTY, LINE_EMPTY}; |
| lilac0112_1 | 25:a7460e23e02e | 248 | static uint8_t NewLineCorner[4]={LINE_EMPTY, LINE_EMPTY, LINE_EMPTY, LINE_EMPTY}; |
| lilac0112_1 | 25:a7460e23e02e | 249 | static uint8_t LastLineCorner[4]={LINE_EMPTY, LINE_EMPTY, LINE_EMPTY, LINE_EMPTY}; |
| lilac0112_1 | 25:a7460e23e02e | 250 | |
| lilac0112_1 | 25:a7460e23e02e | 251 | if((/*data.lnRaw==0*/1)&&(data.lnHold==7)){ |
| lilac0112_1 | 25:a7460e23e02e | 252 | if(data.FieldSpot==LINE_INSIDE){ |
| lilac0112_1 | 25:a7460e23e02e | 253 | |
| lilac0112_1 | 25:a7460e23e02e | 254 | data.lnCorner[L_LINE] = (data.ping[L_PING]<OutToWall[X_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 255 | data.lnCorner[R_LINE] = (data.ping[R_PING]<OutToWall[X_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 256 | data.lnCorner[F_LINE] = (data.ping[F_PING]<OutToWall[Y_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 257 | data.lnCorner[B_LINE] = (data.ping[B_PING]<OutToWall[Y_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 258 | if( |
| lilac0112_1 | 25:a7460e23e02e | 259 | (data.lnCorner[L_LINE])|| |
| lilac0112_1 | 25:a7460e23e02e | 260 | (data.lnCorner[R_LINE])|| |
| lilac0112_1 | 25:a7460e23e02e | 261 | (data.lnCorner[F_LINE])|| |
| lilac0112_1 | 25:a7460e23e02e | 262 | (data.lnCorner[B_LINE]) |
| lilac0112_1 | 25:a7460e23e02e | 263 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 264 | |
| lilac0112_1 | 25:a7460e23e02e | 265 | data.NonWall[L_LINE] = (data.ping[L_PING]>WhiteToWall[X_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 266 | data.NonWall[R_LINE] = (data.ping[R_PING]>WhiteToWall[X_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 267 | data.NonWall[F_LINE] = (data.ping[F_PING]>WhiteToWall[Y_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 268 | data.NonWall[B_LINE] = (data.ping[B_PING]>WhiteToWall[Y_PING]); |
| lilac0112_1 | 25:a7460e23e02e | 269 | |
| lilac0112_1 | 25:a7460e23e02e | 270 | |
| lilac0112_1 | 25:a7460e23e02e | 271 | |
| lilac0112_1 | 25:a7460e23e02e | 272 | ///* |
| lilac0112_1 | 25:a7460e23e02e | 273 | LastLineCorner[L_LINE]=NewLineCorner[L_LINE]; |
| lilac0112_1 | 25:a7460e23e02e | 274 | LastLineCorner[R_LINE]=NewLineCorner[R_LINE]; |
| lilac0112_1 | 25:a7460e23e02e | 275 | LastLineCorner[F_LINE]=NewLineCorner[F_LINE]; |
| lilac0112_1 | 25:a7460e23e02e | 276 | LastLineCorner[B_LINE]=NewLineCorner[B_LINE]; |
| lilac0112_1 | 25:a7460e23e02e | 277 | |
| lilac0112_1 | 25:a7460e23e02e | 278 | NewLineCorner[L_LINE]=data.lnCorner[L_LINE]; |
| lilac0112_1 | 25:a7460e23e02e | 279 | NewLineCorner[R_LINE]=data.lnCorner[R_LINE]; |
| lilac0112_1 | 25:a7460e23e02e | 280 | NewLineCorner[F_LINE]=data.lnCorner[F_LINE]; |
| lilac0112_1 | 25:a7460e23e02e | 281 | NewLineCorner[B_LINE]=data.lnCorner[B_LINE]; |
| lilac0112_1 | 25:a7460e23e02e | 282 | |
| lilac0112_1 | 25:a7460e23e02e | 283 | if( |
| lilac0112_1 | 25:a7460e23e02e | 284 | (LastLineCorner[L_LINE]==NewLineCorner[L_LINE])&& |
| lilac0112_1 | 25:a7460e23e02e | 285 | (LastLineCorner[R_LINE]==NewLineCorner[R_LINE])&& |
| lilac0112_1 | 25:a7460e23e02e | 286 | (LastLineCorner[F_LINE]==NewLineCorner[F_LINE])&& |
| lilac0112_1 | 25:a7460e23e02e | 287 | (LastLineCorner[B_LINE]==NewLineCorner[B_LINE]) |
| lilac0112_1 | 25:a7460e23e02e | 288 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 289 | data.lnRepeat++; |
| lilac0112_1 | 25:a7460e23e02e | 290 | } |
| lilac0112_1 | 25:a7460e23e02e | 291 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 292 | data.lnRepeat=0; |
| lilac0112_1 | 25:a7460e23e02e | 293 | } |
| lilac0112_1 | 25:a7460e23e02e | 294 | //*/ |
| lilac0112_1 | 25:a7460e23e02e | 295 | |
| lilac0112_1 | 25:a7460e23e02e | 296 | data.FieldSpot = LINE_OUTSIDE; |
| lilac0112_1 | 25:a7460e23e02e | 297 | LineLiberate(); |
| lilac0112_1 | 25:a7460e23e02e | 298 | } |
| lilac0112_1 | 25:a7460e23e02e | 299 | } |
| lilac0112_1 | 25:a7460e23e02e | 300 | else if(data.FieldSpot==LINE_OUTSIDE){ |
| lilac0112_1 | 25:a7460e23e02e | 301 | if(data.lnRaw==0){ |
| lilac0112_1 | 25:a7460e23e02e | 302 | data.FieldSpot = LINE_INSIDE; |
| lilac0112_1 | 25:a7460e23e02e | 303 | data.NonWall[L_LINE] = data.NonWall[R_LINE] = data.NonWall[F_LINE] = data.NonWall[B_LINE] = 0; |
| lilac0112_1 | 25:a7460e23e02e | 304 | LineLiberate(); |
| lilac0112_1 | 25:a7460e23e02e | 305 | LineRankClear(); |
| lilac0112_1 | 25:a7460e23e02e | 306 | } |
| lilac0112_1 | 25:a7460e23e02e | 307 | } |
| lilac0112_1 | 25:a7460e23e02e | 308 | } |
| lilac0112_1 | 25:a7460e23e02e | 309 | if(data.FieldSpot == LINE_OUTSIDE){ |
| lilac0112_1 | 25:a7460e23e02e | 310 | if( |
| lilac0112_1 | 25:a7460e23e02e | 311 | ( |
| lilac0112_1 | 25:a7460e23e02e | 312 | (data.ping[L_PING]>=WhiteToWall[X_PING])|| |
| lilac0112_1 | 25:a7460e23e02e | 313 | (data.NonWall[L_LINE]==1)|| |
| lilac0112_1 | 25:a7460e23e02e | 314 | ((data.lnOrder[0]==A_SPOT)&&(data.lnOrder[1]==C_SPOT)) |
| lilac0112_1 | 25:a7460e23e02e | 315 | //(data.lnOrder[0]==A_SPOT) |
| lilac0112_1 | 25:a7460e23e02e | 316 | )&& |
| lilac0112_1 | 25:a7460e23e02e | 317 | ( |
| lilac0112_1 | 25:a7460e23e02e | 318 | (data.ping[R_PING]>=WhiteToWall[X_PING])|| |
| lilac0112_1 | 25:a7460e23e02e | 319 | (data.NonWall[R_LINE]==1)|| |
| lilac0112_1 | 25:a7460e23e02e | 320 | ((data.lnOrder[0]==B_SPOT)&&(data.lnOrder[1]==C_SPOT)) |
| lilac0112_1 | 25:a7460e23e02e | 321 | //(data.lnOrder[0]==B_SPOT) |
| lilac0112_1 | 25:a7460e23e02e | 322 | )&& |
| lilac0112_1 | 25:a7460e23e02e | 323 | ( |
| lilac0112_1 | 25:a7460e23e02e | 324 | (data.ping[F_PING]>=WhiteToWall[Y_PING])|| |
| lilac0112_1 | 25:a7460e23e02e | 325 | (data.NonWall[F_LINE]==1)|| |
| lilac0112_1 | 25:a7460e23e02e | 326 | ((data.lnOrder[0]==C_SPOT)&&(data.lnOrder[1]==A_SPOT))|| |
| lilac0112_1 | 25:a7460e23e02e | 327 | ((data.lnOrder[0]==C_SPOT)&&(data.lnOrder[1]==B_SPOT)) |
| lilac0112_1 | 25:a7460e23e02e | 328 | )&& |
| lilac0112_1 | 25:a7460e23e02e | 329 | ((data.ping[B_PING]>=WhiteToWall[Y_PING])|| |
| lilac0112_1 | 25:a7460e23e02e | 330 | (data.NonWall[B_LINE]==1)|| |
| lilac0112_1 | 25:a7460e23e02e | 331 | ((data.lnOrder[0]==A_SPOT)&&(data.lnOrder[1]==B_SPOT))|| |
| lilac0112_1 | 25:a7460e23e02e | 332 | ((data.lnOrder[0]==B_SPOT)&&(data.lnOrder[1]==A_SPOT)) |
| lilac0112_1 | 25:a7460e23e02e | 333 | ) |
| lilac0112_1 | 25:a7460e23e02e | 334 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 335 | data.FieldSpot = LINE_INSIDE; |
| lilac0112_1 | 25:a7460e23e02e | 336 | data.NonWall[L_LINE] = data.NonWall[R_LINE] = data.NonWall[F_LINE] = data.NonWall[B_LINE] = 0; |
| lilac0112_1 | 25:a7460e23e02e | 337 | LineLiberate(); |
| lilac0112_1 | 25:a7460e23e02e | 338 | LineRankClear(); |
| lilac0112_1 | 25:a7460e23e02e | 339 | } |
| lilac0112_1 | 25:a7460e23e02e | 340 | } |
| lilac0112_1 | 25:a7460e23e02e | 341 | if((data.FieldSpot == LINE_INSIDE)&&(0<data.lnHold)&&(data.lnHold<7)&&(data.lnRaw==0)){ |
| lilac0112_1 | 25:a7460e23e02e | 342 | if( |
| lilac0112_1 | 25:a7460e23e02e | 343 | ( |
| lilac0112_1 | 25:a7460e23e02e | 344 | ( |
| lilac0112_1 | 25:a7460e23e02e | 345 | (data.ping[L_PING]>=WhiteToWall[X_PING])|| |
| lilac0112_1 | 25:a7460e23e02e | 346 | ((data.lnOrder[0]==A_SPOT)&&(data.lnOrder[1]==C_SPOT)) |
| lilac0112_1 | 25:a7460e23e02e | 347 | //(data.lnOrder[0]==A_SPOT) |
| lilac0112_1 | 25:a7460e23e02e | 348 | )&& |
| lilac0112_1 | 25:a7460e23e02e | 349 | ( |
| lilac0112_1 | 25:a7460e23e02e | 350 | (data.ping[R_PING]>=WhiteToWall[X_PING])|| |
| lilac0112_1 | 25:a7460e23e02e | 351 | ((data.lnOrder[0]==B_SPOT)&&(data.lnOrder[1]==C_SPOT)) |
| lilac0112_1 | 25:a7460e23e02e | 352 | //(data.lnOrder[0]==B_SPOT) |
| lilac0112_1 | 25:a7460e23e02e | 353 | )&& |
| lilac0112_1 | 25:a7460e23e02e | 354 | ( |
| lilac0112_1 | 25:a7460e23e02e | 355 | (data.ping[F_PING]>=WhiteToWall[Y_PING])|| |
| lilac0112_1 | 25:a7460e23e02e | 356 | ((data.lnOrder[0]==C_SPOT)&&(data.lnOrder[1]==A_SPOT))|| |
| lilac0112_1 | 25:a7460e23e02e | 357 | ((data.lnOrder[0]==C_SPOT)&&(data.lnOrder[1]==B_SPOT)) |
| lilac0112_1 | 25:a7460e23e02e | 358 | )&& |
| lilac0112_1 | 25:a7460e23e02e | 359 | ( |
| lilac0112_1 | 25:a7460e23e02e | 360 | (data.ping[B_PING]>=WhiteToWall[Y_PING])|| |
| lilac0112_1 | 25:a7460e23e02e | 361 | ((data.lnOrder[0]==A_SPOT)&&(data.lnOrder[1]==B_SPOT))|| |
| lilac0112_1 | 25:a7460e23e02e | 362 | ((data.lnOrder[0]==B_SPOT)&&(data.lnOrder[1]==A_SPOT)) |
| lilac0112_1 | 25:a7460e23e02e | 363 | ) |
| lilac0112_1 | 25:a7460e23e02e | 364 | ) |
| lilac0112_1 | 25:a7460e23e02e | 365 | || |
| lilac0112_1 | 25:a7460e23e02e | 366 | ( |
| lilac0112_1 | 25:a7460e23e02e | 367 | (data.ping[L_PING]>=GoalEdgeToWall[X_PING])&& |
| lilac0112_1 | 25:a7460e23e02e | 368 | (data.ping[R_PING]>=GoalEdgeToWall[X_PING]) |
| lilac0112_1 | 25:a7460e23e02e | 369 | ) |
| lilac0112_1 | 25:a7460e23e02e | 370 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 371 | data.NonWall[L_LINE] = data.NonWall[R_LINE] = data.NonWall[F_LINE] = data.NonWall[B_LINE] = 0; |
| lilac0112_1 | 25:a7460e23e02e | 372 | LineLiberate(); |
| lilac0112_1 | 25:a7460e23e02e | 373 | } |
| lilac0112_1 | 25:a7460e23e02e | 374 | } |
| lilac0112_1 | 25:a7460e23e02e | 375 | ///* |
| lilac0112_1 | 25:a7460e23e02e | 376 | if( |
| lilac0112_1 | 25:a7460e23e02e | 377 | (data.irNotice==IR_NONE)|| |
| lilac0112_1 | 25:a7460e23e02e | 378 | (data.irNotice==IR_FAR)|| |
| lilac0112_1 | 25:a7460e23e02e | 379 | ( |
| lilac0112_1 | 25:a7460e23e02e | 380 | (data.ping[L_PING]>=GoalEdgeToWall[X_PING])&& |
| lilac0112_1 | 25:a7460e23e02e | 381 | (data.ping[R_PING]>=GoalEdgeToWall[X_PING]) |
| lilac0112_1 | 25:a7460e23e02e | 382 | ) |
| lilac0112_1 | 25:a7460e23e02e | 383 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 384 | data.lnRepeat = 0; |
| lilac0112_1 | 25:a7460e23e02e | 385 | |
| lilac0112_1 | 25:a7460e23e02e | 386 | NewLineCorner[L_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 387 | NewLineCorner[R_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 388 | NewLineCorner[F_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 389 | NewLineCorner[B_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 390 | |
| lilac0112_1 | 25:a7460e23e02e | 391 | LastLineCorner[L_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 392 | LastLineCorner[R_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 393 | LastLineCorner[F_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 394 | LastLineCorner[B_LINE]=LINE_EMPTY; |
| lilac0112_1 | 25:a7460e23e02e | 395 | } |
| lilac0112_1 | 25:a7460e23e02e | 396 | //data.lnRepeat=0; |
| lilac0112_1 | 25:a7460e23e02e | 397 | if((data.lnRepeat>0)&&(data.FieldSpot == LINE_INSIDE)){ |
| lilac0112_1 | 25:a7460e23e02e | 398 | //x |
| lilac0112_1 | 25:a7460e23e02e | 399 | if( |
| lilac0112_1 | 25:a7460e23e02e | 400 | ((pow_x>=0)&&(NewLineCorner[R_LINE]))|| |
| lilac0112_1 | 25:a7460e23e02e | 401 | ((pow_x<0)&&(NewLineCorner[L_LINE])) |
| lilac0112_1 | 25:a7460e23e02e | 402 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 403 | data.lnStay[X_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 404 | } |
| lilac0112_1 | 25:a7460e23e02e | 405 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 406 | data.lnStay[X_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 407 | } |
| lilac0112_1 | 25:a7460e23e02e | 408 | //y |
| lilac0112_1 | 25:a7460e23e02e | 409 | if( |
| lilac0112_1 | 25:a7460e23e02e | 410 | ((pow_y>=0)&&(NewLineCorner[F_LINE]))|| |
| lilac0112_1 | 25:a7460e23e02e | 411 | ((pow_y<0)&&(NewLineCorner[B_LINE])) |
| lilac0112_1 | 25:a7460e23e02e | 412 | ){ |
| lilac0112_1 | 25:a7460e23e02e | 413 | data.lnStay[Y_LINE]=0; |
| lilac0112_1 | 25:a7460e23e02e | 414 | } |
| lilac0112_1 | 25:a7460e23e02e | 415 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 416 | data.lnStay[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 417 | } |
| lilac0112_1 | 25:a7460e23e02e | 418 | } |
| lilac0112_1 | 25:a7460e23e02e | 419 | else{ |
| lilac0112_1 | 25:a7460e23e02e | 420 | data.lnStay[X_LINE]=data.lnStay[Y_LINE]=1; |
| lilac0112_1 | 25:a7460e23e02e | 421 | } |
| lilac0112_1 | 25:a7460e23e02e | 422 | //*/ |
| lilac0112_1 | 25:a7460e23e02e | 423 | |
| lilac0112_1 | 25:a7460e23e02e | 424 | } |