2023-05-13 18:56:53 +00:00
|
|
|
#include "pico/stdlib.h"
|
2023-05-13 21:03:23 +00:00
|
|
|
#include "Asser_Moteurs.h"
|
2023-05-13 18:56:53 +00:00
|
|
|
#include "Evitement.h"
|
|
|
|
#include "Trajet.h"
|
|
|
|
|
|
|
|
// 250 ms
|
|
|
|
#define TEMPS_VALIDE_OBSTACLE_US 250000
|
|
|
|
|
|
|
|
enum evitement_statu_t evitement_statu=PAS_D_OBSTACLE;
|
|
|
|
|
2023-05-13 21:03:23 +00:00
|
|
|
void Evitement_gestion(int step_ms){
|
2023-05-13 18:56:53 +00:00
|
|
|
static uint32_t temps_obstacle;
|
|
|
|
switch(evitement_statu){
|
|
|
|
case PAS_D_OBSTACLE:
|
2023-05-13 21:03:23 +00:00
|
|
|
if(Trajet_get_bloque() == 1 && AsserMoteur_RobotImmobile(step_ms)){
|
2023-05-13 18:56:53 +00:00
|
|
|
evitement_statu = OBSTACLE_NON_CONFIRME;
|
|
|
|
temps_obstacle = time_us_32();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OBSTACLE_NON_CONFIRME:
|
|
|
|
if(time_us_32() - temps_obstacle > TEMPS_VALIDE_OBSTACLE_US){
|
2023-05-13 21:03:23 +00:00
|
|
|
evitement_statu = OBSTACLE_CONFIRME;
|
2023-05-13 18:56:53 +00:00
|
|
|
}
|
2023-05-13 21:03:23 +00:00
|
|
|
if(!Trajet_get_bloque()){
|
2023-05-13 18:56:53 +00:00
|
|
|
evitement_statu = PAS_D_OBSTACLE;
|
|
|
|
}
|
|
|
|
break;
|
2023-05-13 21:03:23 +00:00
|
|
|
case OBSTACLE_CONFIRME:
|
|
|
|
if(!Trajet_get_bloque()){
|
2023-05-13 18:56:53 +00:00
|
|
|
evitement_statu = PAS_D_OBSTACLE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum evitement_statu_t Evitement_get_statu(){
|
|
|
|
return evitement_statu;
|
|
|
|
}
|