code avec modifs, programme mit dans les robots pour les derniers matchs

Dependencies:   mbed SerialHalfDuplex SDFileSystem liaison_Bluetooth ident_crac DISCO-F469NI_portrait

Files at this revision

API Documentation at this revision

Comitter:
gabrieltetar
Date:
Fri Jan 31 14:37:29 2020 +0000
Parent:
4:3abef005c4fa
Child:
6:ef2418d23a06
Commit message:
Suppression de la discrimination entre gros et petit robot

Changed in this revision

Globals/constantes.h Show annotated file Show diff for this revision Revisions of this file
Robots/Strategie_big.cpp Show diff for this revision Revisions of this file
Strategie/Strategie.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Globals/constantes.h	Fri Jan 31 07:12:17 2020 +0000
+++ b/Globals/constantes.h	Fri Jan 31 14:37:29 2020 +0000
@@ -18,33 +18,13 @@
 
 //------------------------------------sellection Robot---------------------
 //
-#define ROBOT_BIG //Si commenté Petit Robot,  si Décommenter Gros Robot
+#define ROBOT_SMALL
 
-#ifndef ROBOT_BIG       //  !!!!!!!! ne pas commenter
-    #define ROBOT_SMALL //  !!!!!!!! ne pas commenter
-#endif                  //  !!!!!!!! ne pas commenter
  
 //-------------------------------------------------------------------------
 
 
-#ifdef ROBOT_BIG
 
-    #define NOMBRE_CARTES           2//Le nombre de carte présente sur le gros robot
-    //#define POSITION_DEBUT_X 1830
-    //#define POSITION_DEBUT_Y 900
-    //#define POSITION_DEBUT_T 180
-    
-    #define POSITION_DEBUT_X 200
-    #define POSITION_DEBUT_Y 880
-    #define POSITION_DEBUT_T 0
-    #define MOITIEE_ROBOT    61
-    //#define POSITION_DEBUT_X 0
-    //#define POSITION_DEBUT_Y 0
-    //#define POSITION_DEBUT_T 0
-    
-    #define BALISE_TIMEOUT 5000
-    
-#else
 
     #define NOMBRE_CARTES           2//Le nombre de carte présente sur le petit robot
     #define POSITION_DEBUT_X 210
@@ -53,7 +33,7 @@
     #define MOITIEE_ROBOT 90
     #define BALISE_TIMEOUT 2000
     
-#endif
+
 
 
 
