carte_strategie_2019

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Committer:
Artiom
Date:
Fri May 31 05:02:55 2019 +0000
Revision:
83:23e04b85ae06
Parent:
81:ef50ec0ef328
Child:
84:44d6cd2cab99
ajout gold relache av Gr; ; test reprise de courbe ;      cote jaune ok;     cote violet pas du tout ok

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sitkah 29:41e02746041d 1 #include "global.h"
Sitkah 29:41e02746041d 2 #ifdef ROBOT_BIG
ClementBreteau 15:c2fc239e85df 3
Artiom 83:23e04b85ae06 4 unsigned short x;
Artiom 83:23e04b85ae06 5 unsigned short y;
antbig 12:14729d584500 6 unsigned char isStopEnable = 1;//Permet de savoir si il faut autoriser le stop via les balises
antbig 12:14729d584500 7
antbig 0:ad97421fb1fb 8 /****************************************************************************************/
antbig 0:ad97421fb1fb 9 /* FUNCTION NAME: doFunnyAction */
antbig 0:ad97421fb1fb 10 /* DESCRIPTION : Permet de faire la funny action en fin de partie */
antbig 0:ad97421fb1fb 11 /****************************************************************************************/
antbig 0:ad97421fb1fb 12 void doFunnyAction(void) {
ClementBreteau 18:cc5fec34ed9c 13 //envoie de la funny action
ClementBreteau 18:cc5fec34ed9c 14 // 0x007, 01, 01
ClementBreteau 18:cc5fec34ed9c 15 CANMessage msgTx=CANMessage();
ClementBreteau 18:cc5fec34ed9c 16 msgTx.id=GLOBAL_FUNNY_ACTION;
ClementBreteau 18:cc5fec34ed9c 17 msgTx.format=CANStandard;
ClementBreteau 18:cc5fec34ed9c 18 msgTx.type=CANData;
ClementBreteau 18:cc5fec34ed9c 19 msgTx.len=2;
ClementBreteau 18:cc5fec34ed9c 20 msgTx.data[0]=0x01;
ClementBreteau 18:cc5fec34ed9c 21 msgTx.data[1]=0x01;
ClementBreteau 18:cc5fec34ed9c 22 can1.write(msgTx);
antbig 0:ad97421fb1fb 23 }
antbig 0:ad97421fb1fb 24
antbig 0:ad97421fb1fb 25 /****************************************************************************************/
antbig 0:ad97421fb1fb 26 /* FUNCTION NAME: doAction */
antbig 0:ad97421fb1fb 27 /* DESCRIPTION : Effectuer une action specifique */
antbig 0:ad97421fb1fb 28 /****************************************************************************************/
Sitkah 30:a1e37af4bbde 29 unsigned char doAction(unsigned char id, unsigned short var1, short var2) {
antbig 12:14729d584500 30 CANMessage msgTx=CANMessage();
Sitkah 30:a1e37af4bbde 31 msgTx.format=CANStandard;
Sitkah 30:a1e37af4bbde 32 msgTx.type=CANData;
Sitkah 30:a1e37af4bbde 33 //affichage_debug(id);
Sitkah 30:a1e37af4bbde 34
antbig 0:ad97421fb1fb 35 switch(id) {
Sitkah 30:a1e37af4bbde 36 /////////////////////////////////////////////////////////100 à 108 : ACTIONS HERKULEX/////////////////////////////////////////////
Artiom 83:23e04b85ae06 37 case 118:
Artiom 83:23e04b85ae06 38 SendRawId(VENTOUSE_AV_CENTRE_BALANCE);
Artiom 83:23e04b85ae06 39 break;
Villanut 71:67cce4efd33d 40 case 201:
Villanut 75:1db1b929f13d 41 unsigned char var_tempo;
Artiom 81:ef50ec0ef328 42 var_tempo = (unsigned char)var1;//0auto 1forceon 2 forceoff
Villanut 75:1db1b929f13d 43 SendMsgCan(ASCENSEUR, &var_tempo,1);
Villanut 75:1db1b929f13d 44 waitingAckFrom = 0;
Villanut 75:1db1b929f13d 45 waitingAckID =0;
Sitkah 38:76f886a1c8e6 46 break;
ClementBreteau 15:c2fc239e85df 47
Villanut 72:5b1b3e151e59 48 case 202:
Villanut 72:5b1b3e151e59 49 msgTx.id=VIDER_CONVOYEUR;
Artiom 67:96f914f92d2d 50
Villanut 72:5b1b3e151e59 51 msgTx.len=1;
Villanut 72:5b1b3e151e59 52 msgTx.data[0]=(unsigned char)var1;
Villanut 72:5b1b3e151e59 53
Villanut 72:5b1b3e151e59 54 can2.write(msgTx);
Sitkah 30:a1e37af4bbde 55 break;
Artiom 67:96f914f92d2d 56
Villanut 72:5b1b3e151e59 57 case 203:
Artiom 83:23e04b85ae06 58 x = var1;
Artiom 83:23e04b85ae06 59 if(InversStrat == 1)
Artiom 83:23e04b85ae06 60 {
Artiom 83:23e04b85ae06 61 y = 3000 - var2;
Artiom 83:23e04b85ae06 62 }
Artiom 83:23e04b85ae06 63 else
Artiom 83:23e04b85ae06 64 {
Artiom 83:23e04b85ae06 65 y = var2;
Artiom 83:23e04b85ae06 66 }
Artiom 83:23e04b85ae06 67
Artiom 83:23e04b85ae06 68 Send2Short(GOLDENIUM_AVANT, x, y);
Sitkah 30:a1e37af4bbde 69 break;
Artiom 67:96f914f92d2d 70
Villanut 72:5b1b3e151e59 71 case 204:
Villanut 72:5b1b3e151e59 72 unsigned char arg_tempo;
Villanut 72:5b1b3e151e59 73 if(InversStrat == 1)
Villanut 72:5b1b3e151e59 74 {
Villanut 72:5b1b3e151e59 75 switch(var1){
Villanut 72:5b1b3e151e59 76 case AV_DROIT:
Villanut 72:5b1b3e151e59 77 arg_tempo = AV_GAUCHE;
Villanut 72:5b1b3e151e59 78 break;
Villanut 72:5b1b3e151e59 79 case AV_GAUCHE:
Villanut 72:5b1b3e151e59 80 arg_tempo = AV_DROIT;
Villanut 72:5b1b3e151e59 81 break;
Villanut 72:5b1b3e151e59 82 default :
Villanut 72:5b1b3e151e59 83 arg_tempo =(unsigned char)var1;
Villanut 72:5b1b3e151e59 84 break;
Villanut 72:5b1b3e151e59 85 }
Villanut 72:5b1b3e151e59 86
Villanut 72:5b1b3e151e59 87 }
Villanut 72:5b1b3e151e59 88 else arg_tempo =(unsigned char)var1;
Villanut 72:5b1b3e151e59 89 SendMsgCan(HACHEUR_RELEASE_ATOM, &arg_tempo,1);
Villanut 72:5b1b3e151e59 90 waitingAckFrom = 0;
Villanut 72:5b1b3e151e59 91 waitingAckID =0;
Sitkah 38:76f886a1c8e6 92 break;
Villanut 72:5b1b3e151e59 93
Villanut 72:5b1b3e151e59 94 case 205:
Villanut 72:5b1b3e151e59 95 SendRawId(PRESENTOIR_AVANT);
Sitkah 41:b029ddc4d60e 96 break;
Sitkah 38:76f886a1c8e6 97
Artiom 78:c0533a36da8f 98
Sitkah 38:76f886a1c8e6 99 case 150:
Sitkah 38:76f886a1c8e6 100 SCORE_GR+=var1;
Sitkah 38:76f886a1c8e6 101 SCORE_GLOBAL=SCORE_GR+SCORE_PR;
Sitkah 40:21bb685b553b 102 //liaison_Tx.envoyer_short(0x30,SCORE_GLOBAL);
Sitkah 38:76f886a1c8e6 103 waitingAckFrom = 0;
Sitkah 38:76f886a1c8e6 104 waitingAckID = 0;
Sitkah 38:76f886a1c8e6 105 break;
Sitkah 38:76f886a1c8e6 106
ClementBreteau 18:cc5fec34ed9c 107
Artiom 67:96f914f92d2d 108 case 11://0 Désactiver le stop,1 Activer le stop saut de strat,2 Activer le stop avec evitement
Villanut 71:67cce4efd33d 109 isStopEnable =(unsigned char) var1;
Artiom 83:23e04b85ae06 110 // SendMsgCan(0x5BC, &isStopEnable,1);
Artiom 67:96f914f92d2d 111 waitingAckFrom = 0;
Artiom 67:96f914f92d2d 112 waitingAckID =0;
Artiom 67:96f914f92d2d 113 break;
Villanut 75:1db1b929f13d 114
antbig 12:14729d584500 115 case 20://Désactiver l'asservissement
antbig 12:14729d584500 116 setAsservissementEtat(0);
antbig 12:14729d584500 117 break;
Artiom 67:96f914f92d2d 118
antbig 12:14729d584500 119 case 21://Activer l'asservissement
antbig 12:14729d584500 120 setAsservissementEtat(1);
antbig 12:14729d584500 121 break;
antbig 12:14729d584500 122
antbig 12:14729d584500 123 case 22://Changer la vitesse du robot
kyxstark 73:bf4d6d9db13b 124 SendSpeed(var1);
ClementBreteau 26:2f4fcc2354f3 125 waitingAckFrom = 0;
ClementBreteau 26:2f4fcc2354f3 126 waitingAckID = 0;
ClementBreteau 26:2f4fcc2354f3 127 wait(0.2);
antbig 12:14729d584500 128 break;
kyxstark 74:cdea2998f0b1 129 case 23:
kyxstark 74:cdea2998f0b1 130 SendAccel(var1,(unsigned short)var2);//,(unsigned short)arg2, (unsigned short)arg2);
kyxstark 74:cdea2998f0b1 131 wait_us(200);
kyxstark 74:cdea2998f0b1 132 waitingAckFrom = 0;
kyxstark 74:cdea2998f0b1 133 waitingAckID = 0;
kyxstark 74:cdea2998f0b1 134 break;
antbig 12:14729d584500 135
antbig 12:14729d584500 136 case 30://Action tempo
Sitkah 30:a1e37af4bbde 137 wait_ms(var1);
Sitkah 40:21bb685b553b 138 waitingAckFrom = 0;
Sitkah 40:21bb685b553b 139 waitingAckID = 0;
antbig 12:14729d584500 140 break;
antbig 12:14729d584500 141
Artiom 67:96f914f92d2d 142
antbig 12:14729d584500 143
antbig 0:ad97421fb1fb 144 default:
antbig 0:ad97421fb1fb 145 return 0;//L'action n'existe pas, il faut utiliser le CAN
antbig 0:ad97421fb1fb 146
antbig 0:ad97421fb1fb 147 }
antbig 0:ad97421fb1fb 148 return 1;//L'action est spécifique.
antbig 0:ad97421fb1fb 149
antbig 0:ad97421fb1fb 150 }
antbig 0:ad97421fb1fb 151
antbig 0:ad97421fb1fb 152 /****************************************************************************************/
antbig 0:ad97421fb1fb 153 /* FUNCTION NAME: initRobot */
antbig 0:ad97421fb1fb 154 /* DESCRIPTION : initialiser le robot */
antbig 0:ad97421fb1fb 155 /****************************************************************************************/
antbig 9:d0042422d95a 156 void initRobot(void)
antbig 9:d0042422d95a 157 {
antbig 9:d0042422d95a 158 //Enregistrement de tous les AX12 présent sur la carte
ClementBreteau 15:c2fc239e85df 159 /*AX12_register(5, AX12_SERIAL2);
antbig 8:0edc7dfb7f7e 160 AX12_register(18, AX12_SERIAL2);
antbig 8:0edc7dfb7f7e 161 AX12_register(13, AX12_SERIAL2);
antbig 12:14729d584500 162 AX12_register(1, AX12_SERIAL1);
antbig 12:14729d584500 163 AX12_register(11, AX12_SERIAL1);
antbig 12:14729d584500 164 AX12_register(8, AX12_SERIAL1);
ClementBreteau 15:c2fc239e85df 165 AX12_register(7, AX12_SERIAL2);*/
antbig 9:d0042422d95a 166
antbig 12:14729d584500 167 //AX12_setGoal(AX12_ID_FUNNY_ACTION, AX12_ANGLE_FUNNY_ACTION_CLOSE,AX12_SPEED_FUNNY_ACTION);
antbig 12:14729d584500 168 //AX12_processChange();
antbig 11:ed13a480ddca 169 //runRobotTest();
ClementBreteau 16:7321fb3bb396 170
antbig 9:d0042422d95a 171 }
antbig 9:d0042422d95a 172
antbig 9:d0042422d95a 173 /****************************************************************************************/
antbig 12:14729d584500 174 /* FUNCTION NAME: initRobotActionneur */
antbig 12:14729d584500 175 /* DESCRIPTION : Initialiser la position des actionneurs du robot */
antbig 12:14729d584500 176 /****************************************************************************************/
antbig 12:14729d584500 177 void initRobotActionneur(void)
antbig 12:14729d584500 178 {
ClementBreteau 23:ab87d308eaf9 179 /*doAction(100,1,0);
ClementBreteau 23:ab87d308eaf9 180 doAction(100,2,0);
ClementBreteau 23:ab87d308eaf9 181 doAction(110,0,0);
ClementBreteau 23:ab87d308eaf9 182 doAction(120,0,0);
ClementBreteau 23:ab87d308eaf9 183 doAction(131,0,0);*/
ClementBreteau 23:ab87d308eaf9 184
antbig 12:14729d584500 185 }
antbig 12:14729d584500 186
antbig 12:14729d584500 187 /****************************************************************************************/
antbig 9:d0042422d95a 188 /* FUNCTION NAME: runTest */
antbig 9:d0042422d95a 189 /* DESCRIPTION : tester l'ensemble des actionneurs du robot */
antbig 9:d0042422d95a 190 /****************************************************************************************/
antbig 9:d0042422d95a 191 void runRobotTest(void)
antbig 9:d0042422d95a 192 {
ClementBreteau 18:cc5fec34ed9c 193 /*
antbig 12:14729d584500 194 int waitTime = 500;
antbig 12:14729d584500 195
antbig 9:d0042422d95a 196 //Test des AX12 dans l'ordre
antbig 9:d0042422d95a 197 doAction(111,0,0);//Fermeture pince arrière haute
antbig 12:14729d584500 198 wait_ms(waitTime);
antbig 9:d0042422d95a 199 doAction(110,0,0);//Ouverture pince arrière haute
antbig 12:14729d584500 200 wait_ms(waitTime);
antbig 9:d0042422d95a 201 doAction(113,0,0);//Fermeture pince arrière basse
antbig 12:14729d584500 202 wait_ms(waitTime);
antbig 9:d0042422d95a 203 doAction(112,0,0);//Ouverture pince arrière basse
antbig 12:14729d584500 204 wait_ms(waitTime);
antbig 9:d0042422d95a 205 doAction(115,0,0);//Fermeture porte arrière
antbig 12:14729d584500 206 wait_ms(waitTime);
antbig 9:d0042422d95a 207 doAction(114,0,0);//Ouverture porte arrière
antbig 12:14729d584500 208 wait_ms(waitTime);
antbig 12:14729d584500 209 doAction(101,0,0);//Fermer les portes avant
antbig 12:14729d584500 210 wait_ms(waitTime);
antbig 12:14729d584500 211 doAction(100,0,0);//Ouvrir les portes avant
antbig 12:14729d584500 212 wait_ms(waitTime);
antbig 12:14729d584500 213 doAction(103,0,0);//Descendre le peigne
antbig 12:14729d584500 214 wait_ms(waitTime);
ClementBreteau 18:cc5fec34ed9c 215 doAction(102,0,0);//Remonter le peigne*/
antbig 0:ad97421fb1fb 216 }
antbig 3:19f2285a4757 217
antbig 4:88431b537477 218 /****************************************************************************************/
antbig 4:88431b537477 219 /* FUNCTION NAME: SelectStrategy */
antbig 4:88431b537477 220 /* DESCRIPTION : Charger le fichier de stratégie correspondante à un id */
antbig 4:88431b537477 221 /* RETURN : 0=> Erreur, 1=> OK si le fichier existe */
antbig 4:88431b537477 222 /****************************************************************************************/
Sitkah 29:41e02746041d 223 /*int SelectStrategy(unsigned char id)
antbig 4:88431b537477 224 {
antbig 4:88431b537477 225 switch(id)
antbig 4:88431b537477 226 {
ClementBreteau 15:c2fc239e85df 227 // strat de match
antbig 4:88431b537477 228 case 1:
antbig 11:ed13a480ddca 229 strcpy(cheminFileStart,"/local/strat1.txt");
antbig 11:ed13a480ddca 230 return FileExists(cheminFileStart);
antbig 11:ed13a480ddca 231 case 2:
antbig 11:ed13a480ddca 232 strcpy(cheminFileStart,"/local/strat2.txt");
antbig 11:ed13a480ddca 233 return FileExists(cheminFileStart);
antbig 11:ed13a480ddca 234 case 3:
antbig 11:ed13a480ddca 235 strcpy(cheminFileStart,"/local/strat3.txt");
antbig 11:ed13a480ddca 236 return FileExists(cheminFileStart);
antbig 12:14729d584500 237 case 4:
antbig 12:14729d584500 238 strcpy(cheminFileStart,"/local/strat4.txt");
antbig 12:14729d584500 239 return FileExists(cheminFileStart);
antbig 12:14729d584500 240 case 5:
antbig 12:14729d584500 241 strcpy(cheminFileStart,"/local/strat5.txt");
antbig 12:14729d584500 242 return FileExists(cheminFileStart);
ClementBreteau 14:c8fc06c4887f 243 case 6:
ClementBreteau 14:c8fc06c4887f 244 strcpy(cheminFileStart,"/local/strat6.txt");
ClementBreteau 14:c8fc06c4887f 245 return FileExists(cheminFileStart);
ClementBreteau 14:c8fc06c4887f 246 case 7:
ClementBreteau 14:c8fc06c4887f 247 strcpy(cheminFileStart,"/local/strat7.txt");
ClementBreteau 14:c8fc06c4887f 248 return FileExists(cheminFileStart);
ClementBreteau 14:c8fc06c4887f 249 case 8:
ClementBreteau 14:c8fc06c4887f 250 strcpy(cheminFileStart,"/local/strat8.txt");
ClementBreteau 14:c8fc06c4887f 251 return FileExists(cheminFileStart);
ClementBreteau 14:c8fc06c4887f 252 case 9:
ClementBreteau 14:c8fc06c4887f 253 strcpy(cheminFileStart,"/local/strat9.txt");
ClementBreteau 14:c8fc06c4887f 254 return FileExists(cheminFileStart);
ClementBreteau 14:c8fc06c4887f 255 case 10:
ClementBreteau 14:c8fc06c4887f 256 strcpy(cheminFileStart,"/local/strat10.txt");
ClementBreteau 14:c8fc06c4887f 257 return FileExists(cheminFileStart);
ClementBreteau 14:c8fc06c4887f 258
ClementBreteau 15:c2fc239e85df 259 // strat de demo
ClementBreteau 14:c8fc06c4887f 260 case 0x10:
ClementBreteau 14:c8fc06c4887f 261 strcpy(cheminFileStart,"/local/moteur.txt");
ClementBreteau 14:c8fc06c4887f 262 return FileExists(cheminFileStart);
ClementBreteau 14:c8fc06c4887f 263 case 0x11:
ClementBreteau 15:c2fc239e85df 264 #ifdef ROBOT_BIG
ClementBreteau 15:c2fc239e85df 265 strcpy(cheminFileStart,"/local/bras.txt");
ClementBreteau 15:c2fc239e85df 266 #else
ClementBreteau 15:c2fc239e85df 267 strcpy(cheminFileStart,"/local/porteAvant.txt");
ClementBreteau 15:c2fc239e85df 268 #endif
ClementBreteau 14:c8fc06c4887f 269 return FileExists(cheminFileStart);
ClementBreteau 15:c2fc239e85df 270 case 0x12:
ClementBreteau 15:c2fc239e85df 271 #ifdef ROBOT_BIG
ClementBreteau 15:c2fc239e85df 272 strcpy(cheminFileStart,"/local/balancier.txt");
ClementBreteau 15:c2fc239e85df 273 #else
ClementBreteau 15:c2fc239e85df 274 strcpy(cheminFileStart,"/local/mainTourneuse.txt");
ClementBreteau 15:c2fc239e85df 275 #endif
ClementBreteau 15:c2fc239e85df 276 return FileExists(cheminFileStart);
antbig 11:ed13a480ddca 277 default:
antbig 12:14729d584500 278 strcpy(cheminFileStart,"/local/strat1.txt");
antbig 11:ed13a480ddca 279 return 0;
antbig 4:88431b537477 280 }
Sitkah 29:41e02746041d 281 }*/
antbig 4:88431b537477 282
antbig 12:14729d584500 283 /****************************************************************************************/
antbig 12:14729d584500 284 /* FUNCTION NAME: needToStop */
antbig 12:14729d584500 285 /* DESCRIPTION : Savoir si il faut autoriser le stop du robot via balise */
antbig 12:14729d584500 286 /****************************************************************************************/
antbig 12:14729d584500 287 unsigned char needToStop(void)
antbig 12:14729d584500 288 {
antbig 12:14729d584500 289 return isStopEnable;
antbig 12:14729d584500 290 }
antbig 12:14729d584500 291
antbig 12:14729d584500 292 /****************************************************************************************/
antbig 12:14729d584500 293 /* FUNCTION NAME: doBeforeEndAction */
antbig 12:14729d584500 294 /* DESCRIPTION : Terminer les actions du robot 1s avant la fin du match */
antbig 12:14729d584500 295 /****************************************************************************************/
antbig 12:14729d584500 296 void doBeforeEndAction(void)
antbig 12:14729d584500 297 {
antbig 12:14729d584500 298 doAction(110,0,0);//Ouverture pince arrière haute
antbig 12:14729d584500 299 doAction(112,0,0);//Ouverture pince arrière basse
antbig 12:14729d584500 300 doAction(114,0,0);//Ouverture porte arrière
antbig 12:14729d584500 301 doAction(100,0,0);//Ouvrir les portes avant
antbig 12:14729d584500 302 doAction(102,0,0);//Remonter le peigne
antbig 12:14729d584500 303 }
antbig 12:14729d584500 304
antbig 3:19f2285a4757 305 #endif