carte_strategie_2019
Dependencies: mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac
Diff: Robots/Strategie_big.cpp
- Revision:
- 84:44d6cd2cab99
- Parent:
- 83:23e04b85ae06
- Child:
- 86:05a0c066bdbe
--- a/Robots/Strategie_big.cpp Fri May 31 05:02:55 2019 +0000 +++ b/Robots/Strategie_big.cpp Fri May 31 17:33:28 2019 +0000 @@ -9,24 +9,26 @@ /* FUNCTION NAME: doFunnyAction */ /* DESCRIPTION : Permet de faire la funny action en fin de partie */ /****************************************************************************************/ -void doFunnyAction(void) { +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); + 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) { +unsigned char doAction(unsigned char id, unsigned short var1, short var2) +{ CANMessage msgTx=CANMessage(); msgTx.format=CANStandard; msgTx.type=CANData; @@ -37,42 +39,36 @@ case 118: SendRawId(VENTOUSE_AV_CENTRE_BALANCE); break; - case 201: + + 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: + + case 202: msgTx.id=VIDER_CONVOYEUR; - msgTx.len=1; - msgTx.data[0]=(unsigned char)var1; - + msgTx.data[0]=(unsigned char)var1; // can2.write(msgTx); break; - - case 203: + + case 203: x = var1; - if(InversStrat == 1) - { + if(InversStrat == 1) { y = 3000 - var2; - } - else - { + } else { y = var2; } - Send2Short(GOLDENIUM_AVANT, x, y); break; - + case 204: unsigned char arg_tempo; - if(InversStrat == 1) - { - switch(var1){ + if(InversStrat == 1) { + switch(var1) { case AV_DROIT: arg_tempo = AV_GAUCHE; break; @@ -83,19 +79,18 @@ arg_tempo =(unsigned char)var1; break; } - - } - else arg_tempo =(unsigned char)var1; + + } 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 150: SCORE_GR+=var1; SCORE_GLOBAL=SCORE_GR+SCORE_PR; @@ -103,57 +98,58 @@ 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 + + + 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); + // SendMsgCan(0x5BC, &isStopEnable,1); waitingAckFrom = 0; waitingAckID =0; break; - + case 20://Désactiver l'asservissement setAsservissementEtat(0); - break; - + break; + case 21://Activer l'asservissement setAsservissementEtat(1); - break; - + break; + case 22://Changer la vitesse du robot SendSpeed(var1); waitingAckFrom = 0; waitingAckID = 0; wait(0.2); - break; + break; + case 23: SendAccel(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; - - - + 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) +void initRobot(void) { //Enregistrement de tous les AX12 présent sur la carte /*AX12_register(5, AX12_SERIAL2); @@ -163,11 +159,11 @@ 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(); - + } /****************************************************************************************/ @@ -176,23 +172,23 @@ /****************************************************************************************/ void initRobotActionneur(void) { - /*doAction(100,1,0); + /*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) +void runRobotTest(void) { /* int waitTime = 500; - + //Test des AX12 dans l'ordre doAction(111,0,0);//Fermeture pince arrière haute wait_ms(waitTime); @@ -255,7 +251,7 @@ case 10: strcpy(cheminFileStart,"/local/strat10.txt"); return FileExists(cheminFileStart); - + // strat de demo case 0x10: strcpy(cheminFileStart,"/local/moteur.txt");