Programme carte strategie (disco)

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Committer:
antbig
Date:
Sun Apr 17 08:31:59 2016 +0000
Revision:
3:19f2285a4757
Child:
4:88431b537477
Mise en place de la s?paration des fonctions doAction, initRobot, doFunnyAction entre les robots dans 2 fichier diff. Il faut modifier le fichier constantes.h pour indiquer le type de robot

Who changed what in which revision?

UserRevisionLine numberNew contents of line
antbig 3:19f2285a4757 1 #include "StrategieManager.h"
antbig 3:19f2285a4757 2 #ifdef ROBOT_SMALL
antbig 3:19f2285a4757 3 #include "Config_small.h"
antbig 3:19f2285a4757 4
antbig 3:19f2285a4757 5 /****************************************************************************************/
antbig 3:19f2285a4757 6 /* FUNCTION NAME: doFunnyAction */
antbig 3:19f2285a4757 7 /* DESCRIPTION : Permet de faire la funny action en fin de partie */
antbig 3:19f2285a4757 8 /****************************************************************************************/
antbig 3:19f2285a4757 9 void doFunnyAction(void) {
antbig 3:19f2285a4757 10
antbig 3:19f2285a4757 11
antbig 3:19f2285a4757 12 }
antbig 3:19f2285a4757 13
antbig 3:19f2285a4757 14 /****************************************************************************************/
antbig 3:19f2285a4757 15 /* FUNCTION NAME: doAction */
antbig 3:19f2285a4757 16 /* DESCRIPTION : Effectuer une action specifique */
antbig 3:19f2285a4757 17 /****************************************************************************************/
antbig 3:19f2285a4757 18 unsigned char doAction(unsigned char id, unsigned short speed, short angle) {
antbig 3:19f2285a4757 19 switch(id) {
antbig 3:19f2285a4757 20 case 101://Descendre le bras pour les poissons
antbig 3:19f2285a4757 21 if(InversStrat == 1) {//Si c'est inversé, On utilise le bras coté gauche
antbig 3:19f2285a4757 22 AX12_setGoal(AX12_ID_BRAS_BASE_INV,200,0x0FF);
antbig 3:19f2285a4757 23 AX12_processChange();
antbig 3:19f2285a4757 24 } else {
antbig 3:19f2285a4757 25
antbig 3:19f2285a4757 26 }
antbig 3:19f2285a4757 27 break;
antbig 3:19f2285a4757 28 case 102://Remonter bras moiter
antbig 3:19f2285a4757 29 if(InversStrat == 1) {//Si c'est inversé, On utilise le bras coté gauche
antbig 3:19f2285a4757 30 AX12_setGoal(AX12_ID_BRAS_BASE_INV,270,0x0FF);
antbig 3:19f2285a4757 31 AX12_processChange();
antbig 3:19f2285a4757 32 } else {
antbig 3:19f2285a4757 33
antbig 3:19f2285a4757 34 }
antbig 3:19f2285a4757 35 break;
antbig 3:19f2285a4757 36 case 103://Lacher les poissons
antbig 3:19f2285a4757 37 if(InversStrat == 1) {//Si c'est inversé, On utilise le bras coté gauche
antbig 3:19f2285a4757 38 AX12_setGoal(AX12_ID_BRAS_BASE_INV,210,0x0FF);
antbig 3:19f2285a4757 39 AX12_processChange();
antbig 3:19f2285a4757 40 wait_ms(500);//TODO ajouter une action pour remplacer l'attente bloquante
antbig 3:19f2285a4757 41 AX12_setGoal(AX12_ID_BRAS_RELACHEUR_INV,90);//Ouverture du bras
antbig 3:19f2285a4757 42 AX12_processChange();
antbig 3:19f2285a4757 43 } else {
antbig 3:19f2285a4757 44
antbig 3:19f2285a4757 45 }
antbig 3:19f2285a4757 46 break;
antbig 3:19f2285a4757 47 case 104://Rentrer le bras
antbig 3:19f2285a4757 48 if(InversStrat == 1) {//Si c'est inversé, On utilise le bras coté gauche
antbig 3:19f2285a4757 49 AX12_setGoal(AX12_ID_BRAS_BASE_INV,278,0x0FF);
antbig 3:19f2285a4757 50 AX12_setGoal(AX12_ID_BRAS_RELACHEUR_INV,160);//fermer le bras
antbig 3:19f2285a4757 51 AX12_processChange();
antbig 3:19f2285a4757 52 } else {
antbig 3:19f2285a4757 53
antbig 3:19f2285a4757 54 }
antbig 3:19f2285a4757 55 break;
antbig 3:19f2285a4757 56 default:
antbig 3:19f2285a4757 57 return 0;//L'action n'existe pas, il faut utiliser le CAN
antbig 3:19f2285a4757 58
antbig 3:19f2285a4757 59 }
antbig 3:19f2285a4757 60 return 1;//L'action est spécifique.
antbig 3:19f2285a4757 61
antbig 3:19f2285a4757 62 }
antbig 3:19f2285a4757 63
antbig 3:19f2285a4757 64 /****************************************************************************************/
antbig 3:19f2285a4757 65 /* FUNCTION NAME: initRobot */
antbig 3:19f2285a4757 66 /* DESCRIPTION : initialiser le robot */
antbig 3:19f2285a4757 67 /****************************************************************************************/
antbig 3:19f2285a4757 68 void initRobot(void) {
antbig 3:19f2285a4757 69 /**
antbig 3:19f2285a4757 70 On enregistre les id des AX12 présent sur la carte
antbig 3:19f2285a4757 71 **/
antbig 3:19f2285a4757 72 AX12_register(1,0x0FF);
antbig 3:19f2285a4757 73 AX12_register(2);
antbig 3:19f2285a4757 74 }
antbig 3:19f2285a4757 75
antbig 3:19f2285a4757 76 #endif