From 869ab64e3f9474e4198dfd30d52fd823ac5dcd17 Mon Sep 17 00:00:00 2001 From: Samuel Date: Tue, 5 May 2026 21:11:16 +0200 Subject: [PATCH] Strategie Ninja1 + Code de calibration sur 1m --- Strategie.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++--- Strategie.h | 1 + main.c | 1 + 3 files changed, 69 insertions(+), 4 deletions(-) diff --git a/Strategie.c b/Strategie.c index 7e07a1b..55d9f24 100644 --- a/Strategie.c +++ b/Strategie.c @@ -10,8 +10,11 @@ enum etat_action_t Strategie_Ninja(uint32_t step_ms, enum couleur_t couleur){ NINJA_INIT, NINJA_GRENIER1, NINJA_GRENIER2A, + NINJA_GRENIER2A_CALAGE, NINJA_GRENIER2B, NINJA_GRENIER2C, + NINJA_GRENIER2C_CALAGE, + NINJA_GRENIER2D, NINJA_FIN } etat_sss = NINJA_INIT; static struct trajectoire_t trajectoire_composee; @@ -45,7 +48,7 @@ enum etat_action_t Strategie_Ninja(uint32_t step_ms, enum couleur_t couleur){ break; case NINJA_GRENIER1: - Trajet_config(TRAJECT_CONFIG_RAPIDE); + Trajet_config(TRAJECT_CONFIG_STD); if(Strategie_parcourir_trajet(trajectoire_composee, step_ms, EVITEMENT_SANS_EVITEMENT) == ACTION_TERMINEE){ etat_sss = NINJA_GRENIER2A; if(couleur == COULEUR_JAUNE){ @@ -55,27 +58,38 @@ enum etat_action_t Strategie_Ninja(uint32_t step_ms, enum couleur_t couleur){ 980, 1850, 980, 1970, 0., 0.); } + } break; case NINJA_GRENIER2A: if(Strategie_parcourir_trajet(trajectoire1, step_ms, EVITEMENT_SANS_EVITEMENT) == ACTION_TERMINEE){ + etat_sss = NINJA_GRENIER2A_CALAGE; + } + break; + + case NINJA_GRENIER2A_CALAGE: + if(Strategie_recale(RECALE_SENS_ARRIERE, step_ms) == ACTION_TERMINEE){ etat_sss = NINJA_GRENIER2B; + Localisation_set_y(1975); + Localisation_set_x(980); + Localisation_set_angle(-M_PI/2); if(couleur == COULEUR_JAUNE){ Trajectoire_bezier(&trajectoire1, - 980, 1970, + 980, 1975, 980, 1850, 1160, 1925, 1420, 1925, 0., 0.); } + } break; + case NINJA_GRENIER2B: if(Strategie_parcourir_trajet(trajectoire1, step_ms, EVITEMENT_SANS_EVITEMENT) == ACTION_TERMINEE){ etat_sss = NINJA_GRENIER2C; if(couleur == COULEUR_JAUNE){ - Trajet_config(TRAJECT_CONFIG_STD); Trajectoire_bezier(&trajectoire1, 1420, 1925, 1377, 1925, @@ -87,7 +101,25 @@ enum etat_action_t Strategie_Ninja(uint32_t step_ms, enum couleur_t couleur){ case NINJA_GRENIER2C: if(Strategie_parcourir_trajet(trajectoire1, step_ms, EVITEMENT_SANS_EVITEMENT) == ACTION_TERMINEE){ - etat_sss = NINJA_FIN; + etat_sss = NINJA_GRENIER2C_CALAGE; + } + break; + + case NINJA_GRENIER2C_CALAGE: + if(Strategie_recale(RECALE_SENS_ARRIERE, step_ms) == ACTION_TERMINEE){ + etat_sss = NINJA_GRENIER2D; + Localisation_set_y(1975); + Localisation_set_x(1354); + Localisation_set_angle(-M_PI/2); + Trajectoire_droite(&trajectoire1, + 1354, 1975, + 1354, 1630., 0., 0.); + } + break; + + case NINJA_GRENIER2D: + if(Strategie_parcourir_trajet(trajectoire1, step_ms, EVITEMENT_SANS_EVITEMENT) == ACTION_TERMINEE){ + etat_sss = ACTION_TERMINEE; } break; @@ -121,6 +153,37 @@ enum etat_action_t Strategie_test(uint32_t step_ms){ return ACTION_EN_COURS; } +enum etat_action_t Strategie_1_metre(uint32_t step_ms){ + static enum{ + TEST_INIT, + TEST_EN_COURS, + TEST_TERMINE + } etat_test = TEST_INIT; + static struct trajectoire_t trajectoire1; + Trajet_config(TRAJECT_CONFIG_STD); + + + switch(etat_test){ + case TEST_INIT: + Localisation_set(0, 0, 0); + Trajectoire_droite(&trajectoire1, + 0, 0, + 1000, 0, 0., 0.); + etat_test = TEST_EN_COURS; + break; + case TEST_EN_COURS: + if(Strategie_parcourir_trajet(trajectoire1, step_ms, EVITEMENT_SANS_EVITEMENT) == ACTION_TERMINEE){ + etat_test = TEST_TERMINE; + } + break; + + case TEST_TERMINE: + return ACTION_TERMINEE; + } + + + return ACTION_EN_COURS; +} void PAMI_dance(int identifiant){ diff --git a/Strategie.h b/Strategie.h index 51e7553..e998d1e 100644 --- a/Strategie.h +++ b/Strategie.h @@ -50,6 +50,7 @@ struct objectif_t{ enum etat_action_t Strategie_Ninja(uint32_t step_ms, enum couleur_t); enum etat_action_t Strategie_test(uint32_t step_ms); +enum etat_action_t Strategie_1_metre(uint32_t step_ms); void PAMI_dance(int); diff --git a/main.c b/main.c index 372a7e6..6f80919 100644 --- a/main.c +++ b/main.c @@ -161,6 +161,7 @@ void gestion_PAMI(uint32_t step_ms, int * asser_pos){ switch (get_identifiant()) { case 0: etat_action = Strategie_Ninja(step_ms, get_couleur()); break; + case 1: etat_action = Strategie_1_metre(step_ms); break; case 7: etat_action = Strategie_test(step_ms); break; default: etat_action = ACTION_TERMINEE; break; }