Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Robots/Strategie_small.cpp@83:23e04b85ae06, 2019-05-31 (annotated)
- Committer:
- Artiom
- Date:
- Fri May 31 05:02:55 2019 +0000
- Revision:
- 83:23e04b85ae06
- Parent:
- 80:545a9bf561e1
- Child:
- 84:44d6cd2cab99
ajout gold relache av Gr; ; test reprise de courbe ; cote jaune ok; cote violet pas du tout ok
Who changed what in which revision?
User | Revision | Line number | New 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 | 83:23e04b85ae06 | 66 | if(InversStrat == 1) |
Artiom | 83:23e04b85ae06 | 67 | { |
Artiom | 83:23e04b85ae06 | 68 | y = 3000 - arg2; |
Artiom | 83:23e04b85ae06 | 69 | } |
Artiom | 83:23e04b85ae06 | 70 | else |
Artiom | 83:23e04b85ae06 | 71 | { |
Artiom | 83:23e04b85ae06 | 72 | y = arg2; |
Artiom | 83:23e04b85ae06 | 73 | } |
Artiom | 83:23e04b85ae06 | 74 | |
Artiom | 83:23e04b85ae06 | 75 | Send2Short(GOLDENIUM_AVANT, x, y); |
Sitkah | 30:a1e37af4bbde | 76 | break; |
Villanut | 45:4f93e99bac6e | 77 | case 109: //goldenium arriere |
Artiom | 78:c0533a36da8f | 78 | x=arg1; |
Artiom | 78:c0533a36da8f | 79 | y=arg2; |
Artiom | 78:c0533a36da8f | 80 | Send2Short(GOLDENIUM_ARRIERE, x,y); |
Sitkah | 30:a1e37af4bbde | 81 | break; |
Villanut | 45:4f93e99bac6e | 82 | case 110: //sol avant |
Villanut | 45:4f93e99bac6e | 83 | SendRawId(SOL_AVANT); |
Sitkah | 30:a1e37af4bbde | 84 | break; |
Villanut | 45:4f93e99bac6e | 85 | case 111: //sol arriere |
Villanut | 45:4f93e99bac6e | 86 | SendRawId(SOL_ARRIERE); |
Sitkah | 34:6aa4b46b102e | 87 | break; |
Artiom | 46:a9b6bcb30b1c | 88 | case 112: //sol avant relache |
Artiom | 46:a9b6bcb30b1c | 89 | SendRawId(SOL_AVANT_RELACHE); |
Artiom | 46:a9b6bcb30b1c | 90 | break; |
Artiom | 46:a9b6bcb30b1c | 91 | case 113: //sol arriere relache |
Artiom | 46:a9b6bcb30b1c | 92 | SendRawId(SOL_ARRIERE_RELACHE); |
Artiom | 46:a9b6bcb30b1c | 93 | break; |
Artiom | 52:a47350923b5e | 94 | case 114: |
Artiom | 52:a47350923b5e | 95 | SendRawId(AVANT_RELACHE); |
Artiom | 52:a47350923b5e | 96 | break; |
Artiom | 52:a47350923b5e | 97 | |
Artiom | 52:a47350923b5e | 98 | case 115: |
Artiom | 52:a47350923b5e | 99 | SendRawId(ARRIERE_RELACHE); |
Artiom | 52:a47350923b5e | 100 | break; |
Artiom | 52:a47350923b5e | 101 | |
Artiom | 52:a47350923b5e | 102 | case 116: |
kyxstark | 59:500271ac0881 | 103 | unsigned char arg_tempo; |
kyxstark | 59:500271ac0881 | 104 | if(InversStrat == 1) |
kyxstark | 59:500271ac0881 | 105 | { |
kyxstark | 59:500271ac0881 | 106 | switch(arg1){ |
kyxstark | 59:500271ac0881 | 107 | case AV_DROIT: |
kyxstark | 59:500271ac0881 | 108 | arg_tempo = AV_GAUCHE; |
kyxstark | 59:500271ac0881 | 109 | break; |
kyxstark | 59:500271ac0881 | 110 | case AV_GAUCHE: |
kyxstark | 59:500271ac0881 | 111 | arg_tempo = AV_DROIT; |
kyxstark | 59:500271ac0881 | 112 | break; |
kyxstark | 59:500271ac0881 | 113 | case AR_DROIT: |
kyxstark | 59:500271ac0881 | 114 | arg_tempo = AR_GAUCHE; |
kyxstark | 59:500271ac0881 | 115 | break; |
kyxstark | 59:500271ac0881 | 116 | case AR_GAUCHE: |
kyxstark | 59:500271ac0881 | 117 | arg_tempo = AR_DROIT; |
kyxstark | 59:500271ac0881 | 118 | break; |
kyxstark | 59:500271ac0881 | 119 | default : |
kyxstark | 59:500271ac0881 | 120 | arg_tempo =(unsigned char)arg1; |
kyxstark | 59:500271ac0881 | 121 | break; |
kyxstark | 59:500271ac0881 | 122 | } |
kyxstark | 59:500271ac0881 | 123 | |
kyxstark | 59:500271ac0881 | 124 | } |
kyxstark | 59:500271ac0881 | 125 | else arg_tempo =(unsigned char)arg1; |
Artiom | 52:a47350923b5e | 126 | SendMsgCan(HACHEUR_RELEASE_ATOM, &arg_tempo,1); |
Artiom | 52:a47350923b5e | 127 | waitingAckFrom = 0; |
Artiom | 52:a47350923b5e | 128 | waitingAckID =0; |
Artiom | 52:a47350923b5e | 129 | break; |
Artiom | 52:a47350923b5e | 130 | case 117: |
Artiom | 52:a47350923b5e | 131 | SendRawId(RECROQUEVILLER); |
Artiom | 54:8996a5b18d9b | 132 | break; |
Artiom | 53:e96acb11a51f | 133 | case 118: |
Artiom | 53:e96acb11a51f | 134 | SendRawId(VENTOUSE_AV_CENTRE_BALANCE); |
Artiom | 53:e96acb11a51f | 135 | break; |
Artiom | 54:8996a5b18d9b | 136 | case 119: |
Artiom | 53:e96acb11a51f | 137 | SendRawId(VENTOUSE_AR_CENTRE_BALANCE); |
Artiom | 53:e96acb11a51f | 138 | break; |
Artiom | 54:8996a5b18d9b | 139 | case 120: |
Artiom | 54:8996a5b18d9b | 140 | SendRawId(ACCELERATEUR_INSERTION_AVANT_GAUCHE); |
Artiom | 54:8996a5b18d9b | 141 | break; |
Artiom | 60:97bf2bdd51cc | 142 | |
Artiom | 54:8996a5b18d9b | 143 | case 121: |
kyxstark | 55:1e3dab1f90f4 | 144 | SendRawId(ACCELERATEUR_INSERTION_ARRIERE_GAUCHE); |
Artiom | 54:8996a5b18d9b | 145 | break; |
Artiom | 60:97bf2bdd51cc | 146 | |
Sitkah | 38:76f886a1c8e6 | 147 | case 150: |
Sitkah | 38:76f886a1c8e6 | 148 | SCORE_PR+=arg1; |
Sitkah | 38:76f886a1c8e6 | 149 | liaison_Tx.envoyer_short(0x30,SCORE_PR); |
Sitkah | 38:76f886a1c8e6 | 150 | waitingAckFrom = 0; |
Sitkah | 38:76f886a1c8e6 | 151 | waitingAckID = 0; |
Sitkah | 38:76f886a1c8e6 | 152 | break; |
Artiom | 46:a9b6bcb30b1c | 153 | |
Artiom | 46:a9b6bcb30b1c | 154 | |
ClementBreteau | 18:cc5fec34ed9c | 155 | case 200 : |
Sitkah | 30:a1e37af4bbde | 156 | SendRawId(DATA_TELEMETRE); |
Sitkah | 30:a1e37af4bbde | 157 | /*telemetreDistance = dataTelemetre(); |
ClementBreteau | 18:cc5fec34ed9c | 158 | wait_ms(1); |
ClementBreteau | 18:cc5fec34ed9c | 159 | telemetreDistance = dataTelemetre(); |
Sitkah | 30:a1e37af4bbde | 160 | telemetreDistance = telemetreDistance - 170;*/ |
Artiom | 46:a9b6bcb30b1c | 161 | break; |
Artiom | 46:a9b6bcb30b1c | 162 | |
ClementBreteau | 18:cc5fec34ed9c | 163 | case 201 : |
Artiom | 80:545a9bf561e1 | 164 | SendRawId(0x99);// |
ClementBreteau | 18:cc5fec34ed9c | 165 | retour = 2; |
Artiom | 46:a9b6bcb30b1c | 166 | break; |
Artiom | 46:a9b6bcb30b1c | 167 | |
Artiom | 67:96f914f92d2d | 168 | |
Artiom | 67:96f914f92d2d | 169 | case 11://0 Désactiver le stop,1 Activer le stop saut de strat,2 Activer le stop avec evitement |
Artiom | 67:96f914f92d2d | 170 | isStopEnable =(unsigned char) arg1; |
Artiom | 83:23e04b85ae06 | 171 | // SendMsgCan(0x5BC, &isStopEnable,1); |
Artiom | 67:96f914f92d2d | 172 | waitingAckFrom = 0; |
Artiom | 67:96f914f92d2d | 173 | waitingAckID =0; |
Artiom | 46:a9b6bcb30b1c | 174 | break; |
Artiom | 62:c4863b4b2543 | 175 | |
Artiom | 67:96f914f92d2d | 176 | |
Artiom | 62:c4863b4b2543 | 177 | |
antbig | 12:14729d584500 | 178 | case 20://Désactiver l'asservissement |
antbig | 12:14729d584500 | 179 | setAsservissementEtat(0); |
Artiom | 46:a9b6bcb30b1c | 180 | break; |
Artiom | 67:96f914f92d2d | 181 | |
antbig | 12:14729d584500 | 182 | case 21://Activer l'asservissement |
antbig | 12:14729d584500 | 183 | setAsservissementEtat(1); |
Artiom | 46:a9b6bcb30b1c | 184 | break; |
Artiom | 46:a9b6bcb30b1c | 185 | |
Sitkah | 34:6aa4b46b102e | 186 | case 22://Changer la vitesse du robot |
kyxstark | 74:cdea2998f0b1 | 187 | SendSpeed(arg1);//,(unsigned short)arg2, (unsigned short)arg2); |
ClementBreteau | 18:cc5fec34ed9c | 188 | wait_us(200); |
antbig | 28:acd18776ed2d | 189 | waitingAckFrom = 0; |
antbig | 28:acd18776ed2d | 190 | waitingAckID = 0; |
Artiom | 46:a9b6bcb30b1c | 191 | break; |
kyxstark | 74:cdea2998f0b1 | 192 | case 23: |
kyxstark | 74:cdea2998f0b1 | 193 | SendAccel(arg1,(unsigned short)arg2);//,(unsigned short)arg2, (unsigned short)arg2); |
kyxstark | 74:cdea2998f0b1 | 194 | wait_us(200); |
kyxstark | 74:cdea2998f0b1 | 195 | waitingAckFrom = 0; |
kyxstark | 74:cdea2998f0b1 | 196 | waitingAckID = 0; |
kyxstark | 74:cdea2998f0b1 | 197 | break; |
kyxstark | 74:cdea2998f0b1 | 198 | |
Artiom | 46:a9b6bcb30b1c | 199 | |
Artiom | 46:a9b6bcb30b1c | 200 | case 19: // CHANGER LA VITESSE + DECELERATION |
Artiom | 50:a5361ffeefc8 | 201 | //SendSpeedDecel(arg1,(unsigned short) arg2); |
antbig | 28:acd18776ed2d | 202 | wait_us(200); |
antbig | 28:acd18776ed2d | 203 | waitingAckFrom = 0; |
antbig | 28:acd18776ed2d | 204 | waitingAckID =0; |
Artiom | 46:a9b6bcb30b1c | 205 | break; |
Artiom | 46:a9b6bcb30b1c | 206 | |
ClementBreteau | 16:7321fb3bb396 | 207 | case 30://Action tempo |
Sitkah | 34:6aa4b46b102e | 208 | wait_ms(arg1); |
Villanut | 75:1db1b929f13d | 209 | waitingAckFrom = 0; |
Villanut | 75:1db1b929f13d | 210 | waitingAckID = 0; |
Artiom | 46:a9b6bcb30b1c | 211 | break; |
Artiom | 46:a9b6bcb30b1c | 212 | |
antbig | 3:19f2285a4757 | 213 | default: |
ClementBreteau | 18:cc5fec34ed9c | 214 | retour = 0;//L'action n'existe pas, il faut utiliser le CAN |
Artiom | 46:a9b6bcb30b1c | 215 | |
antbig | 3:19f2285a4757 | 216 | } |
ClementBreteau | 18:cc5fec34ed9c | 217 | return retour;//L'action est spécifique. |
Artiom | 46:a9b6bcb30b1c | 218 | |
antbig | 3:19f2285a4757 | 219 | } |
antbig | 3:19f2285a4757 | 220 | |
antbig | 3:19f2285a4757 | 221 | |
antbig | 4:88431b537477 | 222 | |
antbig | 12:14729d584500 | 223 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 224 | /* FUNCTION NAME: needToStop */ |
antbig | 12:14729d584500 | 225 | /* DESCRIPTION : Savoir si il faut autoriser le stop du robot via balise */ |
antbig | 12:14729d584500 | 226 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 227 | unsigned char needToStop(void) |
antbig | 12:14729d584500 | 228 | { |
antbig | 12:14729d584500 | 229 | return isStopEnable; |
antbig | 12:14729d584500 | 230 | } |
antbig | 12:14729d584500 | 231 | |
antbig | 12:14729d584500 | 232 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 233 | /* FUNCTION NAME: doBeforeEndAction */ |
antbig | 12:14729d584500 | 234 | /* DESCRIPTION : Terminer les actions du robot 1s avant la fin du match */ |
antbig | 12:14729d584500 | 235 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 236 | void doBeforeEndAction(void) |
antbig | 12:14729d584500 | 237 | { |
Artiom | 46:a9b6bcb30b1c | 238 | |
antbig | 12:14729d584500 | 239 | } |
antbig | 12:14729d584500 | 240 | |
antbig | 3:19f2285a4757 | 241 | #endif |