--- a/Robots/Strategie_big.cpp	Fri Jan 31 07:12:17 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,305 +0,0 @@
-#include "global.h"
-#ifdef ROBOT_BIG
-
-unsigned short x;
-unsigned short y;
-unsigned char isStopEnable = 1;//Permet de savoir si il faut autoriser le stop via les balises
-
-/****************************************************************************************/
-/* FUNCTION NAME: doFunnyAction                                                         */
-/* DESCRIPTION  : Permet de faire la funny action en fin de partie                      */
-/****************************************************************************************/
-void doFunnyAction(void)
-{
-    //envoie de la funny action
-    // 0x007, 01, 01
-    CANMessage msgTx=CANMessage();
-    msgTx.id=GLOBAL_FUNNY_ACTION;
-    msgTx.format=CANStandard;
-    msgTx.type=CANData;
-    msgTx.len=2;
-    msgTx.data[0]=0x01;
-    msgTx.data[1]=0x01;
-    can1.write(msgTx);
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: doAction                                                              */
-/* DESCRIPTION  : Effectuer une action specifique                                       */
-/****************************************************************************************/
-unsigned char doAction(unsigned char id, unsigned short var1, short var2)
-{
-    CANMessage msgTx=CANMessage();
-    msgTx.format=CANStandard;
-    msgTx.type=CANData;
-    //affichage_debug(id);
-
-    switch(id) {
-        /////////////////////////////////////////////////////////100 à 108 : ACTIONS HERKULEX/////////////////////////////////////////////
-        case 118:
-            SendRawId(VENTOUSE_AV_CENTRE_BALANCE);
-            break;
-
-        case 201:
-            unsigned char var_tempo;
-            var_tempo = (unsigned char)var1;//0auto 1forceon 2 forceoff
-            SendMsgCan(ASCENSEUR, &var_tempo,1);
-            waitingAckFrom = 0;
-            waitingAckID =0;
-            break;
-
-        case 202:
-            msgTx.id=VIDER_CONVOYEUR;
-            msgTx.len=1;
-            msgTx.data[0]=(unsigned char)var1; //
-            can2.write(msgTx);
-            break;
-
-        case 203:
-            x = var1;
-            if(InversStrat == 1) {
-                y = 3000 - var2;
-            } else {
-                y = var2;
-            }
-            Send2Short(GOLDENIUM_AVANT, x, y);
-            break;
-
-        case 204:
-            unsigned char arg_tempo;
-            if(InversStrat == 1) {
-                switch(var1) {
-                    case AV_DROIT:
-                        arg_tempo = AV_GAUCHE;
-                        break;
-                    case AV_GAUCHE:
-                        arg_tempo = AV_DROIT;
-                        break;
-                    default :
-                        arg_tempo =(unsigned char)var1;
-                        break;
-                }
-
-            } else arg_tempo =(unsigned char)var1;
-            SendMsgCan(HACHEUR_RELEASE_ATOM, &arg_tempo,1);
-            waitingAckFrom = 0;
-            waitingAckID =0;
-            break;
-
-        case 205:
-            SendRawId(PRESENTOIR_AVANT);
-            break;
-            
-        case 206:
-            SendMsgCan(RATEAU, (unsigned char*)&var1,1);
-            break;
-
-
-        case 150:
-            SCORE_GR+=var1;
-            SCORE_GLOBAL=SCORE_GR+SCORE_PR;
-            //liaison_Tx.envoyer_short(0x30,SCORE_GLOBAL);
-            waitingAckFrom = 0;
-            waitingAckID = 0;
-            break;
-
-
-        case 11://0 Désactiver le stop,1 Activer le stop saut de strat,2 Activer le stop avec evitement
-            isStopEnable =(unsigned char) var1;
-            // SendMsgCan(0x5BC, &isStopEnable,1);
-            waitingAckFrom = 0;
-            waitingAckID =0;
-            break;
-
-        case 20://Désactiver l'asservissement
-            setAsservissementEtat(0);
-            break;
-
-        case 21://Activer l'asservissement
-            setAsservissementEtat(1);
-            break;
-
-        case 22://Changer la vitesse du robot
-            SendSpeed(var1);
-            waitingAckFrom = 0;
-            waitingAckID = 0;
-            wait(0.2);
-            break;
-
-        case 23:
-            SendAccel((unsigned short)var1,(unsigned short)var2);//,(unsigned short)arg2, (unsigned short)arg2);
-            wait_us(200);
-            waitingAckFrom = 0;
-            waitingAckID = 0;
-            break;
-
-        case 30://Action tempo
-            wait_ms(var1);
-            waitingAckFrom = 0;
-            waitingAckID = 0;
-            break;
-
-
-
-        default:
-            return 0;//L'action n'existe pas, il faut utiliser le CAN
-
-    }
-    return 1;//L'action est spécifique.
-
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: initRobot                                                             */
-/* DESCRIPTION  : initialiser le robot                                                  */
-/****************************************************************************************/
-void initRobot(void)
-{
-    //Enregistrement de tous les AX12 présent sur la carte
-    /*AX12_register(5,  AX12_SERIAL2);
-    AX12_register(18, AX12_SERIAL2);
-    AX12_register(13, AX12_SERIAL2);
-    AX12_register(1,  AX12_SERIAL1);
-    AX12_register(11,  AX12_SERIAL1);
-    AX12_register(8,  AX12_SERIAL1);
-    AX12_register(7,  AX12_SERIAL2);*/
-
-    //AX12_setGoal(AX12_ID_FUNNY_ACTION, AX12_ANGLE_FUNNY_ACTION_CLOSE,AX12_SPEED_FUNNY_ACTION);
-    //AX12_processChange();
-    //runRobotTest();
-
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: initRobotActionneur                                                   */
-/* DESCRIPTION  : Initialiser la position des actionneurs du robot                      */
-/****************************************************************************************/
-void initRobotActionneur(void)
-{
-    /*doAction(100,1,0);
-    doAction(100,2,0);
-    doAction(110,0,0);
-    doAction(120,0,0);
-    doAction(131,0,0);*/
-
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: runTest                                                               */
-/* DESCRIPTION  : tester l'ensemble des actionneurs du robot                            */
-/****************************************************************************************/
-void runRobotTest(void)
-{
-    /*
-    int waitTime = 500;
-
-    //Test des AX12 dans l'ordre
-    doAction(111,0,0);//Fermeture pince arrière haute
-    wait_ms(waitTime);
-    doAction(110,0,0);//Ouverture pince arrière haute
-    wait_ms(waitTime);
-    doAction(113,0,0);//Fermeture pince arrière basse
-    wait_ms(waitTime);
-    doAction(112,0,0);//Ouverture pince arrière basse
-    wait_ms(waitTime);
-    doAction(115,0,0);//Fermeture porte arrière
-    wait_ms(waitTime);
-    doAction(114,0,0);//Ouverture porte arrière
-    wait_ms(waitTime);
-    doAction(101,0,0);//Fermer les portes avant
-    wait_ms(waitTime);
-    doAction(100,0,0);//Ouvrir les portes avant
-    wait_ms(waitTime);
-    doAction(103,0,0);//Descendre le peigne
-    wait_ms(waitTime);
-    doAction(102,0,0);//Remonter le peigne*/
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: SelectStrategy                                                        */
-/* DESCRIPTION  : Charger le fichier de stratégie correspondante à un id                */
-/* RETURN       : 0=> Erreur, 1=> OK si le fichier existe                               */
-/****************************************************************************************/
-/*int SelectStrategy(unsigned char id)
-{
-    switch(id)
-    {
-        // strat de match
-        case 1:
-            strcpy(cheminFileStart,"/local/strat1.txt");
-            return FileExists(cheminFileStart);
-        case 2:
-            strcpy(cheminFileStart,"/local/strat2.txt");
-            return FileExists(cheminFileStart);
-        case 3:
-            strcpy(cheminFileStart,"/local/strat3.txt");
-            return FileExists(cheminFileStart);
-        case 4:
-            strcpy(cheminFileStart,"/local/strat4.txt");
-            return FileExists(cheminFileStart);
-        case 5:
-            strcpy(cheminFileStart,"/local/strat5.txt");
-            return FileExists(cheminFileStart);
-        case 6:
-            strcpy(cheminFileStart,"/local/strat6.txt");
-            return FileExists(cheminFileStart);
-        case 7:
-            strcpy(cheminFileStart,"/local/strat7.txt");
-            return FileExists(cheminFileStart);
-        case 8:
-            strcpy(cheminFileStart,"/local/strat8.txt");
-            return FileExists(cheminFileStart);
-        case 9:
-            strcpy(cheminFileStart,"/local/strat9.txt");
-            return FileExists(cheminFileStart);
-        case 10:
-            strcpy(cheminFileStart,"/local/strat10.txt");
-            return FileExists(cheminFileStart);
-
-        // strat de demo
-        case 0x10:
-            strcpy(cheminFileStart,"/local/moteur.txt");
-            return FileExists(cheminFileStart);
-        case 0x11:
-#ifdef ROBOT_BIG
-            strcpy(cheminFileStart,"/local/bras.txt");
-#else
-            strcpy(cheminFileStart,"/local/porteAvant.txt");
-#endif
-            return FileExists(cheminFileStart);
-        case 0x12:
-#ifdef ROBOT_BIG
-            strcpy(cheminFileStart,"/local/balancier.txt");
-#else
-            strcpy(cheminFileStart,"/local/mainTourneuse.txt");
-#endif
-            return FileExists(cheminFileStart);
-        default:
-            strcpy(cheminFileStart,"/local/strat1.txt");
-            return 0;
-    }
-}*/
-
-/****************************************************************************************/
-/* FUNCTION NAME: needToStop                                                            */
-/* DESCRIPTION  : Savoir si il faut autoriser le stop du robot via balise               */
-/****************************************************************************************/
-unsigned char needToStop(void)
-{
-    return isStopEnable;
-}
-
-/****************************************************************************************/
-/* FUNCTION NAME: doBeforeEndAction                                                     */
-/* DESCRIPTION  : Terminer les actions du robot 1s avant la fin du match                */
-/****************************************************************************************/
-void doBeforeEndAction(void)
-{
-    doAction(110,0,0);//Ouverture pince arrière haute
-    doAction(112,0,0);//Ouverture pince arrière basse
-    doAction(114,0,0);//Ouverture porte arrière
-    doAction(100,0,0);//Ouvrir les portes avant
-    doAction(102,0,0);//Remonter le peigne
-}
-
-#endif
--- a/Strategie/Strategie.cpp	Fri Jan 31 07:12:17 2020 +0000
+++ b/Strategie/Strategie.cpp	Fri Jan 31 14:37:29 2020 +0000
@@ -187,24 +187,12 @@
 unsigned char DT_ARG_interrupt=0;
 
 
-#ifdef ROBOT_BIG
-
-
-unsigned short id_check[NOMBRE_CARTES]= {CHECK_MOTEUR,CHECK_BALISE};
-unsigned short id_alive[NOMBRE_CARTES]= {ALIVE_MOTEUR,ALIVE_BALISE};
-
-InterruptIn jack(PG_11); //  entrée numerique en interruption pour le jack
-#else
-
 
 unsigned short id_check[NOMBRE_CARTES]= {CHECK_MOTEUR,CHECK_BALISE};
 unsigned short id_alive[NOMBRE_CARTES]= {ALIVE_MOTEUR,ALIVE_BALISE};
 InterruptIn jack(PG_11); //  entrée numerique en interruption pour le jack
 
 
-#endif
-
-
 
 
 
@@ -462,23 +450,9 @@
                     while(1) {
                         TEST_TIR_BALLE.Draw(0xFFF0F0F0, 0);
                         // rn42_Tx.printf("A");//experience
-#ifdef ROBOT_SMALL
                         liaison_Tx.envoyer_short(0x30,666);
                         pc.printf("data\r");
-#else
 
-                        // lire();
-                        /*  if (bluetooth.readable())
-                              pc.putc(bluetooth.getc());
-
-                          if (pc.readable()) {
-                              char c = pc.getc();
-                              if (c == 'A') {
-                                  liaison.envoyer_short(PAQUET_IDENTIFIANT_RAFRAICHIRSCORE, 20);
-                                  pc.printf("rafraichir\n");
-                              }
-                          }*/
-#endif
                     }
                     //ModeDemo=1;
                 } else if(TEST_IMMEUBLE.Touched()) {
@@ -718,11 +692,7 @@
                 lcd.Clear(VERT);
                 // affichage_compteur(100-cpt);
                 //affichage_compteur(SCORE_PR);
-#ifdef ROBOT_BIG
-                affichage_var(SCORE_GR);
-#else
                 affichage_var(SCORE_PR);
-#endif
                 if(liaison_pr.paquet_en_attente()) {
                     PaquetDomotique *paquet=liaison_pr.lire();
                     if(paquet->identifiant==PAQUET_IDENTIFIANT_AJOUTERSCORE) {
@@ -742,14 +712,10 @@
         case FIN :  //AFFICHAGE DE FIN AVEC LE SCORE FINAL
             lcd.Clear (LCD_COLOR_WHITE);
             lcd.SetBackColor(LCD_COLOR_WHITE);
-#ifdef ROBOT_BIG
-            // affichage_compteur(SCORE_GR);
-            affichage_var(SCORE_GR);
-            //liaison_Tx.envoyer_short(PAQUET_IDENTIFIANT_FINMATCH,SCORE_GLOBAL);
-#else
+
             //affichage_compteur(SCORE_PR);
             affichage_var(SCORE_PR);
-#endif
+
             while(1); // force le redemarage du robot
             //break;
 
@@ -904,11 +870,7 @@
                         SendRawId(RECALAGE_START);
                         waitingAckID = ASSERVISSEMENT_RECALAGE;
                         waitingAckFrom = ACKNOWLEDGE_MOTEUR;
-#ifdef ROBOT_SMALL
                         GoStraight(3000, 1,MOITIEE_ROBOT, 0);  //on se recale contre le mur donc il faut donner la valeur du centre du robot (les -5 qui trainent sont dus au tables pourraves sur place)
-#else
-                        GoStraight(-3000, 1,MOITIEE_ROBOT, 0);
-#endif
                         while(waitingAckID !=0 && waitingAckFrom !=0)
                             canProcessRx();
                         waitingAckID_FIN=ASSERVISSEMENT_RECALAGE;
@@ -921,11 +883,7 @@
                     case RECULER_1:
                         waitingAckID = ASSERVISSEMENT_RECALAGE;
                         waitingAckFrom = ACKNOWLEDGE_MOTEUR;
-#ifdef ROBOT_SMALL
                         GoStraight(-100, 0, 0, 0);//-450
-#else
-                        GoStraight(250, 0, 0, 0);
-#endif
                         while(waitingAckID !=0 && waitingAckFrom !=0)
                             canProcessRx();
                         waitingAckID_FIN=ASSERVISSEMENT_RECALAGE;
@@ -961,11 +919,7 @@
                         } else {
                             localData3=MOITIEE_ROBOT;
                         }
-#ifdef ROBOT_SMALL
                         GoStraight(3000, 2,localData3, 0);  //on se recale contre le mur donc il faut donner la valeur du centre du robot
-#else
-                        GoStraight(-3000, 2,localData3, 0);
-#endif
                         while(waitingAckID !=0 && waitingAckFrom !=0)
                             canProcessRx();
                         waitingAckID_FIN=ASSERVISSEMENT_RECALAGE;
@@ -978,11 +932,7 @@
                     case RECULER_2:
                         waitingAckID = ASSERVISSEMENT_RECALAGE;
                         waitingAckFrom = ACKNOWLEDGE_MOTEUR;
-#ifdef ROBOT_SMALL
                         GoStraight(-100, 0, 0, 0);
-#else
-                        GoStraight(250, 0, 0, 0);
-#endif
                         while(waitingAckID !=0 && waitingAckFrom !=0)
                             canProcessRx();
                         waitingAckID_FIN=ASSERVISSEMENT_RECALAGE;
@@ -1163,19 +1113,11 @@
                     }*/
 
                     BendRadius(instruction.arg1, localData2, localData1, localData5);
-#ifdef ROBOT_SMALL
                     if(localData2>0) {
                         direction=1;
                     } else {
                         direction=-1;
                     }
-#else
-                    if(localData2>0) {
-                        direction=-1;
-                    } else {
-                        direction=1;
-                    }
-#endif
                     if(localData2>0)alph=localData2;
                     else alph=-localData2;
                     alpha = localData2*M_PI/1800.0f;
@@ -1428,12 +1370,7 @@
                         } else {
                             gameEtat = ETAT_GAME_WAIT_ACK;
                         }
-#ifdef ROBOT_SMALL
-                        /*actual_instruction = instruction.nextLineOK;//On indique que l'on va charger l'instruction suivante
-                        gameEtat = ETAT_GAME_LOAD_NEXT_INSTRUCTION;*/
-#endif
                         return;
-#ifdef ROBOT_SMALL
                     } else if (tempo == 2) {
                         // on est dans le cas de l'avance selon le telemetre
                         waitingAckID = ASSERVISSEMENT_RECALAGE;
@@ -1443,7 +1380,6 @@
                         GoStraight(telemetreDistance, 0, 0, 0);
                         // on reset la distance du telemetre à 0
                         telemetreDistance = 5000;
-#endif
                     } else {
                         //C'est un AX12 qu'il faut bouger
                         //AX12_setGoal(instruction.arg1,instruction.arg3/10,instruction.arg2);
@@ -1789,25 +1725,6 @@
                                }
                      */
                 break;
-
-
-#ifdef ROBOT_BIG
-#define point_balance 12
-#define point_accelerateur 10
-            case NB_PALETS_BLEU: //nb de palets bleu mis dans l'accelerateur
-                unsigned short palets_bleu=(unsigned short)msgRxBuffer[FIFO_lecture].data[0];
-                SCORE_GR+=palets_bleu*point_balance;
-                //SCORE_GLOBAL=SCORE_GR+SCORE_PR;
-                //liaison_Tx.envoyer_short(0x30,SCORE_GLOBAL);
-                break;
-
-            case NB_PALETS_VERTS://nb de palets vert/rouge mis dans l'accelerateur
-                unsigned short palets_verts=(unsigned short)msgRxBuffer[FIFO_lecture].data[0];
-                SCORE_GR+=palets_verts*point_accelerateur;
-                //SCORE_GLOBAL=SCORE_GR+SCORE_PR;
-                //liaison_Tx.envoyer_short(0x30,SCORE_GLOBAL);
-                break;
-#endif
             case ODOMETRIE_BIG_POSITION:
             case ODOMETRIE_SMALL_POSITION:
 
--- a/main.cpp	Fri Jan 31 07:12:17 2020 +0000
+++ b/main.cpp	Fri Jan 31 14:37:29 2020 +0000
@@ -66,11 +66,7 @@
     can1.frequency(1000000); // fréquence de travail 1Mbit/s
     can2.attach(&canRx_ISR); // création de l'interrupt attachée à la réception sur le CAN
     can2.frequency(1000000);
-#ifdef ROBOT_BIG
-    lcd.DisplayStringAt(0, 0,(uint8_t *)"Initialisation gros robot", LEFT_MODE);
-#else
-    lcd.DisplayStringAt(0, 0,(uint8_t *)"Initialisation petit robot", LEFT_MODE);
-#endif
+    lcd.DisplayStringAt(0, 0,(uint8_t *)"Initialisation", LEFT_MODE);
     led1 = 1;
     bluetooth_init();
     lecture_fichier(); //bloquant si pas de carte SD