homologation gros robot et test avec les ack de la carte a tout faire

Fork of CRAC-Strat_2017_HOMOLOGATION_PETIT_ROBOT by CRAC Team

Committer:
antbig
Date:
Thu Apr 28 08:11:36 2016 +0000
Revision:
9:d0042422d95a
Parent:
7:dcce34c7e06e
Child:
10:a788d9cf60f2
ajout message choix id strat

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 9:d0042422d95a 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 5:dcd817534b57 25 AX12_setGoal(AX12_ID_BRAS_BASE,140,0x0FF);
antbig 5:dcd817534b57 26 AX12_processChange();
antbig 3:19f2285a4757 27 }
antbig 3:19f2285a4757 28 break;
antbig 3:19f2285a4757 29 case 102://Remonter bras moiter
antbig 3:19f2285a4757 30 if(InversStrat == 1) {//Si c'est inversé, On utilise le bras coté gauche
antbig 5:dcd817534b57 31 AX12_setGoal(AX12_ID_BRAS_BASE_INV,220,0x0FF);
antbig 3:19f2285a4757 32 AX12_processChange();
antbig 3:19f2285a4757 33 } else {
antbig 5:dcd817534b57 34 AX12_setGoal(AX12_ID_BRAS_BASE,100,0x0FF);
antbig 5:dcd817534b57 35 AX12_processChange();
antbig 3:19f2285a4757 36 }
antbig 3:19f2285a4757 37 break;
antbig 3:19f2285a4757 38 case 103://Lacher les poissons
antbig 3:19f2285a4757 39 if(InversStrat == 1) {//Si c'est inversé, On utilise le bras coté gauche
antbig 3:19f2285a4757 40 AX12_setGoal(AX12_ID_BRAS_RELACHEUR_INV,90);//Ouverture du bras
antbig 3:19f2285a4757 41 AX12_processChange();
antbig 3:19f2285a4757 42 } else {
antbig 5:dcd817534b57 43 AX12_setGoal(AX12_ID_BRAS_RELACHEUR,250);//Ouverture du bras
antbig 5:dcd817534b57 44 AX12_processChange();
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 5:dcd817534b57 53 AX12_setGoal(AX12_ID_BRAS_BASE,55,0x0FF);
antbig 5:dcd817534b57 54 AX12_setGoal(AX12_ID_BRAS_RELACHEUR,200);//fermer le bras
antbig 5:dcd817534b57 55 AX12_processChange();
antbig 3:19f2285a4757 56 }
antbig 3:19f2285a4757 57 break;
antbig 5:dcd817534b57 58 case 105:
antbig 5:dcd817534b57 59 //AX12_setGoal(AX12_ID_BRAS_RELACHEUR_INV,160);//fermer le bras
antbig 5:dcd817534b57 60 //AX12_processChange();
antbig 5:dcd817534b57 61 break;
antbig 5:dcd817534b57 62 case 106:
antbig 5:dcd817534b57 63 //AX12_setGoal(AX12_ID_BRAS_RELACHEUR_INV,160);//fermer le bras
antbig 5:dcd817534b57 64 //AX12_processChange();
antbig 9:d0042422d95a 65 break;*/
antbig 3:19f2285a4757 66 default:
antbig 9:d0042422d95a 67 waitingAckFrom = 0;
antbig 9:d0042422d95a 68 waitingAckID = 0;
antbig 9:d0042422d95a 69 return 1;//L'action n'existe pas, il faut utiliser le CAN
antbig 3:19f2285a4757 70
antbig 3:19f2285a4757 71 }
antbig 9:d0042422d95a 72 //return 1;//L'action est spécifique.
antbig 3:19f2285a4757 73
antbig 3:19f2285a4757 74 }
antbig 3:19f2285a4757 75
antbig 3:19f2285a4757 76 /****************************************************************************************/
antbig 3:19f2285a4757 77 /* FUNCTION NAME: initRobot */
antbig 3:19f2285a4757 78 /* DESCRIPTION : initialiser le robot */
antbig 3:19f2285a4757 79 /****************************************************************************************/
antbig 3:19f2285a4757 80 void initRobot(void) {
antbig 3:19f2285a4757 81 /**
antbig 3:19f2285a4757 82 On enregistre les id des AX12 présent sur la carte
antbig 3:19f2285a4757 83 **/
antbig 5:dcd817534b57 84 AX12_register(1,AX12_SERIAL1,0x0FF);
antbig 5:dcd817534b57 85 AX12_register(2,AX12_SERIAL1);
antbig 5:dcd817534b57 86 AX12_register(18,AX12_SERIAL1);
antbig 5:dcd817534b57 87 AX12_register(4,AX12_SERIAL2);
antbig 5:dcd817534b57 88 AX12_register(16,AX12_SERIAL2);
antbig 5:dcd817534b57 89 AX12_register(17,AX12_SERIAL2,0x0FF);
antbig 5:dcd817534b57 90 /*
antbig 5:dcd817534b57 91 AX12_setGoal(AX12_ID_BRAS_BASE_INV,278,0x0FF);
antbig 5:dcd817534b57 92 AX12_setGoal(AX12_ID_BRAS_RELACHEUR_INV,160);//fermer le bras
antbig 5:dcd817534b57 93 AX12_setGoal(AX12_ID_BRAS_BASE,278,0x0FF);
antbig 5:dcd817534b57 94 AX12_setGoal(AX12_ID_BRAS_RELACHEUR,160);//fermer le bras
antbig 5:dcd817534b57 95 AX12_processChange();*/
antbig 3:19f2285a4757 96 }
antbig 3:19f2285a4757 97
antbig 4:88431b537477 98 /****************************************************************************************/
antbig 9:d0042422d95a 99 /* FUNCTION NAME: runTest */
antbig 9:d0042422d95a 100 /* DESCRIPTION : tester l'ensemble des actionneurs du robot */
antbig 9:d0042422d95a 101 /****************************************************************************************/
antbig 9:d0042422d95a 102 void runRobotTest(void)
antbig 9:d0042422d95a 103 {
antbig 9:d0042422d95a 104
antbig 9:d0042422d95a 105 }
antbig 9:d0042422d95a 106
antbig 9:d0042422d95a 107 /****************************************************************************************/
antbig 4:88431b537477 108 /* FUNCTION NAME: SelectStrategy */
antbig 4:88431b537477 109 /* DESCRIPTION : Charger le fichier de stratégie correspondante à un id */
antbig 4:88431b537477 110 /* RETURN : 0=> Erreur, 1=> OK si le fichier existe */
antbig 4:88431b537477 111 /****************************************************************************************/
antbig 4:88431b537477 112 int SelectStrategy(unsigned char id)
antbig 4:88431b537477 113 {
antbig 4:88431b537477 114 switch(id)
antbig 4:88431b537477 115 {
antbig 4:88431b537477 116 case 1:
antbig 4:88431b537477 117 strcpy(cheminFileStart,"/local/strat1.txt");
antbig 4:88431b537477 118 return FileExists(cheminFileStart);
antbig 4:88431b537477 119 case 2:
antbig 4:88431b537477 120 strcpy(cheminFileStart,"/local/strat2.txt");
antbig 4:88431b537477 121 return FileExists(cheminFileStart);
antbig 7:dcce34c7e06e 122 case 3:
antbig 7:dcce34c7e06e 123 strcpy(cheminFileStart,"/local/strat3.txt");
antbig 7:dcce34c7e06e 124 return FileExists(cheminFileStart);
antbig 4:88431b537477 125 default:
antbig 4:88431b537477 126 strcpy(cheminFileStart,"/local/strat.txt");
antbig 4:88431b537477 127 return 0;
antbig 4:88431b537477 128 }
antbig 4:88431b537477 129 }
antbig 4:88431b537477 130
antbig 3:19f2285a4757 131 #endif