CRAC Team / Mbed 2 deprecated 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:
74:cdea2998f0b1
;

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