code petit robot pour homologation
Fork of CRAC-Strat_2017_V2 by
Robots/Strategie_small.cpp@4:88431b537477, 2016-04-17 (annotated)
- Committer:
- antbig
- Date:
- Sun Apr 17 14:03:03 2016 +0000
- Revision:
- 4:88431b537477
- Parent:
- 3:19f2285a4757
- Child:
- 5:dcd817534b57
Ajout possibilit? de choisir id strat via CAN
Who changed what in which revision?
User | Revision | Line number | New 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 | 4:88431b537477 | 76 | /****************************************************************************************/ |
antbig | 4:88431b537477 | 77 | /* FUNCTION NAME: SelectStrategy */ |
antbig | 4:88431b537477 | 78 | /* DESCRIPTION : Charger le fichier de stratégie correspondante à un id */ |
antbig | 4:88431b537477 | 79 | /* RETURN : 0=> Erreur, 1=> OK si le fichier existe */ |
antbig | 4:88431b537477 | 80 | /****************************************************************************************/ |
antbig | 4:88431b537477 | 81 | int SelectStrategy(unsigned char id) |
antbig | 4:88431b537477 | 82 | { |
antbig | 4:88431b537477 | 83 | switch(id) |
antbig | 4:88431b537477 | 84 | { |
antbig | 4:88431b537477 | 85 | case 1: |
antbig | 4:88431b537477 | 86 | strcpy(cheminFileStart,"/local/strat1.txt"); |
antbig | 4:88431b537477 | 87 | return FileExists(cheminFileStart); |
antbig | 4:88431b537477 | 88 | case 2: |
antbig | 4:88431b537477 | 89 | strcpy(cheminFileStart,"/local/strat2.txt"); |
antbig | 4:88431b537477 | 90 | return FileExists(cheminFileStart); |
antbig | 4:88431b537477 | 91 | default: |
antbig | 4:88431b537477 | 92 | strcpy(cheminFileStart,"/local/strat.txt"); |
antbig | 4:88431b537477 | 93 | return 0; |
antbig | 4:88431b537477 | 94 | } |
antbig | 4:88431b537477 | 95 | } |
antbig | 4:88431b537477 | 96 | |
antbig | 3:19f2285a4757 | 97 | #endif |