RPiPico-Holonome2023/Strategie_pousse_gateau.c

84 lines
2.7 KiB
C
Raw Normal View History

2023-05-19 22:20:57 +00:00
#include "i2c_annexe.h"
#include "Localisation.h"
2023-05-20 00:19:41 +00:00
#include "Monitoring.h"
2023-05-19 22:20:57 +00:00
#include "Strategie.h"
#include "Trajectoire.h"
#include "Trajet.h"
#include "Geometrie.h"
enum etat_action_t Gateau_pousse_proche(enum couleur_t couleur, uint32_t step_ms){
static enum {
2023-05-20 00:19:41 +00:00
ALLER_1,
ALLER_2,
ALLER_3
} etat=ALLER_1;
float point_x, point_y;
float angle_fin;
2023-05-19 22:20:57 +00:00
struct trajectoire_t trajectoire;
2023-05-20 00:19:41 +00:00
switch(etat){
case ALLER_1:
if(couleur == COULEUR_BLEU){
2023-05-20 00:23:36 +00:00
angle_fin = 90. * DEGRE_EN_RADIAN;
point_x = 310;
2023-05-20 00:19:41 +00:00
}else{
2023-05-20 00:23:36 +00:00
angle_fin = 195. * DEGRE_EN_RADIAN;
point_x = 1700;
2023-05-20 00:19:41 +00:00
}
angle_fin = Geometrie_get_angle_optimal(Localisation_get().angle_radian, angle_fin);
2023-05-19 22:20:57 +00:00
2023-05-20 00:19:41 +00:00
Trajet_config(100, 250);
Trajectoire_droite(&trajectoire, Localisation_get().x_mm, Localisation_get().y_mm, point_x, 3000 - 380,
Localisation_get().angle_radian, angle_fin);
2023-05-19 22:20:57 +00:00
2023-05-20 00:19:41 +00:00
if(parcourt_trajet_simple(trajectoire, step_ms) == ACTION_TERMINEE){
etat=ALLER_2;
2023-05-20 00:23:36 +00:00
i2c_annexe_deplie_bras();
2023-05-20 00:19:41 +00:00
}
break;
case ALLER_2:
2023-05-19 22:20:57 +00:00
if(couleur == COULEUR_BLEU){
2023-05-20 00:19:41 +00:00
angle_fin = 180. * DEGRE_EN_RADIAN;
point_x = 225;
2023-05-19 22:20:57 +00:00
}else{
2023-05-20 00:19:41 +00:00
angle_fin = 180. * DEGRE_EN_RADIAN;
point_x = 1775;
2023-05-19 22:20:57 +00:00
}
angle_fin = Geometrie_get_angle_optimal(Localisation_get().angle_radian, angle_fin);
2023-05-20 00:19:41 +00:00
Trajet_config(250, 250);
Trajectoire_droite(&trajectoire, Localisation_get().x_mm, Localisation_get().y_mm, point_x, 3000 - 1650,
Localisation_get().angle_radian, angle_fin);
2023-05-19 22:20:57 +00:00
2023-05-20 00:19:41 +00:00
if(parcourt_trajet_simple(trajectoire, step_ms) == ACTION_TERMINEE){
2023-05-20 00:23:36 +00:00
i2c_annexe_plie_bras();
2023-05-20 00:19:41 +00:00
etat=ALLER_3;
2023-05-19 22:20:57 +00:00
}
break;
2023-05-20 00:19:41 +00:00
case ALLER_3:
2023-05-19 22:20:57 +00:00
if(couleur == COULEUR_BLEU){
2023-05-20 00:19:41 +00:00
angle_fin = -150. * DEGRE_EN_RADIAN;
point_x = 225;
2023-05-19 22:20:57 +00:00
}else{
2023-05-20 00:19:41 +00:00
angle_fin = 30. * DEGRE_EN_RADIAN;
point_x = 1775;
2023-05-19 22:20:57 +00:00
}
angle_fin = Geometrie_get_angle_optimal(Localisation_get().angle_radian, angle_fin);
2023-05-20 00:19:41 +00:00
Trajet_config(250, 250);
Trajectoire_droite(&trajectoire, Localisation_get().x_mm, Localisation_get().y_mm, point_x, 3000 - 1500,
Localisation_get().angle_radian, angle_fin);
2023-05-19 22:20:57 +00:00
2023-05-20 00:19:41 +00:00
if(parcourt_trajet_simple(trajectoire, step_ms) == ACTION_TERMINEE){
etat=ALLER_1;
return ACTION_TERMINEE;
2023-05-19 22:20:57 +00:00
}
break;
}
2023-05-20 00:19:41 +00:00
return ACTION_EN_COURS;
2023-05-19 22:20:57 +00:00
}