Programme carte strategie (disco)
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Robots/Strategie_big.cpp@9:d0042422d95a, 2016-04-28 (annotated)
- Committer:
- antbig
- Date:
- Thu Apr 28 08:11:36 2016 +0000
- Revision:
- 9:d0042422d95a
- Parent:
- 8:0edc7dfb7f7e
- Child:
- 11:ed13a480ddca
ajout message choix id strat
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
antbig | 1:116040d14164 | 1 | #include "StrategieManager.h" |
antbig | 3:19f2285a4757 | 2 | #ifdef ROBOT_BIG |
antbig | 3:19f2285a4757 | 3 | #include "Config_big.h" |
antbig | 0:ad97421fb1fb | 4 | |
antbig | 0:ad97421fb1fb | 5 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 6 | /* FUNCTION NAME: doFunnyAction */ |
antbig | 0:ad97421fb1fb | 7 | /* DESCRIPTION : Permet de faire la funny action en fin de partie */ |
antbig | 0:ad97421fb1fb | 8 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 9 | void doFunnyAction(void) { |
antbig | 9:d0042422d95a | 10 | AX12_setGoal(AX12_ID_FUNNY_ACTION, 275); |
antbig | 9:d0042422d95a | 11 | AX12_setGoal(AX12_ID_FUNNY_ACTION, 180); |
antbig | 9:d0042422d95a | 12 | AX12_processChange(); |
antbig | 0:ad97421fb1fb | 13 | |
antbig | 0:ad97421fb1fb | 14 | } |
antbig | 0:ad97421fb1fb | 15 | |
antbig | 0:ad97421fb1fb | 16 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 17 | /* FUNCTION NAME: doAction */ |
antbig | 0:ad97421fb1fb | 18 | /* DESCRIPTION : Effectuer une action specifique */ |
antbig | 0:ad97421fb1fb | 19 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 20 | unsigned char doAction(unsigned char id, unsigned short speed, short angle) { |
antbig | 0:ad97421fb1fb | 21 | switch(id) { |
antbig | 3:19f2285a4757 | 22 | |
antbig | 8:0edc7dfb7f7e | 23 | case 110://Ouvrir la pince arrière haute |
antbig | 8:0edc7dfb7f7e | 24 | AX12_setGoal(AX12_ID_PINCE_ARRIERE_HAUTE_GAUCHE, 205); |
antbig | 8:0edc7dfb7f7e | 25 | AX12_setGoal(AX12_ID_PINCE_ARRIERE_HAUTE_DROITE, 95); |
antbig | 8:0edc7dfb7f7e | 26 | AX12_processChange(); |
antbig | 8:0edc7dfb7f7e | 27 | break; |
antbig | 8:0edc7dfb7f7e | 28 | case 111://Fermer la pince arrière haute |
antbig | 8:0edc7dfb7f7e | 29 | AX12_setGoal(AX12_ID_PINCE_ARRIERE_HAUTE_GAUCHE, 145); |
antbig | 8:0edc7dfb7f7e | 30 | AX12_setGoal(AX12_ID_PINCE_ARRIERE_HAUTE_DROITE, 155); |
antbig | 8:0edc7dfb7f7e | 31 | AX12_processChange(); |
antbig | 8:0edc7dfb7f7e | 32 | break; |
antbig | 9:d0042422d95a | 33 | |
antbig | 8:0edc7dfb7f7e | 34 | case 112://Ouvrir la pince arrière basse |
antbig | 9:d0042422d95a | 35 | AX12_setGoal(AX12_ID_PINCE_ARRIERE_BASSE_GAUCHE, 205); |
antbig | 9:d0042422d95a | 36 | AX12_setGoal(AX12_ID_PINCE_ARRIERE_BASSE_DROITE, 95); |
antbig | 9:d0042422d95a | 37 | AX12_processChange(); |
antbig | 8:0edc7dfb7f7e | 38 | break; |
antbig | 8:0edc7dfb7f7e | 39 | case 113://Fermer la pince arrière basse |
antbig | 9:d0042422d95a | 40 | AX12_setGoal(AX12_ID_PINCE_ARRIERE_BASSE_GAUCHE, 145); |
antbig | 9:d0042422d95a | 41 | AX12_setGoal(AX12_ID_PINCE_ARRIERE_BASSE_DROITE, 155); |
antbig | 9:d0042422d95a | 42 | AX12_processChange(); |
antbig | 9:d0042422d95a | 43 | break; |
antbig | 8:0edc7dfb7f7e | 44 | |
antbig | 8:0edc7dfb7f7e | 45 | case 114://Ouvrir les portes arrières |
antbig | 8:0edc7dfb7f7e | 46 | AX12_setGoal(AX12_ID_PORTE_ARRIERE_GAUCHE, 250); |
antbig | 8:0edc7dfb7f7e | 47 | AX12_setGoal(AX12_ID_PORTE_ARRIERE_DROITE, 50); |
antbig | 8:0edc7dfb7f7e | 48 | AX12_processChange(); |
antbig | 8:0edc7dfb7f7e | 49 | break; |
antbig | 8:0edc7dfb7f7e | 50 | case 115://Fermer les portes arrière |
antbig | 8:0edc7dfb7f7e | 51 | AX12_setGoal(AX12_ID_PORTE_ARRIERE_GAUCHE, 145); |
antbig | 8:0edc7dfb7f7e | 52 | AX12_setGoal(AX12_ID_PORTE_ARRIERE_DROITE, 155); |
antbig | 8:0edc7dfb7f7e | 53 | AX12_processChange(); |
antbig | 8:0edc7dfb7f7e | 54 | break; |
antbig | 0:ad97421fb1fb | 55 | default: |
antbig | 0:ad97421fb1fb | 56 | return 0;//L'action n'existe pas, il faut utiliser le CAN |
antbig | 0:ad97421fb1fb | 57 | |
antbig | 0:ad97421fb1fb | 58 | } |
antbig | 0:ad97421fb1fb | 59 | return 1;//L'action est spécifique. |
antbig | 0:ad97421fb1fb | 60 | |
antbig | 0:ad97421fb1fb | 61 | } |
antbig | 0:ad97421fb1fb | 62 | |
antbig | 0:ad97421fb1fb | 63 | /****************************************************************************************/ |
antbig | 0:ad97421fb1fb | 64 | /* FUNCTION NAME: initRobot */ |
antbig | 0:ad97421fb1fb | 65 | /* DESCRIPTION : initialiser le robot */ |
antbig | 0:ad97421fb1fb | 66 | /****************************************************************************************/ |
antbig | 9:d0042422d95a | 67 | void initRobot(void) |
antbig | 9:d0042422d95a | 68 | { |
antbig | 9:d0042422d95a | 69 | //Enregistrement de tous les AX12 présent sur la carte |
antbig | 8:0edc7dfb7f7e | 70 | AX12_register(4, AX12_SERIAL1); |
antbig | 8:0edc7dfb7f7e | 71 | AX12_register(14, AX12_SERIAL1); |
antbig | 8:0edc7dfb7f7e | 72 | AX12_register(15, AX12_SERIAL1); |
antbig | 8:0edc7dfb7f7e | 73 | AX12_register(5, AX12_SERIAL2); |
antbig | 8:0edc7dfb7f7e | 74 | AX12_register(18, AX12_SERIAL2); |
antbig | 8:0edc7dfb7f7e | 75 | AX12_register(13, AX12_SERIAL2); |
antbig | 9:d0042422d95a | 76 | AX12_register(1, AX12_SERIAL2); |
antbig | 9:d0042422d95a | 77 | |
antbig | 9:d0042422d95a | 78 | runRobotTest(); |
antbig | 9:d0042422d95a | 79 | } |
antbig | 9:d0042422d95a | 80 | |
antbig | 9:d0042422d95a | 81 | /****************************************************************************************/ |
antbig | 9:d0042422d95a | 82 | /* FUNCTION NAME: runTest */ |
antbig | 9:d0042422d95a | 83 | /* DESCRIPTION : tester l'ensemble des actionneurs du robot */ |
antbig | 9:d0042422d95a | 84 | /****************************************************************************************/ |
antbig | 9:d0042422d95a | 85 | void runRobotTest(void) |
antbig | 9:d0042422d95a | 86 | { |
antbig | 9:d0042422d95a | 87 | //Test des AX12 dans l'ordre |
antbig | 9:d0042422d95a | 88 | doAction(111,0,0);//Fermeture pince arrière haute |
antbig | 9:d0042422d95a | 89 | wait_ms(500); |
antbig | 9:d0042422d95a | 90 | doAction(110,0,0);//Ouverture pince arrière haute |
antbig | 9:d0042422d95a | 91 | wait_ms(500); |
antbig | 9:d0042422d95a | 92 | doAction(113,0,0);//Fermeture pince arrière basse |
antbig | 9:d0042422d95a | 93 | wait_ms(500); |
antbig | 9:d0042422d95a | 94 | doAction(112,0,0);//Ouverture pince arrière basse |
antbig | 9:d0042422d95a | 95 | wait_ms(500); |
antbig | 9:d0042422d95a | 96 | doAction(115,0,0);//Fermeture porte arrière |
antbig | 9:d0042422d95a | 97 | wait_ms(500); |
antbig | 9:d0042422d95a | 98 | doAction(114,0,0);//Ouverture porte arrière |
antbig | 0:ad97421fb1fb | 99 | } |
antbig | 3:19f2285a4757 | 100 | |
antbig | 4:88431b537477 | 101 | /****************************************************************************************/ |
antbig | 4:88431b537477 | 102 | /* FUNCTION NAME: SelectStrategy */ |
antbig | 4:88431b537477 | 103 | /* DESCRIPTION : Charger le fichier de stratégie correspondante à un id */ |
antbig | 4:88431b537477 | 104 | /* RETURN : 0=> Erreur, 1=> OK si le fichier existe */ |
antbig | 4:88431b537477 | 105 | /****************************************************************************************/ |
antbig | 4:88431b537477 | 106 | int SelectStrategy(unsigned char id) |
antbig | 4:88431b537477 | 107 | { |
antbig | 4:88431b537477 | 108 | switch(id) |
antbig | 4:88431b537477 | 109 | { |
antbig | 4:88431b537477 | 110 | case 1: |
antbig | 4:88431b537477 | 111 | |
antbig | 4:88431b537477 | 112 | break; |
antbig | 4:88431b537477 | 113 | } |
antbig | 4:88431b537477 | 114 | return 0; |
antbig | 4:88431b537477 | 115 | } |
antbig | 4:88431b537477 | 116 | |
antbig | 3:19f2285a4757 | 117 | #endif |