CRAC Team / Mbed 2 deprecated carte_strategie_2019

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Committer:
Artiom
Date:
Tue May 28 20:37:59 2019 +0000
Revision:
78:c0533a36da8f
Parent:
75:1db1b929f13d
Child:
80:545a9bf561e1
GR conte ses points tout seul

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 67:96f914f92d2d 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 78:c0533a36da8f 65 x=arg1;
Artiom 78:c0533a36da8f 66 y=arg2;
Artiom 78:c0533a36da8f 67 Send2Short(GOLDENIUM_AVANT, x,y);
Sitkah 30:a1e37af4bbde 68 break;
Villanut 45:4f93e99bac6e 69 case 109: //goldenium arriere
Artiom 78:c0533a36da8f 70 x=arg1;
Artiom 78:c0533a36da8f 71 y=arg2;
Artiom 78:c0533a36da8f 72 Send2Short(GOLDENIUM_ARRIERE, x,y);
Sitkah 30:a1e37af4bbde 73 break;
Villanut 45:4f93e99bac6e 74 case 110: //sol avant
Villanut 45:4f93e99bac6e 75 SendRawId(SOL_AVANT);
Sitkah 30:a1e37af4bbde 76 break;
Villanut 45:4f93e99bac6e 77 case 111: //sol arriere
Villanut 45:4f93e99bac6e 78 SendRawId(SOL_ARRIERE);
Sitkah 34:6aa4b46b102e 79 break;
Artiom 46:a9b6bcb30b1c 80 case 112: //sol avant relache
Artiom 46:a9b6bcb30b1c 81 SendRawId(SOL_AVANT_RELACHE);
Artiom 46:a9b6bcb30b1c 82 break;
Artiom 46:a9b6bcb30b1c 83 case 113: //sol arriere relache
Artiom 46:a9b6bcb30b1c 84 SendRawId(SOL_ARRIERE_RELACHE);
Artiom 46:a9b6bcb30b1c 85 break;
Artiom 52:a47350923b5e 86 case 114:
Artiom 52:a47350923b5e 87 SendRawId(AVANT_RELACHE);
Artiom 52:a47350923b5e 88 break;
Artiom 52:a47350923b5e 89
Artiom 52:a47350923b5e 90 case 115:
Artiom 52:a47350923b5e 91 SendRawId(ARRIERE_RELACHE);
Artiom 52:a47350923b5e 92 break;
Artiom 52:a47350923b5e 93
Artiom 52:a47350923b5e 94 case 116:
kyxstark 59:500271ac0881 95 unsigned char arg_tempo;
kyxstark 59:500271ac0881 96 if(InversStrat == 1)
kyxstark 59:500271ac0881 97 {
kyxstark 59:500271ac0881 98 switch(arg1){
kyxstark 59:500271ac0881 99 case AV_DROIT:
kyxstark 59:500271ac0881 100 arg_tempo = AV_GAUCHE;
kyxstark 59:500271ac0881 101 break;
kyxstark 59:500271ac0881 102 case AV_GAUCHE:
kyxstark 59:500271ac0881 103 arg_tempo = AV_DROIT;
kyxstark 59:500271ac0881 104 break;
kyxstark 59:500271ac0881 105 case AR_DROIT:
kyxstark 59:500271ac0881 106 arg_tempo = AR_GAUCHE;
kyxstark 59:500271ac0881 107 break;
kyxstark 59:500271ac0881 108 case AR_GAUCHE:
kyxstark 59:500271ac0881 109 arg_tempo = AR_DROIT;
kyxstark 59:500271ac0881 110 break;
kyxstark 59:500271ac0881 111 default :
kyxstark 59:500271ac0881 112 arg_tempo =(unsigned char)arg1;
kyxstark 59:500271ac0881 113 break;
kyxstark 59:500271ac0881 114 }
kyxstark 59:500271ac0881 115
kyxstark 59:500271ac0881 116 }
kyxstark 59:500271ac0881 117 else arg_tempo =(unsigned char)arg1;
Artiom 52:a47350923b5e 118 SendMsgCan(HACHEUR_RELEASE_ATOM, &arg_tempo,1);
Artiom 52:a47350923b5e 119 waitingAckFrom = 0;
Artiom 52:a47350923b5e 120 waitingAckID =0;
Artiom 52:a47350923b5e 121 break;
Artiom 52:a47350923b5e 122 case 117:
Artiom 52:a47350923b5e 123 SendRawId(RECROQUEVILLER);
Artiom 54:8996a5b18d9b 124 break;
Artiom 53:e96acb11a51f 125 case 118:
Artiom 53:e96acb11a51f 126 SendRawId(VENTOUSE_AV_CENTRE_BALANCE);
Artiom 53:e96acb11a51f 127 break;
Artiom 54:8996a5b18d9b 128 case 119:
Artiom 53:e96acb11a51f 129 SendRawId(VENTOUSE_AR_CENTRE_BALANCE);
Artiom 53:e96acb11a51f 130 break;
Artiom 54:8996a5b18d9b 131 case 120:
Artiom 54:8996a5b18d9b 132 SendRawId(ACCELERATEUR_INSERTION_AVANT_GAUCHE);
Artiom 54:8996a5b18d9b 133 break;
Artiom 60:97bf2bdd51cc 134
Artiom 54:8996a5b18d9b 135 case 121:
kyxstark 55:1e3dab1f90f4 136 SendRawId(ACCELERATEUR_INSERTION_ARRIERE_GAUCHE);
Artiom 54:8996a5b18d9b 137 break;
Artiom 60:97bf2bdd51cc 138
Sitkah 38:76f886a1c8e6 139 case 150:
Sitkah 38:76f886a1c8e6 140 SCORE_PR+=arg1;
Sitkah 38:76f886a1c8e6 141 liaison_Tx.envoyer_short(0x30,SCORE_PR);
Sitkah 38:76f886a1c8e6 142 waitingAckFrom = 0;
Sitkah 38:76f886a1c8e6 143 waitingAckID = 0;
Sitkah 38:76f886a1c8e6 144 break;
Artiom 46:a9b6bcb30b1c 145
Artiom 46:a9b6bcb30b1c 146
ClementBreteau 18:cc5fec34ed9c 147 case 200 :
Sitkah 30:a1e37af4bbde 148 SendRawId(DATA_TELEMETRE);
Sitkah 30:a1e37af4bbde 149 /*telemetreDistance = dataTelemetre();
ClementBreteau 18:cc5fec34ed9c 150 wait_ms(1);
ClementBreteau 18:cc5fec34ed9c 151 telemetreDistance = dataTelemetre();
Sitkah 30:a1e37af4bbde 152 telemetreDistance = telemetreDistance - 170;*/
Artiom 46:a9b6bcb30b1c 153 break;
Artiom 46:a9b6bcb30b1c 154
ClementBreteau 18:cc5fec34ed9c 155 case 201 :
Sitkah 30:a1e37af4bbde 156 SendRawId(0x99);
ClementBreteau 18:cc5fec34ed9c 157 retour = 2;
Artiom 46:a9b6bcb30b1c 158 break;
Artiom 46:a9b6bcb30b1c 159
Artiom 67:96f914f92d2d 160
Artiom 67:96f914f92d2d 161 case 11://0 Désactiver le stop,1 Activer le stop saut de strat,2 Activer le stop avec evitement
Artiom 67:96f914f92d2d 162 isStopEnable =(unsigned char) arg1;
Artiom 67:96f914f92d2d 163 SendMsgCan(0x5BC, &isStopEnable,1);
Artiom 67:96f914f92d2d 164 waitingAckFrom = 0;
Artiom 67:96f914f92d2d 165 waitingAckID =0;
Artiom 46:a9b6bcb30b1c 166 break;
Artiom 62:c4863b4b2543 167
Artiom 67:96f914f92d2d 168
Artiom 62:c4863b4b2543 169
antbig 12:14729d584500 170 case 20://Désactiver l'asservissement
antbig 12:14729d584500 171 setAsservissementEtat(0);
Artiom 46:a9b6bcb30b1c 172 break;
Artiom 67:96f914f92d2d 173
antbig 12:14729d584500 174 case 21://Activer l'asservissement
antbig 12:14729d584500 175 setAsservissementEtat(1);
Artiom 46:a9b6bcb30b1c 176 break;
Artiom 46:a9b6bcb30b1c 177
Sitkah 34:6aa4b46b102e 178 case 22://Changer la vitesse du robot
kyxstark 74:cdea2998f0b1 179 SendSpeed(arg1);//,(unsigned short)arg2, (unsigned short)arg2);
ClementBreteau 18:cc5fec34ed9c 180 wait_us(200);
antbig 28:acd18776ed2d 181 waitingAckFrom = 0;
antbig 28:acd18776ed2d 182 waitingAckID = 0;
Artiom 46:a9b6bcb30b1c 183 break;
kyxstark 74:cdea2998f0b1 184 case 23:
kyxstark 74:cdea2998f0b1 185 SendAccel(arg1,(unsigned short)arg2);//,(unsigned short)arg2, (unsigned short)arg2);
kyxstark 74:cdea2998f0b1 186 wait_us(200);
kyxstark 74:cdea2998f0b1 187 waitingAckFrom = 0;
kyxstark 74:cdea2998f0b1 188 waitingAckID = 0;
kyxstark 74:cdea2998f0b1 189 break;
kyxstark 74:cdea2998f0b1 190
Artiom 46:a9b6bcb30b1c 191
Artiom 46:a9b6bcb30b1c 192 case 19: // CHANGER LA VITESSE + DECELERATION
Artiom 50:a5361ffeefc8 193 //SendSpeedDecel(arg1,(unsigned short) arg2);
antbig 28:acd18776ed2d 194 wait_us(200);
antbig 28:acd18776ed2d 195 waitingAckFrom = 0;
antbig 28:acd18776ed2d 196 waitingAckID =0;
Artiom 46:a9b6bcb30b1c 197 break;
Artiom 46:a9b6bcb30b1c 198
ClementBreteau 16:7321fb3bb396 199 case 30://Action tempo
Sitkah 34:6aa4b46b102e 200 wait_ms(arg1);
Villanut 75:1db1b929f13d 201 waitingAckFrom = 0;
Villanut 75:1db1b929f13d 202 waitingAckID = 0;
Artiom 46:a9b6bcb30b1c 203 break;
Artiom 46:a9b6bcb30b1c 204
antbig 3:19f2285a4757 205 default:
ClementBreteau 18:cc5fec34ed9c 206 retour = 0;//L'action n'existe pas, il faut utiliser le CAN
Artiom 46:a9b6bcb30b1c 207
antbig 3:19f2285a4757 208 }
ClementBreteau 18:cc5fec34ed9c 209 return retour;//L'action est spécifique.
Artiom 46:a9b6bcb30b1c 210
antbig 3:19f2285a4757 211 }
antbig 3:19f2285a4757 212
antbig 3:19f2285a4757 213
antbig 4:88431b537477 214
antbig 12:14729d584500 215 /****************************************************************************************/
antbig 12:14729d584500 216 /* FUNCTION NAME: needToStop */
antbig 12:14729d584500 217 /* DESCRIPTION : Savoir si il faut autoriser le stop du robot via balise */
antbig 12:14729d584500 218 /****************************************************************************************/
antbig 12:14729d584500 219 unsigned char needToStop(void)
antbig 12:14729d584500 220 {
antbig 12:14729d584500 221 return isStopEnable;
antbig 12:14729d584500 222 }
antbig 12:14729d584500 223
antbig 12:14729d584500 224 /****************************************************************************************/
antbig 12:14729d584500 225 /* FUNCTION NAME: doBeforeEndAction */
antbig 12:14729d584500 226 /* DESCRIPTION : Terminer les actions du robot 1s avant la fin du match */
antbig 12:14729d584500 227 /****************************************************************************************/
antbig 12:14729d584500 228 void doBeforeEndAction(void)
antbig 12:14729d584500 229 {
Artiom 46:a9b6bcb30b1c 230
antbig 12:14729d584500 231 }
antbig 12:14729d584500 232
antbig 3:19f2285a4757 233 #endif