carte_strategie_2019

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Committer:
kyxstark
Date:
Mon May 27 10:43:43 2019 +0000
Revision:
74:cdea2998f0b1
Parent:
73:bf4d6d9db13b
Child:
75:1db1b929f13d

        

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