carte_strategie_2019

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Committer:
Villanut
Date:
Sun May 26 15:53:09 2019 +0000
Revision:
71:67cce4efd33d
Parent:
67:96f914f92d2d
Child:
72:5b1b3e151e59
;

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