sequences des strats
Strategie.cpp@1:785b37686185, 2019-05-24 (annotated)
- Committer:
- JimmyAREM
- Date:
- Fri May 24 21:45:02 2019 +0000
- Revision:
- 1:785b37686185
- Parent:
- 0:a89fe490343e
- Child:
- 2:e0402d1e9ed5
strat
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JimmyAREM | 0:a89fe490343e | 1 | #include "Strategie.h" |
JimmyAREM | 0:a89fe490343e | 2 | |
JimmyAREM | 0:a89fe490343e | 3 | char bufferScore[3]={'0','0','0'}; |
JimmyAREM | 1:785b37686185 | 4 | |
JimmyAREM | 0:a89fe490343e | 5 | bool typeMovement = DEPLACEMENT_AVANT; |
JimmyAREM | 1:785b37686185 | 6 | bool typeEvitement = ARRET; |
JimmyAREM | 0:a89fe490343e | 7 | |
JimmyAREM | 0:a89fe490343e | 8 | extern int distanceUltrasonGauche; |
JimmyAREM | 0:a89fe490343e | 9 | extern int distanceUltrasonDroit; |
JimmyAREM | 0:a89fe490343e | 10 | extern int distanceUltrasonArriere; |
JimmyAREM | 0:a89fe490343e | 11 | |
JimmyAREM | 0:a89fe490343e | 12 | extern int distanceTOF1; |
JimmyAREM | 0:a89fe490343e | 13 | extern int distanceTOF2; |
JimmyAREM | 0:a89fe490343e | 14 | extern int distanceTOF3; |
JimmyAREM | 0:a89fe490343e | 15 | extern int distanceTOF4; |
JimmyAREM | 0:a89fe490343e | 16 | extern int distanceTOF5; |
JimmyAREM | 0:a89fe490343e | 17 | |
JimmyAREM | 0:a89fe490343e | 18 | |
JimmyAREM | 0:a89fe490343e | 19 | extern bool stopCapteurs; |
JimmyAREM | 0:a89fe490343e | 20 | |
JimmyAREM | 0:a89fe490343e | 21 | |
JimmyAREM | 1:785b37686185 | 22 | Timeout tempsArretMvt; |
JimmyAREM | 1:785b37686185 | 23 | |
JimmyAREM | 1:785b37686185 | 24 | |
JimmyAREM | 1:785b37686185 | 25 | |
JimmyAREM | 0:a89fe490343e | 26 | void updateAndWriteScore(char n1, char n2, char n3) |
JimmyAREM | 0:a89fe490343e | 27 | { |
JimmyAREM | 0:a89fe490343e | 28 | bufferScore[0] = n1; |
JimmyAREM | 0:a89fe490343e | 29 | bufferScore[1] = n2; |
JimmyAREM | 0:a89fe490343e | 30 | bufferScore[2] = n3; |
JimmyAREM | 0:a89fe490343e | 31 | write(bufferScore); |
JimmyAREM | 0:a89fe490343e | 32 | } |
JimmyAREM | 0:a89fe490343e | 33 | |
JimmyAREM | 0:a89fe490343e | 34 | void LectureI2CCarteCapteur(deplacement robot) |
JimmyAREM | 0:a89fe490343e | 35 | { |
JimmyAREM | 0:a89fe490343e | 36 | traitementBufferCapteurs(); |
JimmyAREM | 0:a89fe490343e | 37 | if(AnalyseDistance(distanceUltrasonGauche, distanceUltrasonDroit, distanceUltrasonArriere, typeMovement) == ROBOT) |
JimmyAREM | 0:a89fe490343e | 38 | { |
JimmyAREM | 0:a89fe490343e | 39 | if( ((distanceUltrasonGauche <= 300) || (distanceUltrasonDroit <= 300)) && (typeMovement == DEPLACEMENT_AVANT) ) |
JimmyAREM | 0:a89fe490343e | 40 | { |
JimmyAREM | 0:a89fe490343e | 41 | stopCapteurs = true; |
JimmyAREM | 0:a89fe490343e | 42 | } |
JimmyAREM | 0:a89fe490343e | 43 | else if ( (distanceUltrasonArriere <= 300) && (typeMovement == DEPLACEMENT_ARRIERE) ) |
JimmyAREM | 0:a89fe490343e | 44 | { |
JimmyAREM | 0:a89fe490343e | 45 | stopCapteurs = true; |
JimmyAREM | 0:a89fe490343e | 46 | } |
JimmyAREM | 0:a89fe490343e | 47 | else |
JimmyAREM | 0:a89fe490343e | 48 | { |
JimmyAREM | 0:a89fe490343e | 49 | stopCapteurs = false; |
JimmyAREM | 0:a89fe490343e | 50 | } |
JimmyAREM | 0:a89fe490343e | 51 | } |
JimmyAREM | 0:a89fe490343e | 52 | else |
JimmyAREM | 0:a89fe490343e | 53 | { |
JimmyAREM | 0:a89fe490343e | 54 | stopCapteurs = false; |
JimmyAREM | 0:a89fe490343e | 55 | } |
JimmyAREM | 0:a89fe490343e | 56 | } |
JimmyAREM | 0:a89fe490343e | 57 | |
JimmyAREM | 1:785b37686185 | 58 | void arretSystem() |
JimmyAREM | 1:785b37686185 | 59 | { |
JimmyAREM | 1:785b37686185 | 60 | Pompe pompe(PIN_POMPE); |
JimmyAREM | 1:785b37686185 | 61 | Demarreur demarreur(PIN_DEMARREUR); |
JimmyAREM | 1:785b37686185 | 62 | Bras brasGauche(PIN_SERVO_BRAS_GAUCHE, GAUCHE); |
JimmyAREM | 1:785b37686185 | 63 | Bras brasDroit(PIN_SERVO_BRAS_DROIT, DROIT); |
JimmyAREM | 1:785b37686185 | 64 | BrasPousser brasPousserGauche(PIN_SERVO_PALETS_GAUCHE, GAUCHE); |
JimmyAREM | 1:785b37686185 | 65 | BrasPousser brasPousserDroit(PIN_SERVO_PALETS_DROIT,DROIT); |
JimmyAREM | 1:785b37686185 | 66 | deplacement robot; |
JimmyAREM | 1:785b37686185 | 67 | |
JimmyAREM | 1:785b37686185 | 68 | robot.initialisation(); |
JimmyAREM | 1:785b37686185 | 69 | robot.arreterRobot(); |
JimmyAREM | 1:785b37686185 | 70 | pompe.desactiver(); |
JimmyAREM | 1:785b37686185 | 71 | } |
JimmyAREM | 1:785b37686185 | 72 | |
JimmyAREM | 1:785b37686185 | 73 | void strategieHomologationViolet(deplacement robot, Pompe pompe, Demarreur demarreur, Bras brasGauche, Bras brasDroit, BrasPousser brasPousserGauche, BrasPousser brasPousserDroit) |
JimmyAREM | 1:785b37686185 | 74 | { |
JimmyAREM | 1:785b37686185 | 75 | write(bufferScore); |
JimmyAREM | 1:785b37686185 | 76 | Timer tempsMatch; // timer en seconde |
JimmyAREM | 1:785b37686185 | 77 | int etapeMatch = 0; |
JimmyAREM | 1:785b37686185 | 78 | while(demarreur.getState() == false) |
JimmyAREM | 1:785b37686185 | 79 | { |
JimmyAREM | 1:785b37686185 | 80 | //on attend |
JimmyAREM | 1:785b37686185 | 81 | //pc.printf("On attend le depart du Robot Thanos\n\r"); |
JimmyAREM | 1:785b37686185 | 82 | } |
JimmyAREM | 1:785b37686185 | 83 | tempsArretMvt.attach(&arretSystem, TEMPSMATCH); |
JimmyAREM | 1:785b37686185 | 84 | lancerTimerEcran(); |
JimmyAREM | 1:785b37686185 | 85 | tempsMatch.start(); |
JimmyAREM | 1:785b37686185 | 86 | typeEvitement = ARRET; |
JimmyAREM | 1:785b37686185 | 87 | while(tempsMatch <= TEMPSMATCH) |
JimmyAREM | 1:785b37686185 | 88 | { |
JimmyAREM | 1:785b37686185 | 89 | switch (etapeMatch) { |
JimmyAREM | 1:785b37686185 | 90 | |
JimmyAREM | 1:785b37686185 | 91 | case 0 : /* On tourne pour aller vers le terrain adverse et on avance jusqu'au milieu du terrain */ |
JimmyAREM | 1:785b37686185 | 92 | { |
JimmyAREM | 1:785b37686185 | 93 | typeMovement = DEPLACEMENT_AVANT; |
JimmyAREM | 1:785b37686185 | 94 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 95 | robot.ligne_droite_basique(127500); |
JimmyAREM | 1:785b37686185 | 96 | etapeMatch++; |
JimmyAREM | 1:785b37686185 | 97 | |
JimmyAREM | 1:785b37686185 | 98 | break; |
JimmyAREM | 1:785b37686185 | 99 | } |
JimmyAREM | 1:785b37686185 | 100 | case 1 : /* On se met en position pour pousser les palets */ |
JimmyAREM | 1:785b37686185 | 101 | { |
JimmyAREM | 1:785b37686185 | 102 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 103 | robot.ligne_droite_basique(60000); |
JimmyAREM | 1:785b37686185 | 104 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 105 | brasPousserDroit.activerBras(); |
JimmyAREM | 1:785b37686185 | 106 | brasPousserGauche.activerBras(); |
JimmyAREM | 1:785b37686185 | 107 | etapeMatch++; |
JimmyAREM | 1:785b37686185 | 108 | |
JimmyAREM | 1:785b37686185 | 109 | break; |
JimmyAREM | 1:785b37686185 | 110 | } |
JimmyAREM | 1:785b37686185 | 111 | case 2 : /* On pousse la zone de chaos dans les cases */ |
JimmyAREM | 1:785b37686185 | 112 | { |
JimmyAREM | 1:785b37686185 | 113 | robot.ligne_droite_basique(110000); |
JimmyAREM | 1:785b37686185 | 114 | updateAndWriteScore('0', '1', '0'); |
JimmyAREM | 1:785b37686185 | 115 | etapeMatch++; |
JimmyAREM | 1:785b37686185 | 116 | |
JimmyAREM | 1:785b37686185 | 117 | break; |
JimmyAREM | 1:785b37686185 | 118 | } |
JimmyAREM | 1:785b37686185 | 119 | case 3 : /* On se met en position pour faire des rectangles */ |
JimmyAREM | 1:785b37686185 | 120 | { |
JimmyAREM | 1:785b37686185 | 121 | typeMovement = DEPLACEMENT_ARRIERE; |
JimmyAREM | 1:785b37686185 | 122 | robot.marche_arriere(-10000); |
JimmyAREM | 1:785b37686185 | 123 | brasPousserDroit.desactiverBras(); |
JimmyAREM | 1:785b37686185 | 124 | brasPousserGauche.desactiverBras(); |
JimmyAREM | 1:785b37686185 | 125 | etapeMatch++; |
JimmyAREM | 1:785b37686185 | 126 | |
JimmyAREM | 1:785b37686185 | 127 | break; |
JimmyAREM | 1:785b37686185 | 128 | } |
JimmyAREM | 1:785b37686185 | 129 | case 4 : /* On fait un rectangle arriere */ |
JimmyAREM | 1:785b37686185 | 130 | { |
JimmyAREM | 1:785b37686185 | 131 | |
JimmyAREM | 1:785b37686185 | 132 | robot.marche_arriere(-50000); |
JimmyAREM | 1:785b37686185 | 133 | robot.rotation_rel(-90); |
JimmyAREM | 1:785b37686185 | 134 | robot.marche_arriere(-50000); |
JimmyAREM | 1:785b37686185 | 135 | robot.rotation_rel(-90); |
JimmyAREM | 1:785b37686185 | 136 | robot.marche_arriere(-50000); |
JimmyAREM | 1:785b37686185 | 137 | robot.rotation_rel(-90); |
JimmyAREM | 1:785b37686185 | 138 | robot.marche_arriere(-50000); |
JimmyAREM | 1:785b37686185 | 139 | //robot.rotation_rel(180); |
JimmyAREM | 1:785b37686185 | 140 | etapeMatch++; |
JimmyAREM | 1:785b37686185 | 141 | |
JimmyAREM | 1:785b37686185 | 142 | break; |
JimmyAREM | 1:785b37686185 | 143 | } |
JimmyAREM | 1:785b37686185 | 144 | case 5 : /* On pousse le palet vert ou le vert et les deux bleus dans la balance en passant par la pente */ |
JimmyAREM | 1:785b37686185 | 145 | { |
JimmyAREM | 1:785b37686185 | 146 | typeMovement = DEPLACEMENT_AVANT; |
JimmyAREM | 1:785b37686185 | 147 | robot.ligne_droite_basique(50000); |
JimmyAREM | 1:785b37686185 | 148 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 149 | robot.ligne_droite_basique(50000); |
JimmyAREM | 1:785b37686185 | 150 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 151 | robot.ligne_droite_basique(50000); |
JimmyAREM | 1:785b37686185 | 152 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 153 | robot.ligne_droite_basique(50000); |
JimmyAREM | 1:785b37686185 | 154 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 155 | etapeMatch++; |
JimmyAREM | 1:785b37686185 | 156 | |
JimmyAREM | 1:785b37686185 | 157 | break; |
JimmyAREM | 1:785b37686185 | 158 | } |
JimmyAREM | 1:785b37686185 | 159 | |
JimmyAREM | 1:785b37686185 | 160 | default: |
JimmyAREM | 1:785b37686185 | 161 | { |
JimmyAREM | 1:785b37686185 | 162 | robot.vitesse_nulle_D(0); |
JimmyAREM | 1:785b37686185 | 163 | robot.vitesse_nulle_G(0); |
JimmyAREM | 1:785b37686185 | 164 | motors_stop(); |
JimmyAREM | 1:785b37686185 | 165 | } |
JimmyAREM | 1:785b37686185 | 166 | } |
JimmyAREM | 1:785b37686185 | 167 | } |
JimmyAREM | 1:785b37686185 | 168 | |
JimmyAREM | 1:785b37686185 | 169 | //Arrêter les moteurs |
JimmyAREM | 1:785b37686185 | 170 | robot.vitesse_nulle_D(0); |
JimmyAREM | 1:785b37686185 | 171 | robot.vitesse_nulle_G(0); |
JimmyAREM | 1:785b37686185 | 172 | motors_stop(); |
JimmyAREM | 1:785b37686185 | 173 | while(1); |
JimmyAREM | 1:785b37686185 | 174 | } |
JimmyAREM | 1:785b37686185 | 175 | |
JimmyAREM | 0:a89fe490343e | 176 | void strategieClassiqueViolet(deplacement robot, Pompe pompe, Demarreur demarreur, Bras brasGauche, Bras brasDroit, BrasPousser brasPousserGauche, BrasPousser brasPousserDroit) |
JimmyAREM | 0:a89fe490343e | 177 | { |
JimmyAREM | 0:a89fe490343e | 178 | write(bufferScore); |
JimmyAREM | 0:a89fe490343e | 179 | Timer tempsMatch; // timer en seconde |
JimmyAREM | 0:a89fe490343e | 180 | int etapeMatch = 0; |
JimmyAREM | 0:a89fe490343e | 181 | while(demarreur.getState() == false) |
JimmyAREM | 0:a89fe490343e | 182 | { |
JimmyAREM | 0:a89fe490343e | 183 | //on attend |
JimmyAREM | 0:a89fe490343e | 184 | //pc.printf("On attend le depart du Robot Thanos\n\r"); |
JimmyAREM | 0:a89fe490343e | 185 | } |
JimmyAREM | 1:785b37686185 | 186 | tempsArretMvt.attach(&arretSystem, TEMPSMATCH); |
JimmyAREM | 0:a89fe490343e | 187 | lancerTimerEcran(); |
JimmyAREM | 0:a89fe490343e | 188 | tempsMatch.start(); |
JimmyAREM | 0:a89fe490343e | 189 | while(tempsMatch <= TEMPSMATCH) |
JimmyAREM | 0:a89fe490343e | 190 | { |
JimmyAREM | 0:a89fe490343e | 191 | switch (etapeMatch) { |
JimmyAREM | 0:a89fe490343e | 192 | |
JimmyAREM | 0:a89fe490343e | 193 | case 0 : /* On active l'expérience */ |
JimmyAREM | 0:a89fe490343e | 194 | { |
JimmyAREM | 0:a89fe490343e | 195 | typeMovement = DEPLACEMENT_AVANT; |
JimmyAREM | 1:785b37686185 | 196 | robot.ligne_droite_basique(25000); |
JimmyAREM | 0:a89fe490343e | 197 | robot.poussette(300); |
JimmyAREM | 0:a89fe490343e | 198 | updateAndWriteScore('0', '4', '0'); |
JimmyAREM | 0:a89fe490343e | 199 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 200 | |
JimmyAREM | 0:a89fe490343e | 201 | break; |
JimmyAREM | 0:a89fe490343e | 202 | } |
JimmyAREM | 0:a89fe490343e | 203 | case 1 : /* On pousse le palet bleu de la pente de l'accélérateur */ |
JimmyAREM | 0:a89fe490343e | 204 | { |
JimmyAREM | 0:a89fe490343e | 205 | typeMovement = DEPLACEMENT_ARRIERE; |
JimmyAREM | 0:a89fe490343e | 206 | robot.marche_arriere(-11200); |
JimmyAREM | 0:a89fe490343e | 207 | typeMovement = DEPLACEMENT_AVANT; |
JimmyAREM | 0:a89fe490343e | 208 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 209 | robot.ligne_droite_basique(130000); |
JimmyAREM | 0:a89fe490343e | 210 | brasDroit.activerBras(); |
JimmyAREM | 1:785b37686185 | 211 | robot.ligne_droite_basique(16000); |
JimmyAREM | 0:a89fe490343e | 212 | brasDroit.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 213 | updateAndWriteScore('0', '5', '0'); |
JimmyAREM | 0:a89fe490343e | 214 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 215 | |
JimmyAREM | 0:a89fe490343e | 216 | break; |
JimmyAREM | 0:a89fe490343e | 217 | } |
JimmyAREM | 0:a89fe490343e | 218 | case 2 : /* On récupère le goldenium */ |
JimmyAREM | 0:a89fe490343e | 219 | { |
JimmyAREM | 1:785b37686185 | 220 | robot.ligne_droite_basique(54500); |
JimmyAREM | 0:a89fe490343e | 221 | robot.rotation_rel(-90); |
JimmyAREM | 0:a89fe490343e | 222 | pompe.activer(); |
JimmyAREM | 0:a89fe490343e | 223 | robot.poussette(1000); |
JimmyAREM | 0:a89fe490343e | 224 | typeMovement = DEPLACEMENT_ARRIERE; |
JimmyAREM | 0:a89fe490343e | 225 | robot.marche_arriere(-10000); |
JimmyAREM | 0:a89fe490343e | 226 | typeMovement = DEPLACEMENT_AVANT; |
JimmyAREM | 0:a89fe490343e | 227 | updateAndWriteScore('0', '8', '0'); |
JimmyAREM | 0:a89fe490343e | 228 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 229 | |
JimmyAREM | 0:a89fe490343e | 230 | break; |
JimmyAREM | 0:a89fe490343e | 231 | } |
JimmyAREM | 0:a89fe490343e | 232 | case 3 : /* On met le goldenium dans la balance */ |
JimmyAREM | 0:a89fe490343e | 233 | { |
JimmyAREM | 0:a89fe490343e | 234 | |
JimmyAREM | 0:a89fe490343e | 235 | robot.rotation_rel(-90); |
JimmyAREM | 1:785b37686185 | 236 | robot.ligne_droite_basique(97000); |
JimmyAREM | 0:a89fe490343e | 237 | robot.rotation_rel(-90); |
JimmyAREM | 1:785b37686185 | 238 | robot.ligne_droite_basique(104000); |
JimmyAREM | 0:a89fe490343e | 239 | robot.poussette(1000); |
JimmyAREM | 0:a89fe490343e | 240 | pompe.desactiver(); |
JimmyAREM | 0:a89fe490343e | 241 | wait(2); |
JimmyAREM | 0:a89fe490343e | 242 | updateAndWriteScore('1', '0', '4'); |
JimmyAREM | 0:a89fe490343e | 243 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 244 | |
JimmyAREM | 0:a89fe490343e | 245 | break; |
JimmyAREM | 0:a89fe490343e | 246 | } |
JimmyAREM | 0:a89fe490343e | 247 | case 4 : /* On pousse la zone de chaos dans la zone du redium */ |
JimmyAREM | 0:a89fe490343e | 248 | { |
JimmyAREM | 0:a89fe490343e | 249 | typeMovement = DEPLACEMENT_ARRIERE; |
JimmyAREM | 0:a89fe490343e | 250 | robot.marche_arriere(-8000); |
JimmyAREM | 0:a89fe490343e | 251 | typeMovement = DEPLACEMENT_AVANT; |
JimmyAREM | 0:a89fe490343e | 252 | robot.rotation_rel(135); |
JimmyAREM | 0:a89fe490343e | 253 | brasPousserGauche.activerBras(); |
JimmyAREM | 0:a89fe490343e | 254 | brasPousserDroit.activerBras(); |
JimmyAREM | 1:785b37686185 | 255 | robot.ligne_droite_basique(112500); |
JimmyAREM | 0:a89fe490343e | 256 | updateAndWriteScore('1', '2', '4'); |
JimmyAREM | 0:a89fe490343e | 257 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 258 | |
JimmyAREM | 0:a89fe490343e | 259 | break; |
JimmyAREM | 0:a89fe490343e | 260 | } |
JimmyAREM | 0:a89fe490343e | 261 | case 5 : /* On pousse le palet vert ou le vert et les deux bleus dans la balance en passant par la pente */ |
JimmyAREM | 0:a89fe490343e | 262 | { |
JimmyAREM | 0:a89fe490343e | 263 | brasPousserGauche.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 264 | brasPousserDroit.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 265 | typeMovement = DEPLACEMENT_ARRIERE; |
JimmyAREM | 0:a89fe490343e | 266 | robot.marche_arriere(-8000); |
JimmyAREM | 0:a89fe490343e | 267 | typeMovement = DEPLACEMENT_AVANT; |
JimmyAREM | 0:a89fe490343e | 268 | robot.rotation_rel(-90); |
JimmyAREM | 1:785b37686185 | 269 | robot.ligne_droite_basique(45000); |
JimmyAREM | 0:a89fe490343e | 270 | robot.rotation_rel(-42); |
JimmyAREM | 1:785b37686185 | 271 | robot.ligne_droite_basique(86000); |
JimmyAREM | 0:a89fe490343e | 272 | robot.rotation_rel(-90); |
JimmyAREM | 0:a89fe490343e | 273 | brasPousserGauche.activerBras(); |
JimmyAREM | 0:a89fe490343e | 274 | brasPousserDroit.activerBras(); |
JimmyAREM | 0:a89fe490343e | 275 | //mettre la fonction pente |
JimmyAREM | 0:a89fe490343e | 276 | robot.commande_vitesse(30,30); |
JimmyAREM | 0:a89fe490343e | 277 | wait(7); |
JimmyAREM | 0:a89fe490343e | 278 | robot.commande_vitesse(150,150); |
JimmyAREM | 0:a89fe490343e | 279 | wait(3); |
JimmyAREM | 0:a89fe490343e | 280 | updateAndWriteScore('1', '3', '4'); |
JimmyAREM | 0:a89fe490343e | 281 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 282 | |
JimmyAREM | 0:a89fe490343e | 283 | break; |
JimmyAREM | 0:a89fe490343e | 284 | } |
JimmyAREM | 0:a89fe490343e | 285 | case 6 : /* On redescant de la pente */ |
JimmyAREM | 0:a89fe490343e | 286 | { |
JimmyAREM | 0:a89fe490343e | 287 | robot.commande_vitesse(-30,-30); |
JimmyAREM | 0:a89fe490343e | 288 | wait(2); |
JimmyAREM | 0:a89fe490343e | 289 | brasPousserGauche.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 290 | brasPousserDroit.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 291 | robot.commande_vitesse(-50,-50); |
JimmyAREM | 0:a89fe490343e | 292 | wait_ms(10000); |
JimmyAREM | 0:a89fe490343e | 293 | robot.vitesse_nulle_D(0); |
JimmyAREM | 0:a89fe490343e | 294 | robot.vitesse_nulle_G(0); |
JimmyAREM | 0:a89fe490343e | 295 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 296 | |
JimmyAREM | 0:a89fe490343e | 297 | break; |
JimmyAREM | 0:a89fe490343e | 298 | } |
JimmyAREM | 0:a89fe490343e | 299 | default: |
JimmyAREM | 0:a89fe490343e | 300 | { |
JimmyAREM | 0:a89fe490343e | 301 | robot.vitesse_nulle_D(0); |
JimmyAREM | 0:a89fe490343e | 302 | robot.vitesse_nulle_G(0); |
JimmyAREM | 0:a89fe490343e | 303 | motors_stop(); |
JimmyAREM | 0:a89fe490343e | 304 | pompe.desactiver(); |
JimmyAREM | 0:a89fe490343e | 305 | } |
JimmyAREM | 0:a89fe490343e | 306 | } |
JimmyAREM | 0:a89fe490343e | 307 | } |
JimmyAREM | 0:a89fe490343e | 308 | |
JimmyAREM | 0:a89fe490343e | 309 | //Arrêter les moteurs |
JimmyAREM | 0:a89fe490343e | 310 | robot.vitesse_nulle_D(0); |
JimmyAREM | 0:a89fe490343e | 311 | robot.vitesse_nulle_G(0); |
JimmyAREM | 0:a89fe490343e | 312 | motors_stop(); |
JimmyAREM | 0:a89fe490343e | 313 | pompe.desactiver(); |
JimmyAREM | 0:a89fe490343e | 314 | while(1); |
JimmyAREM | 0:a89fe490343e | 315 | } |
JimmyAREM | 0:a89fe490343e | 316 | |
JimmyAREM | 0:a89fe490343e | 317 | |
JimmyAREM | 0:a89fe490343e | 318 | |
JimmyAREM | 0:a89fe490343e | 319 | |
JimmyAREM | 0:a89fe490343e | 320 | |
JimmyAREM | 0:a89fe490343e | 321 | |
JimmyAREM | 0:a89fe490343e | 322 | void strategieClassiqueJaune(deplacement robot, Pompe pompe, Demarreur demarreur, Bras brasGauche, Bras brasDroit, BrasPousser brasPousserGauche, BrasPousser brasPousserDroit) |
JimmyAREM | 0:a89fe490343e | 323 | { |
JimmyAREM | 0:a89fe490343e | 324 | write(bufferScore); |
JimmyAREM | 0:a89fe490343e | 325 | Timer tempsMatch; // timer en seconde |
JimmyAREM | 0:a89fe490343e | 326 | int etapeMatch = 5; |
JimmyAREM | 0:a89fe490343e | 327 | while(demarreur.getState() == false) |
JimmyAREM | 0:a89fe490343e | 328 | { |
JimmyAREM | 0:a89fe490343e | 329 | //on attend |
JimmyAREM | 0:a89fe490343e | 330 | //pc.printf("On attend le depart du Robot Thanos\n\r"); |
JimmyAREM | 0:a89fe490343e | 331 | } |
JimmyAREM | 1:785b37686185 | 332 | tempsArretMvt.attach(&arretSystem, 100.0); |
JimmyAREM | 0:a89fe490343e | 333 | lancerTimerEcran(); |
JimmyAREM | 0:a89fe490343e | 334 | tempsMatch.start(); |
JimmyAREM | 0:a89fe490343e | 335 | while(tempsMatch <= TEMPSMATCH) |
JimmyAREM | 0:a89fe490343e | 336 | { |
JimmyAREM | 0:a89fe490343e | 337 | switch (etapeMatch) { |
JimmyAREM | 0:a89fe490343e | 338 | |
JimmyAREM | 0:a89fe490343e | 339 | case 0 : /* On active l'expérience */ |
JimmyAREM | 0:a89fe490343e | 340 | { |
JimmyAREM | 1:785b37686185 | 341 | robot.ligne_droite_basique(25000); |
JimmyAREM | 0:a89fe490343e | 342 | robot.poussette(300); |
JimmyAREM | 0:a89fe490343e | 343 | updateAndWriteScore('0', '4', '0'); |
JimmyAREM | 0:a89fe490343e | 344 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 345 | |
JimmyAREM | 0:a89fe490343e | 346 | break; |
JimmyAREM | 0:a89fe490343e | 347 | } |
JimmyAREM | 0:a89fe490343e | 348 | case 1 : /* On pousse le palet bleu de la pente de l'accélérateur */ |
JimmyAREM | 0:a89fe490343e | 349 | { |
JimmyAREM | 0:a89fe490343e | 350 | robot.marche_arriere(-11200); |
JimmyAREM | 0:a89fe490343e | 351 | robot.rotation_rel(-90); |
JimmyAREM | 1:785b37686185 | 352 | robot.ligne_droite_basique(130000); |
JimmyAREM | 0:a89fe490343e | 353 | brasDroit.activerBras(); |
JimmyAREM | 1:785b37686185 | 354 | robot.ligne_droite_basique(16000); |
JimmyAREM | 0:a89fe490343e | 355 | brasDroit.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 356 | updateAndWriteScore('0', '5', '0'); |
JimmyAREM | 0:a89fe490343e | 357 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 358 | |
JimmyAREM | 0:a89fe490343e | 359 | break; |
JimmyAREM | 0:a89fe490343e | 360 | } |
JimmyAREM | 0:a89fe490343e | 361 | case 2 : /* On récupère le goldenium */ |
JimmyAREM | 0:a89fe490343e | 362 | { |
JimmyAREM | 1:785b37686185 | 363 | robot.ligne_droite_basique(54500); |
JimmyAREM | 0:a89fe490343e | 364 | robot.rotation_rel(90); |
JimmyAREM | 0:a89fe490343e | 365 | pompe.activer(); |
JimmyAREM | 0:a89fe490343e | 366 | robot.poussette(1000); |
JimmyAREM | 0:a89fe490343e | 367 | robot.marche_arriere(-10000); |
JimmyAREM | 0:a89fe490343e | 368 | updateAndWriteScore('0', '8', '0'); |
JimmyAREM | 0:a89fe490343e | 369 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 370 | |
JimmyAREM | 0:a89fe490343e | 371 | break; |
JimmyAREM | 0:a89fe490343e | 372 | } |
JimmyAREM | 0:a89fe490343e | 373 | case 3 : /* On met le goldenium dans la balance */ |
JimmyAREM | 0:a89fe490343e | 374 | { |
JimmyAREM | 0:a89fe490343e | 375 | |
JimmyAREM | 0:a89fe490343e | 376 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 377 | robot.ligne_droite_basique(96000); |
JimmyAREM | 0:a89fe490343e | 378 | robot.rotation_rel(90); |
JimmyAREM | 1:785b37686185 | 379 | robot.ligne_droite_basique(104000); |
JimmyAREM | 0:a89fe490343e | 380 | robot.poussette(1000); |
JimmyAREM | 0:a89fe490343e | 381 | pompe.desactiver(); |
JimmyAREM | 0:a89fe490343e | 382 | wait(2); |
JimmyAREM | 0:a89fe490343e | 383 | updateAndWriteScore('1', '0', '4'); |
JimmyAREM | 0:a89fe490343e | 384 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 385 | |
JimmyAREM | 0:a89fe490343e | 386 | break; |
JimmyAREM | 0:a89fe490343e | 387 | } |
JimmyAREM | 0:a89fe490343e | 388 | case 4 : /* On pousse la zone de chaos dans la zone du redium */ |
JimmyAREM | 0:a89fe490343e | 389 | { |
JimmyAREM | 0:a89fe490343e | 390 | |
JimmyAREM | 0:a89fe490343e | 391 | robot.marche_arriere(-8000); |
JimmyAREM | 0:a89fe490343e | 392 | robot.rotation_rel(-135); |
JimmyAREM | 0:a89fe490343e | 393 | brasPousserGauche.activerBras(); |
JimmyAREM | 0:a89fe490343e | 394 | brasPousserDroit.activerBras(); |
JimmyAREM | 1:785b37686185 | 395 | robot.ligne_droite_basique(112500); |
JimmyAREM | 0:a89fe490343e | 396 | updateAndWriteScore('1', '2', '4'); |
JimmyAREM | 0:a89fe490343e | 397 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 398 | |
JimmyAREM | 0:a89fe490343e | 399 | break; |
JimmyAREM | 0:a89fe490343e | 400 | } |
JimmyAREM | 0:a89fe490343e | 401 | case 5 : /* On pousse le palet vert ou le vert et les deux bleus dans la balance en passant par la pente */ |
JimmyAREM | 0:a89fe490343e | 402 | { |
JimmyAREM | 0:a89fe490343e | 403 | brasPousserGauche.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 404 | brasPousserDroit.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 405 | /*robot.marche_arriere(-8000); |
JimmyAREM | 0:a89fe490343e | 406 | robot.rotation_rel(-90); |
JimmyAREM | 0:a89fe490343e | 407 | robot.ligne_droite(45000); |
JimmyAREM | 0:a89fe490343e | 408 | robot.rotation_rel(-42); |
JimmyAREM | 0:a89fe490343e | 409 | robot.ligne_droite(86000);*/ |
JimmyAREM | 0:a89fe490343e | 410 | robot.rotation_rel(90); |
JimmyAREM | 0:a89fe490343e | 411 | brasPousserGauche.activerBras(); |
JimmyAREM | 0:a89fe490343e | 412 | brasPousserDroit.activerBras(); |
JimmyAREM | 0:a89fe490343e | 413 | robot.commande_vitesse(30,30); |
JimmyAREM | 0:a89fe490343e | 414 | wait(7); |
JimmyAREM | 0:a89fe490343e | 415 | robot.commande_vitesse(150,150); |
JimmyAREM | 0:a89fe490343e | 416 | wait(3); |
JimmyAREM | 0:a89fe490343e | 417 | updateAndWriteScore('1', '3', '4'); |
JimmyAREM | 0:a89fe490343e | 418 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 419 | |
JimmyAREM | 0:a89fe490343e | 420 | break; |
JimmyAREM | 0:a89fe490343e | 421 | } |
JimmyAREM | 0:a89fe490343e | 422 | case 6 : /* On redescant de la pente */ |
JimmyAREM | 0:a89fe490343e | 423 | { |
JimmyAREM | 0:a89fe490343e | 424 | robot.commande_vitesse(-30,-30); |
JimmyAREM | 0:a89fe490343e | 425 | wait(2); |
JimmyAREM | 0:a89fe490343e | 426 | brasPousserGauche.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 427 | brasPousserDroit.desactiverBras(); |
JimmyAREM | 0:a89fe490343e | 428 | robot.commande_vitesse(-50,-50); |
JimmyAREM | 0:a89fe490343e | 429 | wait_ms(10000); |
JimmyAREM | 0:a89fe490343e | 430 | robot.vitesse_nulle_D(0); |
JimmyAREM | 0:a89fe490343e | 431 | robot.vitesse_nulle_G(0); |
JimmyAREM | 0:a89fe490343e | 432 | etapeMatch++; |
JimmyAREM | 0:a89fe490343e | 433 | |
JimmyAREM | 0:a89fe490343e | 434 | break; |
JimmyAREM | 0:a89fe490343e | 435 | } |
JimmyAREM | 0:a89fe490343e | 436 | default: |
JimmyAREM | 0:a89fe490343e | 437 | { |
JimmyAREM | 0:a89fe490343e | 438 | robot.vitesse_nulle_D(0); |
JimmyAREM | 0:a89fe490343e | 439 | robot.vitesse_nulle_G(0); |
JimmyAREM | 0:a89fe490343e | 440 | motors_stop(); |
JimmyAREM | 0:a89fe490343e | 441 | } |
JimmyAREM | 0:a89fe490343e | 442 | } |
JimmyAREM | 0:a89fe490343e | 443 | } |
JimmyAREM | 0:a89fe490343e | 444 | |
JimmyAREM | 0:a89fe490343e | 445 | //Arrêter les moteurs |
JimmyAREM | 0:a89fe490343e | 446 | robot.vitesse_nulle_D(0); |
JimmyAREM | 0:a89fe490343e | 447 | robot.vitesse_nulle_G(0); |
JimmyAREM | 0:a89fe490343e | 448 | motors_stop(); |
JimmyAREM | 0:a89fe490343e | 449 | while(1); |
JimmyAREM | 0:a89fe490343e | 450 | } |