Programme carte strategie (disco)

Dependencies:   mbed SerialHalfDuplex SDFileSystem DISCO-F469NI_portrait liaison_Bluetooth ident_crac

Robots/Strategie_small.cpp

Committer:
Artiom
Date:
2019-05-23
Revision:
54:8996a5b18d9b
Parent:
53:e96acb11a51f
Child:
55:1e3dab1f90f4

File content as of revision 54:8996a5b18d9b:

#include "global.h"

#ifdef ROBOT_SMALL


unsigned char isStopEnable = 1;//Permet de savoir si il faut autoriser le stop via les balises
//unsigned short telemetreDistance;


/****************************************************************************************/
/* FUNCTION NAME: doFunnyAction                                                         */
/* DESCRIPTION  : Permet de faire la funny action en fin de partie                      */
/****************************************************************************************/
void doFunnyAction(void)
{


}


/*************************************************************************************************/
/* FUNCTION NAME: doAction                                                                       */
/* DESCRIPTION  : Effectuer une action specifique correspondant au numéro dans le fichier strat  */
/*************************************************************************************************/
unsigned char doAction(unsigned char id, unsigned short arg1, short arg2)
{
    int retour = 1;
    CANMessage msgTx=CANMessage();
    msgTx.format=CANStandard;
    msgTx.type=CANData;
    switch(id) {
        case 101: //bras gabarit
            SendRawId(GABARIT_PETIT_ROBOT);
            break;
        case 102: //attraper presentoir avant
            SendRawId(PRESENTOIR_AVANT);
            break;
        case 103: //attraper presentoir arriere
            SendRawId(PRESENTOIR_ARRIERE);
            break;
        case 104: //balance avant
            SendRawId(BALANCE_AVANT);
            break;
        case 105: //balance arriere
            SendRawId(BALANCE_ARRIERE);
            break;
        case 106: //accelerateur avant
            SendRawId(ACCELERATEUR_AVANT);
            break;
        case 107: //accelerateur arriere
            SendRawId(ACCELERATEUR_ARRIERE);
            break;
        case 108: //goldenium avant
            SendRawId(GOLDENIUM_AVANT);
            break;
        case 109: //goldenium arriere
            SendRawId(GOLDENIUM_ARRIERE);
            break;
        case 110: //sol avant
            SendRawId(SOL_AVANT);
            break;
        case 111: //sol arriere
            SendRawId(SOL_ARRIERE);
            break;
        case 112: //sol avant relache
            SendRawId(SOL_AVANT_RELACHE);
            break;
        case 113: //sol arriere relache
            SendRawId(SOL_ARRIERE_RELACHE);
            break;
        case 114:
            SendRawId(AVANT_RELACHE);
            break;

        case 115:
            SendRawId(ARRIERE_RELACHE);
            break;

        case 116:
            unsigned char arg_tempo=(unsigned char)arg1;
            SendMsgCan(HACHEUR_RELEASE_ATOM, &arg_tempo,1);
            waitingAckFrom = 0;
            waitingAckID =0;
            break;
        case 117:
            SendRawId(RECROQUEVILLER);
            break;
        case 118:
            SendRawId(VENTOUSE_AV_CENTRE_BALANCE);
            break;
        case 119:
            SendRawId(VENTOUSE_AR_CENTRE_BALANCE);
            break;
        case 120:
            SendRawId(ACCELERATEUR_INSERTION_AVANT_GAUCHE);
            break;
        case 121:
            SendRawId(ACCELERATEUR_INSERTION_DERRIERE_GAUCHE);
            break;

        case 150:
            SCORE_PR+=arg1;
            liaison_Tx.envoyer_short(0x30,SCORE_PR);
            waitingAckFrom = 0;
            waitingAckID = 0;
            break;


        case 200 :
            SendRawId(DATA_TELEMETRE);
            /*telemetreDistance = dataTelemetre();
            wait_ms(1);
            telemetreDistance = dataTelemetre();
            telemetreDistance = telemetreDistance - 170;*/
            break;

        case 201 :
            SendRawId(0x99);
            retour = 2;
            break;

        case 10://Désactiver le stop
            isStopEnable = 0;
            break;
        case 11://Activer le stop
            isStopEnable = 1;
            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(arg1,(unsigned short)arg2);
            wait_us(200);
            waitingAckFrom = 0;
            waitingAckID = 0;
            break;

        case 19: // CHANGER LA VITESSE + DECELERATION
            //SendSpeedDecel(arg1,(unsigned short) arg2);
            wait_us(200);
            waitingAckFrom = 0;
            waitingAckID =0;
            break;

        case 30://Action tempo
            wait_ms(arg1);
            break;

        default:
            retour = 0;//L'action n'existe pas, il faut utiliser le CAN

    }
    return retour;//L'action est spécifique.

}



/****************************************************************************************/
/* 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)
{

}

#endif