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@75:1db1b929f13d, 2019-05-27 (annotated)
- Committer:
- Villanut
- Date:
- Mon May 27 12:38:21 2019 +0000
- Revision:
- 75:1db1b929f13d
- Parent:
- 74:cdea2998f0b1
- Child:
- 78:c0533a36da8f
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; |
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 |
kyxstark | 74:cdea2998f0b1 | 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; |
kyxstark | 74:cdea2998f0b1 | 178 | case 23: |
kyxstark | 74:cdea2998f0b1 | 179 | SendAccel(arg1,(unsigned short)arg2);//,(unsigned short)arg2, (unsigned short)arg2); |
kyxstark | 74:cdea2998f0b1 | 180 | wait_us(200); |
kyxstark | 74:cdea2998f0b1 | 181 | waitingAckFrom = 0; |
kyxstark | 74:cdea2998f0b1 | 182 | waitingAckID = 0; |
kyxstark | 74:cdea2998f0b1 | 183 | break; |
kyxstark | 74:cdea2998f0b1 | 184 | |
Artiom | 46:a9b6bcb30b1c | 185 | |
Artiom | 46:a9b6bcb30b1c | 186 | case 19: // CHANGER LA VITESSE + DECELERATION |
Artiom | 50:a5361ffeefc8 | 187 | //SendSpeedDecel(arg1,(unsigned short) arg2); |
antbig | 28:acd18776ed2d | 188 | wait_us(200); |
antbig | 28:acd18776ed2d | 189 | waitingAckFrom = 0; |
antbig | 28:acd18776ed2d | 190 | waitingAckID =0; |
Artiom | 46:a9b6bcb30b1c | 191 | break; |
Artiom | 46:a9b6bcb30b1c | 192 | |
ClementBreteau | 16:7321fb3bb396 | 193 | case 30://Action tempo |
Sitkah | 34:6aa4b46b102e | 194 | wait_ms(arg1); |
Villanut | 75:1db1b929f13d | 195 | waitingAckFrom = 0; |
Villanut | 75:1db1b929f13d | 196 | waitingAckID = 0; |
Artiom | 46:a9b6bcb30b1c | 197 | break; |
Artiom | 46:a9b6bcb30b1c | 198 | |
antbig | 3:19f2285a4757 | 199 | default: |
ClementBreteau | 18:cc5fec34ed9c | 200 | retour = 0;//L'action n'existe pas, il faut utiliser le CAN |
Artiom | 46:a9b6bcb30b1c | 201 | |
antbig | 3:19f2285a4757 | 202 | } |
ClementBreteau | 18:cc5fec34ed9c | 203 | return retour;//L'action est spécifique. |
Artiom | 46:a9b6bcb30b1c | 204 | |
antbig | 3:19f2285a4757 | 205 | } |
antbig | 3:19f2285a4757 | 206 | |
antbig | 3:19f2285a4757 | 207 | |
antbig | 4:88431b537477 | 208 | |
antbig | 12:14729d584500 | 209 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 210 | /* FUNCTION NAME: needToStop */ |
antbig | 12:14729d584500 | 211 | /* DESCRIPTION : Savoir si il faut autoriser le stop du robot via balise */ |
antbig | 12:14729d584500 | 212 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 213 | unsigned char needToStop(void) |
antbig | 12:14729d584500 | 214 | { |
antbig | 12:14729d584500 | 215 | return isStopEnable; |
antbig | 12:14729d584500 | 216 | } |
antbig | 12:14729d584500 | 217 | |
antbig | 12:14729d584500 | 218 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 219 | /* FUNCTION NAME: doBeforeEndAction */ |
antbig | 12:14729d584500 | 220 | /* DESCRIPTION : Terminer les actions du robot 1s avant la fin du match */ |
antbig | 12:14729d584500 | 221 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 222 | void doBeforeEndAction(void) |
antbig | 12:14729d584500 | 223 | { |
Artiom | 46:a9b6bcb30b1c | 224 | |
antbig | 12:14729d584500 | 225 | } |
antbig | 12:14729d584500 | 226 | |
antbig | 3:19f2285a4757 | 227 | #endif |