carte_strategie_2019

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Committer:
Artiom
Date:
Wed May 29 21:27:00 2019 +0000
Revision:
81:ef50ec0ef328
Parent:
80:545a9bf561e1
Child:
83:23e04b85ae06
Child:
85:c46c39d879a9
arret balise xyt fonctionel, pb arret courbe;

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