code petit robot pour homologation

Fork of CRAC-Strat_2017_V2 by CRAC Team

Committer:
antbig
Date:
Sat Apr 23 09:16:14 2016 +0000
Revision:
5:dcd817534b57
Parent:
4:88431b537477
Child:
7:dcce34c7e06e
Ajout du choix de la couleur et de l'id de la strat?gie ? utiliser via CAN

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 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 5:dcd817534b57 65 break;
antbig 3:19f2285a4757 66 default:
antbig 3:19f2285a4757 67 return 0;//L'action n'existe pas, il faut utiliser le CAN
antbig 3:19f2285a4757 68
antbig 3:19f2285a4757 69 }
antbig 3:19f2285a4757 70 return 1;//L'action est spécifique.
antbig 3:19f2285a4757 71
antbig 3:19f2285a4757 72 }
antbig 3:19f2285a4757 73
antbig 3:19f2285a4757 74 /****************************************************************************************/
antbig 3:19f2285a4757 75 /* FUNCTION NAME: initRobot */
antbig 3:19f2285a4757 76 /* DESCRIPTION : initialiser le robot */
antbig 3:19f2285a4757 77 /****************************************************************************************/
antbig 3:19f2285a4757 78 void initRobot(void) {
antbig 3:19f2285a4757 79 /**
antbig 3:19f2285a4757 80 On enregistre les id des AX12 présent sur la carte
antbig 3:19f2285a4757 81 **/
antbig 5:dcd817534b57 82 AX12_register(1,AX12_SERIAL1,0x0FF);
antbig 5:dcd817534b57 83 AX12_register(2,AX12_SERIAL1);
antbig 5:dcd817534b57 84 AX12_register(18,AX12_SERIAL1);
antbig 5:dcd817534b57 85 AX12_register(4,AX12_SERIAL2);
antbig 5:dcd817534b57 86 AX12_register(16,AX12_SERIAL2);
antbig 5:dcd817534b57 87 AX12_register(17,AX12_SERIAL2,0x0FF);
antbig 5:dcd817534b57 88 /*
antbig 5:dcd817534b57 89 AX12_setGoal(AX12_ID_BRAS_BASE_INV,278,0x0FF);
antbig 5:dcd817534b57 90 AX12_setGoal(AX12_ID_BRAS_RELACHEUR_INV,160);//fermer le bras
antbig 5:dcd817534b57 91 AX12_setGoal(AX12_ID_BRAS_BASE,278,0x0FF);
antbig 5:dcd817534b57 92 AX12_setGoal(AX12_ID_BRAS_RELACHEUR,160);//fermer le bras
antbig 5:dcd817534b57 93 AX12_processChange();*/
antbig 3:19f2285a4757 94 }
antbig 3:19f2285a4757 95
antbig 4:88431b537477 96 /****************************************************************************************/
antbig 4:88431b537477 97 /* FUNCTION NAME: SelectStrategy */
antbig 4:88431b537477 98 /* DESCRIPTION : Charger le fichier de stratégie correspondante à un id */
antbig 4:88431b537477 99 /* RETURN : 0=> Erreur, 1=> OK si le fichier existe */
antbig 4:88431b537477 100 /****************************************************************************************/
antbig 4:88431b537477 101 int SelectStrategy(unsigned char id)
antbig 4:88431b537477 102 {
antbig 4:88431b537477 103 switch(id)
antbig 4:88431b537477 104 {
antbig 4:88431b537477 105 case 1:
antbig 4:88431b537477 106 strcpy(cheminFileStart,"/local/strat1.txt");
antbig 4:88431b537477 107 return FileExists(cheminFileStart);
antbig 4:88431b537477 108 case 2:
antbig 4:88431b537477 109 strcpy(cheminFileStart,"/local/strat2.txt");
antbig 4:88431b537477 110 return FileExists(cheminFileStart);
antbig 4:88431b537477 111 default:
antbig 4:88431b537477 112 strcpy(cheminFileStart,"/local/strat.txt");
antbig 4:88431b537477 113 return 0;
antbig 4:88431b537477 114 }
antbig 4:88431b537477 115 }
antbig 4:88431b537477 116
antbig 3:19f2285a4757 117 #endif