code petit robot pour homologation

Fork of CRAC-Strat_2017_V2 by CRAC Team

Revision:
16:7321fb3bb396
Parent:
15:c2fc239e85df
Child:
18:cc5fec34ed9c
--- a/Strategie/Strategie.cpp	Thu May 11 12:55:52 2017 +0000
+++ b/Strategie/Strategie.cpp	Fri May 19 17:13:46 2017 +0000
@@ -319,13 +319,13 @@
                             localData5 = 0;
                         }
                     }
-                    
+                    #ifdef ROBOT_BIG
                     if(InversStrat == 1) {
                             /*if (instruction.direction == FORWARD) instruction.direction = BACKWARD;
                             else instruction.direction = FORWARD;*/
                             instruction.direction = ((instruction.direction == FORWARD)?BACKWARD:FORWARD);
                         }
-                        
+                    #endif    
                     localData2 = (((instruction.direction == FORWARD)?1:-1)*instruction.arg1);
                     GoStraight(localData2, 0, 0, localData5);
                     
@@ -654,7 +654,6 @@
                 if(waitingAckFrom == msgRxBuffer[FIFO_lecture].id && ((unsigned short)msgRxBuffer[FIFO_lecture].data[0]|((unsigned short)(msgRxBuffer[FIFO_lecture].data[1])<<8) == waitingAckID)) {
                     waitingAckFrom = 0;
                     waitingAckID = 0;
-                    SendRawId(0x123);
                 }
             break;
 #ifdef ROBOT_BIG
@@ -720,11 +719,9 @@
                     msgTx.type=CANData;
                     if(SelectStrategy(msgRxBuffer[FIFO_lecture].data[0])) {
                         // id de la stratégie sur 1 octet
-                        if (msgRxBuffer[FIFO_lecture].data[0] < 0x10){
-                                // Si la strat est une strat de match, on desactive le mode demo
+                        if (msgRxBuffer[FIFO_lecture].data[0] < 0x10){  // Si la strat est une strat de match, on desactive le mode demo
                                 ModeDemo = 0;
-                        } else {
-                                // sinon, on active le mode demo, utile pour la fin de la demo
+                        } else {                                        // sinon, on active le mode demo, utile pour la fin de la demo
                                 ModeDemo = 1;
                         }
                         
@@ -739,24 +736,31 @@
                     tactile_printf("Strat %d, Asser desactive",msgTx.data[0]);
                 }
             break;
+            case BALISE_DANGER :
+                SendAck(ACKNOWLEDGE_BALISE, BALISE_END_DANGER);
+            break;
+            
             case BALISE_STOP:
                 SendAck(ACKNOWLEDGE_BALISE, BALISE_STOP);
-                
-                if(needToStop() != 0 && ingnorBaliseOnce ==0) {
-                    if(gameEtat > ETAT_GAME_START && gameEtat != ETAT_WARNING_TIMEOUT)
-                    {
-                        SendRawId(ASSERVISSEMENT_STOP);
-                        //while(1);
-                        gameEtat = ETAT_WARNING_TIMEOUT;
-                        if(gameEtat != ETAT_WARING_END_BALISE_WAIT) {
-                            timeoutWarning.reset();
-                            timeoutWarning.start();//Reset du timer utiliser par le timeout
+                if (instruction[actual_instruction].order == MV_TURN){ //J'ai rajouté cette ligne mais il faut tester avec et sans pour voir le comportement du robot, 
+                    if(needToStop() != 0 && ingnorBaliseOnce ==0) {
+                        if(gameEtat > ETAT_GAME_START && gameEtat != ETAT_WARNING_TIMEOUT)
+                        {
+                            SendRawId(ASSERVISSEMENT_STOP);
+                            //while(1);
+                            gameEtat = ETAT_WARNING_TIMEOUT;
+                            if(gameEtat != ETAT_WARING_END_BALISE_WAIT) {
+                                timeoutWarning.reset();
+                                timeoutWarning.start();//Reset du timer utiliser par le timeout
+                            }
                         }
                     }
                 }
                 ingnorBaliseOnce = 0;
             break;
+            
             case BALISE_END_DANGER:
+                SendAck(ACKNOWLEDGE_BALISE, BALISE_END_DANGER);
                 if(gameEtat == ETAT_WARNING_TIMEOUT) {
                     timeoutWarningWaitEnd.reset();
                     timeoutWarningWaitEnd.start();