Programme carte strategie (disco)
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Robots/Strategie_small.cpp@45:4f93e99bac6e, 2019-05-09 (annotated)
- Committer:
- Villanut
- Date:
- Thu May 09 08:38:45 2019 +0000
- Revision:
- 45:4f93e99bac6e
- Parent:
- 42:657b6a573e11
- Child:
- 46:a9b6bcb30b1c
v2019
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 | /****************************************************************************************/ |
antbig | 3:19f2285a4757 | 14 | void doFunnyAction(void) { |
antbig | 3:19f2285a4757 | 15 | |
antbig | 3:19f2285a4757 | 16 | |
antbig | 3:19f2285a4757 | 17 | } |
antbig | 3:19f2285a4757 | 18 | |
ClementBreteau | 18:cc5fec34ed9c | 19 | |
Sitkah | 42:657b6a573e11 | 20 | /*************************************************************************************************/ |
Sitkah | 42:657b6a573e11 | 21 | /* FUNCTION NAME: doAction */ |
Sitkah | 42:657b6a573e11 | 22 | /* DESCRIPTION : Effectuer une action specifique correspondant au numéro dans le fichier strat */ |
Sitkah | 42:657b6a573e11 | 23 | /*************************************************************************************************/ |
Sitkah | 34:6aa4b46b102e | 24 | unsigned char doAction(unsigned char id, unsigned short arg1, short arg2) { |
ClementBreteau | 18:cc5fec34ed9c | 25 | int retour = 1; |
Sitkah | 34:6aa4b46b102e | 26 | CANMessage msgTx=CANMessage(); |
Sitkah | 34:6aa4b46b102e | 27 | msgTx.format=CANStandard; |
Sitkah | 34:6aa4b46b102e | 28 | msgTx.type=CANData; |
antbig | 3:19f2285a4757 | 29 | switch(id) { |
Villanut | 45:4f93e99bac6e | 30 | case 101: //bras gabarit |
Villanut | 45:4f93e99bac6e | 31 | SendRawId(GABARIT_PETIT_ROBOT); |
Sitkah | 30:a1e37af4bbde | 32 | break; |
Villanut | 45:4f93e99bac6e | 33 | case 102: //attraper presentoir avant |
Villanut | 45:4f93e99bac6e | 34 | SendRawId(PRESENTOIR_AVANT); |
Sitkah | 30:a1e37af4bbde | 35 | break; |
Villanut | 45:4f93e99bac6e | 36 | case 103: //attraper presentoir arriere |
Villanut | 45:4f93e99bac6e | 37 | SendRawId(PRESENTOIR_ARRIERE); |
Sitkah | 30:a1e37af4bbde | 38 | break; |
Villanut | 45:4f93e99bac6e | 39 | case 104: //balance avant |
Villanut | 45:4f93e99bac6e | 40 | SendRawId(BALANCE_AVANT); |
Sitkah | 30:a1e37af4bbde | 41 | break; |
Villanut | 45:4f93e99bac6e | 42 | case 105: //balance arriere |
Villanut | 45:4f93e99bac6e | 43 | SendRawId(BALANCE_ARRIERE); |
Sitkah | 30:a1e37af4bbde | 44 | break; |
Villanut | 45:4f93e99bac6e | 45 | case 106: //accelerateur avant |
Villanut | 45:4f93e99bac6e | 46 | SendRawId(ACCELERATEUR_AVANT); |
Sitkah | 30:a1e37af4bbde | 47 | break; |
Villanut | 45:4f93e99bac6e | 48 | case 107: //accelerateur arriere |
Villanut | 45:4f93e99bac6e | 49 | SendRawId(ACCELERATEUR_ARRIERE); |
Sitkah | 30:a1e37af4bbde | 50 | break; |
Villanut | 45:4f93e99bac6e | 51 | case 108: //goldenium avant |
Villanut | 45:4f93e99bac6e | 52 | SendRawId(GOLDENIUM_AVANT); |
Sitkah | 30:a1e37af4bbde | 53 | break; |
Villanut | 45:4f93e99bac6e | 54 | case 109: //goldenium arriere |
Villanut | 45:4f93e99bac6e | 55 | SendRawId(GOLDENIUM_ARRIERE); |
Sitkah | 30:a1e37af4bbde | 56 | break; |
Villanut | 45:4f93e99bac6e | 57 | case 110: //sol avant |
Villanut | 45:4f93e99bac6e | 58 | SendRawId(SOL_AVANT); |
Sitkah | 30:a1e37af4bbde | 59 | break; |
Villanut | 45:4f93e99bac6e | 60 | case 111: //sol arriere |
Villanut | 45:4f93e99bac6e | 61 | SendRawId(SOL_ARRIERE); |
Sitkah | 34:6aa4b46b102e | 62 | break; |
Sitkah | 34:6aa4b46b102e | 63 | |
Sitkah | 38:76f886a1c8e6 | 64 | case 150: |
Sitkah | 38:76f886a1c8e6 | 65 | SCORE_PR+=arg1; |
Sitkah | 38:76f886a1c8e6 | 66 | liaison_Tx.envoyer_short(0x30,SCORE_PR); |
Sitkah | 38:76f886a1c8e6 | 67 | waitingAckFrom = 0; |
Sitkah | 38:76f886a1c8e6 | 68 | waitingAckID = 0; |
Sitkah | 38:76f886a1c8e6 | 69 | break; |
Sitkah | 38:76f886a1c8e6 | 70 | |
ClementBreteau | 16:7321fb3bb396 | 71 | |
ClementBreteau | 18:cc5fec34ed9c | 72 | case 200 : |
Sitkah | 30:a1e37af4bbde | 73 | SendRawId(DATA_TELEMETRE); |
Sitkah | 30:a1e37af4bbde | 74 | /*telemetreDistance = dataTelemetre(); |
ClementBreteau | 18:cc5fec34ed9c | 75 | wait_ms(1); |
ClementBreteau | 18:cc5fec34ed9c | 76 | telemetreDistance = dataTelemetre(); |
Sitkah | 30:a1e37af4bbde | 77 | telemetreDistance = telemetreDistance - 170;*/ |
ClementBreteau | 18:cc5fec34ed9c | 78 | break; |
ClementBreteau | 18:cc5fec34ed9c | 79 | |
ClementBreteau | 18:cc5fec34ed9c | 80 | case 201 : |
Sitkah | 30:a1e37af4bbde | 81 | SendRawId(0x99); |
ClementBreteau | 18:cc5fec34ed9c | 82 | retour = 2; |
antbig | 10:a788d9cf60f2 | 83 | break; |
ClementBreteau | 15:c2fc239e85df | 84 | |
antbig | 12:14729d584500 | 85 | case 10://Désactiver le stop |
antbig | 12:14729d584500 | 86 | isStopEnable = 0; |
antbig | 12:14729d584500 | 87 | break; |
antbig | 12:14729d584500 | 88 | case 11://Activer le stop |
antbig | 12:14729d584500 | 89 | isStopEnable = 1; |
antbig | 12:14729d584500 | 90 | break; |
antbig | 12:14729d584500 | 91 | case 20://Désactiver l'asservissement |
antbig | 12:14729d584500 | 92 | setAsservissementEtat(0); |
antbig | 12:14729d584500 | 93 | break; |
antbig | 12:14729d584500 | 94 | case 21://Activer l'asservissement |
antbig | 12:14729d584500 | 95 | setAsservissementEtat(1); |
ClementBreteau | 16:7321fb3bb396 | 96 | break; |
ClementBreteau | 16:7321fb3bb396 | 97 | |
Sitkah | 34:6aa4b46b102e | 98 | case 22://Changer la vitesse du robot |
Sitkah | 34:6aa4b46b102e | 99 | SendSpeed(arg1,(unsigned short)arg2); |
ClementBreteau | 18:cc5fec34ed9c | 100 | wait_us(200); |
antbig | 28:acd18776ed2d | 101 | waitingAckFrom = 0; |
antbig | 28:acd18776ed2d | 102 | waitingAckID = 0; |
antbig | 28:acd18776ed2d | 103 | break; |
antbig | 28:acd18776ed2d | 104 | |
antbig | 28:acd18776ed2d | 105 | case 19: // CHANGER LA VITESSE + DECELERATION |
Sitkah | 34:6aa4b46b102e | 106 | SendSpeedDecel(arg1,(unsigned short) arg2); |
antbig | 28:acd18776ed2d | 107 | wait_us(200); |
antbig | 28:acd18776ed2d | 108 | waitingAckFrom = 0; |
antbig | 28:acd18776ed2d | 109 | waitingAckID =0; |
ClementBreteau | 16:7321fb3bb396 | 110 | break; |
ClementBreteau | 16:7321fb3bb396 | 111 | |
ClementBreteau | 16:7321fb3bb396 | 112 | case 30://Action tempo |
Sitkah | 34:6aa4b46b102e | 113 | wait_ms(arg1); |
antbig | 12:14729d584500 | 114 | break; |
Sitkah | 34:6aa4b46b102e | 115 | |
antbig | 3:19f2285a4757 | 116 | default: |
ClementBreteau | 18:cc5fec34ed9c | 117 | retour = 0;//L'action n'existe pas, il faut utiliser le CAN |
antbig | 3:19f2285a4757 | 118 | |
antbig | 3:19f2285a4757 | 119 | } |
ClementBreteau | 18:cc5fec34ed9c | 120 | return retour;//L'action est spécifique. |
antbig | 3:19f2285a4757 | 121 | |
antbig | 3:19f2285a4757 | 122 | } |
antbig | 3:19f2285a4757 | 123 | |
antbig | 3:19f2285a4757 | 124 | |
antbig | 4:88431b537477 | 125 | |
antbig | 12:14729d584500 | 126 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 127 | /* FUNCTION NAME: needToStop */ |
antbig | 12:14729d584500 | 128 | /* DESCRIPTION : Savoir si il faut autoriser le stop du robot via balise */ |
antbig | 12:14729d584500 | 129 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 130 | unsigned char needToStop(void) |
antbig | 12:14729d584500 | 131 | { |
antbig | 12:14729d584500 | 132 | return isStopEnable; |
antbig | 12:14729d584500 | 133 | } |
antbig | 12:14729d584500 | 134 | |
antbig | 12:14729d584500 | 135 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 136 | /* FUNCTION NAME: doBeforeEndAction */ |
antbig | 12:14729d584500 | 137 | /* DESCRIPTION : Terminer les actions du robot 1s avant la fin du match */ |
antbig | 12:14729d584500 | 138 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 139 | void doBeforeEndAction(void) |
antbig | 12:14729d584500 | 140 | { |
antbig | 12:14729d584500 | 141 | |
antbig | 12:14729d584500 | 142 | } |
antbig | 12:14729d584500 | 143 | |
antbig | 3:19f2285a4757 | 144 | #endif |