CRAC Team / Mbed 2 deprecated carte_strategie_2019

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Committer:
Artiom
Date:
Fri May 31 17:33:28 2019 +0000
Revision:
84:44d6cd2cab99
Parent:
83:23e04b85ae06
new test courbe

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sitkah 29:41e02746041d 1 #include "global.h"
Sitkah 38:76f886a1c8e6 2
antbig 3:19f2285a4757 3 #ifdef ROBOT_SMALL
Sitkah 29:41e02746041d 4
Artiom 67:96f914f92d2d 5 unsigned short distance_recalage;
Artiom 67:96f914f92d2d 6 unsigned short distance_revenir;
Artiom 78:c0533a36da8f 7
Artiom 78:c0533a36da8f 8 unsigned short x;
Artiom 78:c0533a36da8f 9 unsigned short y;
antbig 12:14729d584500 10 unsigned char isStopEnable = 1;//Permet de savoir si il faut autoriser le stop via les balises
ClementBreteau 21:590cdacb6a35 11 //unsigned short telemetreDistance;
ClementBreteau 18:cc5fec34ed9c 12
antbig 12:14729d584500 13
antbig 3:19f2285a4757 14 /****************************************************************************************/
antbig 3:19f2285a4757 15 /* FUNCTION NAME: doFunnyAction */
antbig 3:19f2285a4757 16 /* DESCRIPTION : Permet de faire la funny action en fin de partie */
antbig 3:19f2285a4757 17 /****************************************************************************************/
Artiom 46:a9b6bcb30b1c 18 void doFunnyAction(void)
Artiom 46:a9b6bcb30b1c 19 {
Artiom 46:a9b6bcb30b1c 20
Artiom 46:a9b6bcb30b1c 21
antbig 3:19f2285a4757 22 }
antbig 3:19f2285a4757 23
ClementBreteau 18:cc5fec34ed9c 24
Sitkah 42:657b6a573e11 25 /*************************************************************************************************/
Sitkah 42:657b6a573e11 26 /* FUNCTION NAME: doAction */
Sitkah 42:657b6a573e11 27 /* DESCRIPTION : Effectuer une action specifique correspondant au numéro dans le fichier strat */
Sitkah 42:657b6a573e11 28 /*************************************************************************************************/
Artiom 46:a9b6bcb30b1c 29 unsigned char doAction(unsigned char id, unsigned short arg1, short arg2)
Artiom 46:a9b6bcb30b1c 30 {
ClementBreteau 18:cc5fec34ed9c 31 int retour = 1;
Sitkah 34:6aa4b46b102e 32 CANMessage msgTx=CANMessage();
Sitkah 34:6aa4b46b102e 33 msgTx.format=CANStandard;
Sitkah 34:6aa4b46b102e 34 msgTx.type=CANData;
Artiom 83:23e04b85ae06 35 //SendMsgCan(0x5BB, &id,1);
antbig 3:19f2285a4757 36 switch(id) {
Villanut 45:4f93e99bac6e 37 case 101: //bras gabarit
Artiom 46:a9b6bcb30b1c 38 SendRawId(GABARIT_PETIT_ROBOT);
Sitkah 30:a1e37af4bbde 39 break;
Villanut 45:4f93e99bac6e 40 case 102: //attraper presentoir avant
Artiom 46:a9b6bcb30b1c 41 SendRawId(PRESENTOIR_AVANT);
Sitkah 30:a1e37af4bbde 42 break;
Villanut 45:4f93e99bac6e 43 case 103: //attraper presentoir arriere
Villanut 45:4f93e99bac6e 44 SendRawId(PRESENTOIR_ARRIERE);
Sitkah 30:a1e37af4bbde 45 break;
Villanut 45:4f93e99bac6e 46 case 104: //balance avant
Villanut 45:4f93e99bac6e 47 SendRawId(BALANCE_AVANT);
Sitkah 30:a1e37af4bbde 48 break;
Villanut 45:4f93e99bac6e 49 case 105: //balance arriere
Villanut 45:4f93e99bac6e 50 SendRawId(BALANCE_ARRIERE);
Sitkah 30:a1e37af4bbde 51 break;
Villanut 45:4f93e99bac6e 52 case 106: //accelerateur avant
Artiom 60:97bf2bdd51cc 53 //SendRawId(ACCELERATEUR_AVANT);
Artiom 67:96f914f92d2d 54 distance_recalage=arg1;
Artiom 67:96f914f92d2d 55 distance_revenir=arg2;
Artiom 60:97bf2bdd51cc 56 Send2Short(ACCELERATEUR_AVANT, distance_recalage,distance_revenir);
Sitkah 30:a1e37af4bbde 57 break;
Villanut 45:4f93e99bac6e 58 case 107: //accelerateur arriere
Artiom 67:96f914f92d2d 59 distance_recalage=arg1;
Artiom 67:96f914f92d2d 60 distance_revenir=arg2;
Artiom 67:96f914f92d2d 61 Send2Short(ACCELERATEUR_ARRIERE, distance_recalage,distance_revenir);
Sitkah 30:a1e37af4bbde 62 break;
Villanut 45:4f93e99bac6e 63 case 108: //goldenium avant
Artiom 60:97bf2bdd51cc 64 //SendRawId(GOLDENIUM_AVANT);
Artiom 83:23e04b85ae06 65 x = arg1;
Artiom 84:44d6cd2cab99 66 if(InversStrat == 1) {
Artiom 83:23e04b85ae06 67 y = 3000 - arg2;
Artiom 84:44d6cd2cab99 68 } else {
Artiom 83:23e04b85ae06 69 y = arg2;
Artiom 83:23e04b85ae06 70 }
Artiom 83:23e04b85ae06 71 Send2Short(GOLDENIUM_AVANT, x, y);
Sitkah 30:a1e37af4bbde 72 break;
Villanut 45:4f93e99bac6e 73 case 109: //goldenium arriere
Artiom 78:c0533a36da8f 74 x=arg1;
Artiom 78:c0533a36da8f 75 y=arg2;
Artiom 78:c0533a36da8f 76 Send2Short(GOLDENIUM_ARRIERE, x,y);
Sitkah 30:a1e37af4bbde 77 break;
Villanut 45:4f93e99bac6e 78 case 110: //sol avant
Villanut 45:4f93e99bac6e 79 SendRawId(SOL_AVANT);
Sitkah 30:a1e37af4bbde 80 break;
Villanut 45:4f93e99bac6e 81 case 111: //sol arriere
Villanut 45:4f93e99bac6e 82 SendRawId(SOL_ARRIERE);
Sitkah 34:6aa4b46b102e 83 break;
Artiom 46:a9b6bcb30b1c 84 case 112: //sol avant relache
Artiom 46:a9b6bcb30b1c 85 SendRawId(SOL_AVANT_RELACHE);
Artiom 46:a9b6bcb30b1c 86 break;
Artiom 46:a9b6bcb30b1c 87 case 113: //sol arriere relache
Artiom 46:a9b6bcb30b1c 88 SendRawId(SOL_ARRIERE_RELACHE);
Artiom 46:a9b6bcb30b1c 89 break;
Artiom 84:44d6cd2cab99 90 case 114://relache les 3 ventouses avants
Artiom 52:a47350923b5e 91 SendRawId(AVANT_RELACHE);
Artiom 52:a47350923b5e 92 break;
Artiom 52:a47350923b5e 93
Artiom 84:44d6cd2cab99 94 case 115://relache les 3 ventouses arrieres
Artiom 52:a47350923b5e 95 SendRawId(ARRIERE_RELACHE);
Artiom 52:a47350923b5e 96 break;
Artiom 52:a47350923b5e 97
Artiom 84:44d6cd2cab99 98 case 116://relache une pompe
kyxstark 59:500271ac0881 99 unsigned char arg_tempo;
Artiom 84:44d6cd2cab99 100 if(InversStrat == 1) {
Artiom 84:44d6cd2cab99 101 switch(arg1) {
kyxstark 59:500271ac0881 102 case AV_DROIT:
kyxstark 59:500271ac0881 103 arg_tempo = AV_GAUCHE;
kyxstark 59:500271ac0881 104 break;
kyxstark 59:500271ac0881 105 case AV_GAUCHE:
kyxstark 59:500271ac0881 106 arg_tempo = AV_DROIT;
kyxstark 59:500271ac0881 107 break;
kyxstark 59:500271ac0881 108 case AR_DROIT:
kyxstark 59:500271ac0881 109 arg_tempo = AR_GAUCHE;
kyxstark 59:500271ac0881 110 break;
kyxstark 59:500271ac0881 111 case AR_GAUCHE:
kyxstark 59:500271ac0881 112 arg_tempo = AR_DROIT;
kyxstark 59:500271ac0881 113 break;
kyxstark 59:500271ac0881 114 default :
kyxstark 59:500271ac0881 115 arg_tempo =(unsigned char)arg1;
kyxstark 59:500271ac0881 116 break;
kyxstark 59:500271ac0881 117 }
Artiom 84:44d6cd2cab99 118
Artiom 84:44d6cd2cab99 119 } else arg_tempo =(unsigned char)arg1;
Artiom 52:a47350923b5e 120 SendMsgCan(HACHEUR_RELEASE_ATOM, &arg_tempo,1);
Artiom 52:a47350923b5e 121 waitingAckFrom = 0;
Artiom 52:a47350923b5e 122 waitingAckID =0;
Artiom 52:a47350923b5e 123 break;
Artiom 52:a47350923b5e 124 case 117:
Artiom 52:a47350923b5e 125 SendRawId(RECROQUEVILLER);
Artiom 54:8996a5b18d9b 126 break;
Artiom 53:e96acb11a51f 127 case 118:
Artiom 53:e96acb11a51f 128 SendRawId(VENTOUSE_AV_CENTRE_BALANCE);
Artiom 53:e96acb11a51f 129 break;
Artiom 54:8996a5b18d9b 130 case 119:
Artiom 53:e96acb11a51f 131 SendRawId(VENTOUSE_AR_CENTRE_BALANCE);
Artiom 53:e96acb11a51f 132 break;
Artiom 54:8996a5b18d9b 133 case 120:
Artiom 54:8996a5b18d9b 134 SendRawId(ACCELERATEUR_INSERTION_AVANT_GAUCHE);
Artiom 54:8996a5b18d9b 135 break;
Artiom 84:44d6cd2cab99 136
Artiom 54:8996a5b18d9b 137 case 121:
kyxstark 55:1e3dab1f90f4 138 SendRawId(ACCELERATEUR_INSERTION_ARRIERE_GAUCHE);
Artiom 54:8996a5b18d9b 139 break;
Artiom 84:44d6cd2cab99 140
Sitkah 38:76f886a1c8e6 141 case 150:
Sitkah 38:76f886a1c8e6 142 SCORE_PR+=arg1;
Sitkah 38:76f886a1c8e6 143 liaison_Tx.envoyer_short(0x30,SCORE_PR);
Sitkah 38:76f886a1c8e6 144 waitingAckFrom = 0;
Sitkah 38:76f886a1c8e6 145 waitingAckID = 0;
Sitkah 38:76f886a1c8e6 146 break;
Artiom 46:a9b6bcb30b1c 147
Artiom 46:a9b6bcb30b1c 148
ClementBreteau 18:cc5fec34ed9c 149 case 200 :
Sitkah 30:a1e37af4bbde 150 SendRawId(DATA_TELEMETRE);
Sitkah 30:a1e37af4bbde 151 /*telemetreDistance = dataTelemetre();
ClementBreteau 18:cc5fec34ed9c 152 wait_ms(1);
ClementBreteau 18:cc5fec34ed9c 153 telemetreDistance = dataTelemetre();
Sitkah 30:a1e37af4bbde 154 telemetreDistance = telemetreDistance - 170;*/
Artiom 46:a9b6bcb30b1c 155 break;
Artiom 46:a9b6bcb30b1c 156
ClementBreteau 18:cc5fec34ed9c 157 case 201 :
Artiom 80:545a9bf561e1 158 SendRawId(0x99);//
ClementBreteau 18:cc5fec34ed9c 159 retour = 2;
Artiom 46:a9b6bcb30b1c 160 break;
Artiom 46:a9b6bcb30b1c 161
Artiom 84:44d6cd2cab99 162
Artiom 67:96f914f92d2d 163 case 11://0 Désactiver le stop,1 Activer le stop saut de strat,2 Activer le stop avec evitement
Artiom 67:96f914f92d2d 164 isStopEnable =(unsigned char) arg1;
Artiom 84:44d6cd2cab99 165 // SendMsgCan(0x5BC, &isStopEnable,1);
Artiom 67:96f914f92d2d 166 waitingAckFrom = 0;
Artiom 67:96f914f92d2d 167 waitingAckID =0;
Artiom 46:a9b6bcb30b1c 168 break;
Artiom 84:44d6cd2cab99 169
Artiom 84:44d6cd2cab99 170
Artiom 84:44d6cd2cab99 171
antbig 12:14729d584500 172 case 20://Désactiver l'asservissement
antbig 12:14729d584500 173 setAsservissementEtat(0);
Artiom 46:a9b6bcb30b1c 174 break;
Artiom 84:44d6cd2cab99 175
antbig 12:14729d584500 176 case 21://Activer l'asservissement
antbig 12:14729d584500 177 setAsservissementEtat(1);
Artiom 46:a9b6bcb30b1c 178 break;
Artiom 46:a9b6bcb30b1c 179
Sitkah 34:6aa4b46b102e 180 case 22://Changer la vitesse du robot
kyxstark 74:cdea2998f0b1 181 SendSpeed(arg1);//,(unsigned short)arg2, (unsigned short)arg2);
ClementBreteau 18:cc5fec34ed9c 182 wait_us(200);
antbig 28:acd18776ed2d 183 waitingAckFrom = 0;
antbig 28:acd18776ed2d 184 waitingAckID = 0;
Artiom 46:a9b6bcb30b1c 185 break;
kyxstark 74:cdea2998f0b1 186 case 23:
kyxstark 74:cdea2998f0b1 187 SendAccel(arg1,(unsigned short)arg2);//,(unsigned short)arg2, (unsigned short)arg2);
kyxstark 74:cdea2998f0b1 188 wait_us(200);
kyxstark 74:cdea2998f0b1 189 waitingAckFrom = 0;
kyxstark 74:cdea2998f0b1 190 waitingAckID = 0;
kyxstark 74:cdea2998f0b1 191 break;
Artiom 84:44d6cd2cab99 192
Artiom 46:a9b6bcb30b1c 193
Artiom 46:a9b6bcb30b1c 194 case 19: // CHANGER LA VITESSE + DECELERATION
Artiom 50:a5361ffeefc8 195 //SendSpeedDecel(arg1,(unsigned short) arg2);
antbig 28:acd18776ed2d 196 wait_us(200);
antbig 28:acd18776ed2d 197 waitingAckFrom = 0;
antbig 28:acd18776ed2d 198 waitingAckID =0;
Artiom 46:a9b6bcb30b1c 199 break;
Artiom 46:a9b6bcb30b1c 200
ClementBreteau 16:7321fb3bb396 201 case 30://Action tempo
Sitkah 34:6aa4b46b102e 202 wait_ms(arg1);
Villanut 75:1db1b929f13d 203 waitingAckFrom = 0;
Villanut 75:1db1b929f13d 204 waitingAckID = 0;
Artiom 46:a9b6bcb30b1c 205 break;
Artiom 46:a9b6bcb30b1c 206
antbig 3:19f2285a4757 207 default:
ClementBreteau 18:cc5fec34ed9c 208 retour = 0;//L'action n'existe pas, il faut utiliser le CAN
Artiom 46:a9b6bcb30b1c 209
antbig 3:19f2285a4757 210 }
ClementBreteau 18:cc5fec34ed9c 211 return retour;//L'action est spécifique.
Artiom 46:a9b6bcb30b1c 212
antbig 3:19f2285a4757 213 }
antbig 3:19f2285a4757 214
antbig 3:19f2285a4757 215
antbig 4:88431b537477 216
antbig 12:14729d584500 217 /****************************************************************************************/
antbig 12:14729d584500 218 /* FUNCTION NAME: needToStop */
antbig 12:14729d584500 219 /* DESCRIPTION : Savoir si il faut autoriser le stop du robot via balise */
antbig 12:14729d584500 220 /****************************************************************************************/
antbig 12:14729d584500 221 unsigned char needToStop(void)
antbig 12:14729d584500 222 {
antbig 12:14729d584500 223 return isStopEnable;
antbig 12:14729d584500 224 }
antbig 12:14729d584500 225
antbig 12:14729d584500 226 /****************************************************************************************/
antbig 12:14729d584500 227 /* FUNCTION NAME: doBeforeEndAction */
antbig 12:14729d584500 228 /* DESCRIPTION : Terminer les actions du robot 1s avant la fin du match */
antbig 12:14729d584500 229 /****************************************************************************************/
antbig 12:14729d584500 230 void doBeforeEndAction(void)
antbig 12:14729d584500 231 {
Artiom 46:a9b6bcb30b1c 232
antbig 12:14729d584500 233 }
antbig 12:14729d584500 234
antbig 3:19f2285a4757 235 #endif