Programme carte strategie (disco)
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Robots/Strategie_small.cpp@53:e96acb11a51f, 2019-05-22 (annotated)
- Committer:
- Artiom
- Date:
- Wed May 22 09:52:00 2019 +0000
- Revision:
- 53:e96acb11a51f
- Parent:
- 52:a47350923b5e
- Child:
- 54:8996a5b18d9b
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 |
Villanut | 45:4f93e99bac6e | 48 | SendRawId(ACCELERATEUR_AVANT); |
Sitkah | 30:a1e37af4bbde | 49 | break; |
Villanut | 45:4f93e99bac6e | 50 | case 107: //accelerateur arriere |
Villanut | 45:4f93e99bac6e | 51 | SendRawId(ACCELERATEUR_ARRIERE); |
Sitkah | 30:a1e37af4bbde | 52 | break; |
Villanut | 45:4f93e99bac6e | 53 | case 108: //goldenium avant |
Villanut | 45:4f93e99bac6e | 54 | SendRawId(GOLDENIUM_AVANT); |
Sitkah | 30:a1e37af4bbde | 55 | break; |
Villanut | 45:4f93e99bac6e | 56 | case 109: //goldenium arriere |
Villanut | 45:4f93e99bac6e | 57 | SendRawId(GOLDENIUM_ARRIERE); |
Sitkah | 30:a1e37af4bbde | 58 | break; |
Villanut | 45:4f93e99bac6e | 59 | case 110: //sol avant |
Villanut | 45:4f93e99bac6e | 60 | SendRawId(SOL_AVANT); |
Sitkah | 30:a1e37af4bbde | 61 | break; |
Villanut | 45:4f93e99bac6e | 62 | case 111: //sol arriere |
Villanut | 45:4f93e99bac6e | 63 | SendRawId(SOL_ARRIERE); |
Sitkah | 34:6aa4b46b102e | 64 | break; |
Artiom | 46:a9b6bcb30b1c | 65 | case 112: //sol avant relache |
Artiom | 46:a9b6bcb30b1c | 66 | SendRawId(SOL_AVANT_RELACHE); |
Artiom | 46:a9b6bcb30b1c | 67 | break; |
Artiom | 46:a9b6bcb30b1c | 68 | case 113: //sol arriere relache |
Artiom | 46:a9b6bcb30b1c | 69 | SendRawId(SOL_ARRIERE_RELACHE); |
Artiom | 46:a9b6bcb30b1c | 70 | break; |
Artiom | 52:a47350923b5e | 71 | case 114: |
Artiom | 52:a47350923b5e | 72 | SendRawId(AVANT_RELACHE); |
Artiom | 52:a47350923b5e | 73 | break; |
Artiom | 52:a47350923b5e | 74 | |
Artiom | 52:a47350923b5e | 75 | case 115: |
Artiom | 52:a47350923b5e | 76 | SendRawId(ARRIERE_RELACHE); |
Artiom | 52:a47350923b5e | 77 | break; |
Artiom | 52:a47350923b5e | 78 | |
Artiom | 52:a47350923b5e | 79 | case 116: |
Artiom | 52:a47350923b5e | 80 | unsigned char arg_tempo=(unsigned char)arg1; |
Artiom | 52:a47350923b5e | 81 | SendMsgCan(HACHEUR_RELEASE_ATOM, &arg_tempo,1); |
Artiom | 52:a47350923b5e | 82 | waitingAckFrom = 0; |
Artiom | 52:a47350923b5e | 83 | waitingAckID =0; |
Artiom | 52:a47350923b5e | 84 | break; |
Artiom | 52:a47350923b5e | 85 | case 117: |
Artiom | 52:a47350923b5e | 86 | SendRawId(RECROQUEVILLER); |
Artiom | 52:a47350923b5e | 87 | break; |
Artiom | 53:e96acb11a51f | 88 | case 118: |
Artiom | 53:e96acb11a51f | 89 | SendRawId(VENTOUSE_AV_CENTRE_BALANCE); |
Artiom | 53:e96acb11a51f | 90 | break; |
Artiom | 53:e96acb11a51f | 91 | case 119: |
Artiom | 53:e96acb11a51f | 92 | SendRawId(VENTOUSE_AR_CENTRE_BALANCE); |
Artiom | 53:e96acb11a51f | 93 | break; |
Artiom | 46:a9b6bcb30b1c | 94 | |
Sitkah | 38:76f886a1c8e6 | 95 | case 150: |
Sitkah | 38:76f886a1c8e6 | 96 | SCORE_PR+=arg1; |
Sitkah | 38:76f886a1c8e6 | 97 | liaison_Tx.envoyer_short(0x30,SCORE_PR); |
Sitkah | 38:76f886a1c8e6 | 98 | waitingAckFrom = 0; |
Sitkah | 38:76f886a1c8e6 | 99 | waitingAckID = 0; |
Sitkah | 38:76f886a1c8e6 | 100 | break; |
Artiom | 46:a9b6bcb30b1c | 101 | |
Artiom | 46:a9b6bcb30b1c | 102 | |
ClementBreteau | 18:cc5fec34ed9c | 103 | case 200 : |
Sitkah | 30:a1e37af4bbde | 104 | SendRawId(DATA_TELEMETRE); |
Sitkah | 30:a1e37af4bbde | 105 | /*telemetreDistance = dataTelemetre(); |
ClementBreteau | 18:cc5fec34ed9c | 106 | wait_ms(1); |
ClementBreteau | 18:cc5fec34ed9c | 107 | telemetreDistance = dataTelemetre(); |
Sitkah | 30:a1e37af4bbde | 108 | telemetreDistance = telemetreDistance - 170;*/ |
Artiom | 46:a9b6bcb30b1c | 109 | break; |
Artiom | 46:a9b6bcb30b1c | 110 | |
ClementBreteau | 18:cc5fec34ed9c | 111 | case 201 : |
Sitkah | 30:a1e37af4bbde | 112 | SendRawId(0x99); |
ClementBreteau | 18:cc5fec34ed9c | 113 | retour = 2; |
Artiom | 46:a9b6bcb30b1c | 114 | break; |
Artiom | 46:a9b6bcb30b1c | 115 | |
antbig | 12:14729d584500 | 116 | case 10://Désactiver le stop |
antbig | 12:14729d584500 | 117 | isStopEnable = 0; |
Artiom | 46:a9b6bcb30b1c | 118 | break; |
antbig | 12:14729d584500 | 119 | case 11://Activer le stop |
antbig | 12:14729d584500 | 120 | isStopEnable = 1; |
Artiom | 46:a9b6bcb30b1c | 121 | break; |
antbig | 12:14729d584500 | 122 | case 20://Désactiver l'asservissement |
antbig | 12:14729d584500 | 123 | setAsservissementEtat(0); |
Artiom | 46:a9b6bcb30b1c | 124 | break; |
antbig | 12:14729d584500 | 125 | case 21://Activer l'asservissement |
antbig | 12:14729d584500 | 126 | setAsservissementEtat(1); |
Artiom | 46:a9b6bcb30b1c | 127 | break; |
Artiom | 46:a9b6bcb30b1c | 128 | |
Sitkah | 34:6aa4b46b102e | 129 | case 22://Changer la vitesse du robot |
Artiom | 52:a47350923b5e | 130 | // SendSpeed(arg1,(unsigned short)arg2); |
ClementBreteau | 18:cc5fec34ed9c | 131 | wait_us(200); |
antbig | 28:acd18776ed2d | 132 | waitingAckFrom = 0; |
antbig | 28:acd18776ed2d | 133 | waitingAckID = 0; |
Artiom | 46:a9b6bcb30b1c | 134 | break; |
Artiom | 46:a9b6bcb30b1c | 135 | |
Artiom | 46:a9b6bcb30b1c | 136 | case 19: // CHANGER LA VITESSE + DECELERATION |
Artiom | 50:a5361ffeefc8 | 137 | //SendSpeedDecel(arg1,(unsigned short) arg2); |
antbig | 28:acd18776ed2d | 138 | wait_us(200); |
antbig | 28:acd18776ed2d | 139 | waitingAckFrom = 0; |
antbig | 28:acd18776ed2d | 140 | waitingAckID =0; |
Artiom | 46:a9b6bcb30b1c | 141 | break; |
Artiom | 46:a9b6bcb30b1c | 142 | |
ClementBreteau | 16:7321fb3bb396 | 143 | case 30://Action tempo |
Sitkah | 34:6aa4b46b102e | 144 | wait_ms(arg1); |
Artiom | 46:a9b6bcb30b1c | 145 | break; |
Artiom | 46:a9b6bcb30b1c | 146 | |
antbig | 3:19f2285a4757 | 147 | default: |
ClementBreteau | 18:cc5fec34ed9c | 148 | retour = 0;//L'action n'existe pas, il faut utiliser le CAN |
Artiom | 46:a9b6bcb30b1c | 149 | |
antbig | 3:19f2285a4757 | 150 | } |
ClementBreteau | 18:cc5fec34ed9c | 151 | return retour;//L'action est spécifique. |
Artiom | 46:a9b6bcb30b1c | 152 | |
antbig | 3:19f2285a4757 | 153 | } |
antbig | 3:19f2285a4757 | 154 | |
antbig | 3:19f2285a4757 | 155 | |
antbig | 4:88431b537477 | 156 | |
antbig | 12:14729d584500 | 157 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 158 | /* FUNCTION NAME: needToStop */ |
antbig | 12:14729d584500 | 159 | /* DESCRIPTION : Savoir si il faut autoriser le stop du robot via balise */ |
antbig | 12:14729d584500 | 160 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 161 | unsigned char needToStop(void) |
antbig | 12:14729d584500 | 162 | { |
antbig | 12:14729d584500 | 163 | return isStopEnable; |
antbig | 12:14729d584500 | 164 | } |
antbig | 12:14729d584500 | 165 | |
antbig | 12:14729d584500 | 166 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 167 | /* FUNCTION NAME: doBeforeEndAction */ |
antbig | 12:14729d584500 | 168 | /* DESCRIPTION : Terminer les actions du robot 1s avant la fin du match */ |
antbig | 12:14729d584500 | 169 | /****************************************************************************************/ |
antbig | 12:14729d584500 | 170 | void doBeforeEndAction(void) |
antbig | 12:14729d584500 | 171 | { |
Artiom | 46:a9b6bcb30b1c | 172 | |
antbig | 12:14729d584500 | 173 | } |
antbig | 12:14729d584500 | 174 | |
antbig | 3:19f2285a4757 | 175 | #endif |