TRR2018 omar

Dependencies:   mbed

Fork of biniou by TRR 2018

stateMachines.cpp

Committer:
GaspardD
Date:
2018-09-08
Revision:
8:1d8c3ca5e508
Parent:
3:03ea98f5b2e4
Child:
9:747fd4a80225

File content as of revision 8:1d8c3ca5e508:

#include "states_m.h"


#define NB_ECHANTILLONS_IR 4
#define NB_ECHANTILLONS_LIDAR 4

#define CORRECTEUR_P 1;
#define CORRECTEUR_I 0;
#define CORRECTEUR_D 0;

static int mode_courant = ; // mettre en define pour la compilation ? ou régler via télécommande ?

uint16_t dist_murGF[NB_ECHANTILLONS_IR];//buffer tournant ir avant gauche pour moyenne
uint16_t dist_murGL[NB_ECHANTILLONS_IR];//buffer tournant ir coté gauche pour moyenne
uint16_t dist_murDF[NB_ECHANTILLONS_IR];//buffer tournant ir avant droit pour moyenne
uint16_t dist_murDL[NB_ECHANTILLONS_IR];//buffer tournant ir coté droit pour moyenne
int dist_obstacle_lidar[NB_ECHANTILLONS_LIDAR];//buffer tournant
int index_fifo_ir = 0;//pour géreer le buffer tournant
int index_fifo_lidar = 0;

int tachy_cmps;

//Capteurs

AnalogIn anaGF(A0);//capteur ir avant gauche
AnalogIn anaGL(A1);//capteur ir coté gauche
AnalogIn anaDF(A2);//capteur ir avant droit
AnalogIn anaDL(A3);//capteur ir coté droit

int lidarStr;
int lidarDist;

//Etats
SECTION_ST st_CurrentSection;
OBSTACLE_ST st_obstacleDet;
MUR_ST st_murs;
THROTTLE_ST st_thro;

//time monitoring

Timer temps;// temps.start()/stop()/sec: read()/ms: read_ms()/µs: read_us()



//########## INIT STATES MACHINES ##########
void murs_init(void)
{
    st_murs=MUR_GD_OK;
    return;
}
void obstacle_init(void)
{
    st_obstacleDet=LONG_RANGE_CLEAR;
    return;
}
void section_init(void)
{
    temps.reset();
    temps.start();
    st_CurrentSection=ARRET;
    return;
}
void throttle_init(void)
{
    st_thro = AT_SPEED;
    return;
}


//########## UPDATE STATES ##########
void murs_update(void)
{
    MUR_ST st_tmp_murs;
    dist_murGF=anaGF.read_u16();
    dist_murGL=anaGL.read_u16();
    dist_murDF=anaDF.read_u16();
    dist_murDL=anaDL.read_u16();

    if(1)
    {
        st_tmp_murs = MUR_GD_OK;
    }else
    {
        st_tmp_murs = MURS_ABSENTS;
    }

    st_murs = st_tmp_murs;
    return;
}
void obstacle_update(void)
{
    return;
}
void section_update(void)
{
    return;
}

void throttle_update(void)
{
    return;
}

//########## OUTPUT STATES ##########
void murs_output(void)
{
    return;
}

void obstacle_output(void)
{
    return;
}
void section_output(void)
{
    return;
}

void throttle_output(void)
{
    return;
}