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