Non testé : Ajout panneaux solaires
This commit is contained in:
		
							parent
							
								
									d414eb1d07
								
							
						
					
					
						commit
						09e0c50a9f
					
				| @ -32,6 +32,7 @@ Score.c | |||||||
| Servomoteur.c | Servomoteur.c | ||||||
| Strategie.c | Strategie.c | ||||||
| Strategie_deplacement.c | Strategie_deplacement.c | ||||||
|  | Strategie_2024_panneaux.c | ||||||
| Strategie_2024_plante.c | Strategie_2024_plante.c | ||||||
| Strategie_2024_pots.c | Strategie_2024_pots.c | ||||||
| Strategie_2024.c | Strategie_2024.c | ||||||
|  | |||||||
							
								
								
									
										38
									
								
								Score.c
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								Score.c
									
									
									
									
									
								
							| @ -2,22 +2,20 @@ | |||||||
| #include "i2c_annexe.h" | #include "i2c_annexe.h" | ||||||
| #include "Score.h" | #include "Score.h" | ||||||
| 
 | 
 | ||||||
| #define SCORE_INITIAL 5 | #define SCORE_INITIAL 0 | ||||||
| 
 | 
 | ||||||
| uint32_t Score_nb_cerises=0; | uint32_t Score_nb_points; | ||||||
| uint32_t Score_nb_points=0; | uint32_t Score_plante_zone_normale=0; | ||||||
| uint32_t Score_funny_action=0; | uint32_t Score_plante_jardiniere=0; | ||||||
| uint32_t Score_gateau=0; | uint32_t Score_panneau=0; | ||||||
| uint32_t Score_pieds_dans_plat=0; | uint32_t Score_pieds_dans_plat=0; | ||||||
| 
 | 
 | ||||||
| void Score_recalcule(){ | void Score_recalcule(){ | ||||||
|     Score_nb_points = SCORE_INITIAL; |     Score_nb_points = SCORE_INITIAL; | ||||||
|     if(Score_nb_cerises > 0){ |     Score_nb_points += Score_plante_zone_normale; | ||||||
|         Score_nb_points += Score_nb_cerises + 5; |     Score_nb_points += Score_plante_jardiniere; | ||||||
|     } |     Score_nb_points += Score_panneau; | ||||||
|     Score_nb_points += Score_funny_action; |  | ||||||
|     Score_nb_points += Score_pieds_dans_plat; |     Score_nb_points += Score_pieds_dans_plat; | ||||||
|     Score_nb_points += Score_gateau; |  | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -26,23 +24,15 @@ void Score_actualise(){ | |||||||
|     i2c_annexe_envoie_score(Score_nb_points); |     i2c_annexe_envoie_score(Score_nb_points); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Score_ajout_gateau(uint32_t nb_gateau){ | /// @brief 10 points si le robot finit dans une autre zone que la sienne
 | ||||||
|     Score_gateau += nb_gateau; |  | ||||||
|     Score_actualise(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| void Score_set_funny_action(){ |  | ||||||
|     Score_funny_action = 5; |  | ||||||
|     Score_actualise(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void Score_set_pieds_dans_plat(){ | void Score_set_pieds_dans_plat(){ | ||||||
|     Score_pieds_dans_plat = 15; |     Score_pieds_dans_plat = 10; | ||||||
|     Score_actualise(); |     Score_actualise(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Score_ajout_cerise(uint32_t nb_cerises){ | /// @brief Ajout 5 points au score par panneaux
 | ||||||
|     Score_nb_cerises += nb_cerises; | /// @param nb_panneau 
 | ||||||
|  | void Score_ajout_panneau(uint32_t nb_panneau){ | ||||||
|  |     Score_panneau += (nb_panneau*5); | ||||||
|     Score_actualise(); |     Score_actualise(); | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								Score.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Score.h
									
									
									
									
									
								
							| @ -1,6 +1,4 @@ | |||||||
| #include "pico/stdlib.h" | #include "pico/stdlib.h" | ||||||
| 
 | 
 | ||||||
| void Score_set_funny_action(); |  | ||||||
| void Score_set_pieds_dans_plat(); | void Score_set_pieds_dans_plat(); | ||||||
| void Score_ajout_cerise(uint32_t nb_cerises); | void Score_ajout_panneau(uint32_t nb_panneaux); | ||||||
| void Score_ajout_gateau(uint32_t nb_gateau); |  | ||||||
| @ -71,6 +71,8 @@ void Strategie_2024(enum couleur_t couleur, uint32_t step_ms, uint32_t temps_ms) | |||||||
|     static enum { |     static enum { | ||||||
|         TAP_CALAGE, |         TAP_CALAGE, | ||||||
|         TAP_POT, |         TAP_POT, | ||||||
|  |         TAP_PANNEAUX_SOLAIRES, | ||||||
|  |         TAP_ALLER_PLANTE, | ||||||
|         TAP_PLANTE_ORIENTATION, |         TAP_PLANTE_ORIENTATION, | ||||||
|         TAP_PLANTE_ATTRAPE_1, |         TAP_PLANTE_ATTRAPE_1, | ||||||
|         TAP_PLANTE_ATTRAPE_2, |         TAP_PLANTE_ATTRAPE_2, | ||||||
| @ -93,10 +95,21 @@ void Strategie_2024(enum couleur_t couleur, uint32_t step_ms, uint32_t temps_ms) | |||||||
|             break; |             break; | ||||||
|         case TAP_POT: |         case TAP_POT: | ||||||
|             if(Strat_2024_attrape_pot(get_groupe_pot(couleur), _step_ms) == ACTION_TERMINEE){ |             if(Strat_2024_attrape_pot(get_groupe_pot(couleur), _step_ms) == ACTION_TERMINEE){ | ||||||
|                 etat_test=TAP_PLANTE_ORIENTATION; |                 etat_test=TAP_PANNEAUX_SOLAIRES; | ||||||
|             } |             } | ||||||
|             break; |             break; | ||||||
| 
 | 
 | ||||||
|  |         case TAP_PANNEAUX_SOLAIRES: | ||||||
|  |             if(Strat_2024_tourner_panneaux(couleur, step_ms) == ACTION_TERMINEE){ | ||||||
|  |                 etat_test=TAP_ALLER_PLANTE; | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  | 
 | ||||||
|  |         case TAP_ALLER_PLANTE: | ||||||
|  |             if(Strategie_aller_a(940, 300, EVITEMENT_PAUSE_DEVANT_OBSTACLE, step_ms) == ACTION_TERMINEE){ | ||||||
|  |                 etat_test=TAP_PLANTE_ORIENTATION; | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|         case TAP_PLANTE_ORIENTATION: |         case TAP_PLANTE_ORIENTATION: | ||||||
|             if(Strat_2024_aller_zone_plante(get_zone_plante(couleur), _step_ms) == ACTION_TERMINEE){ |             if(Strat_2024_aller_zone_plante(get_zone_plante(couleur), _step_ms) == ACTION_TERMINEE){ | ||||||
|                 etat_test=TAP_PLANTE_ATTRAPE_1; |                 etat_test=TAP_PLANTE_ATTRAPE_1; | ||||||
|  | |||||||
| @ -4,6 +4,7 @@ | |||||||
| #include "Trajectoire.h" | #include "Trajectoire.h" | ||||||
| #include "Trajet.h" | #include "Trajet.h" | ||||||
| #include "Strategie.h" | #include "Strategie.h" | ||||||
|  | #include "Strategie_2024_panneaux.h" | ||||||
| #include "Strategie_2024_plante.h" | #include "Strategie_2024_plante.h" | ||||||
| #include "Strategie_2024_pots.h" | #include "Strategie_2024_pots.h" | ||||||
| #include "Commande_vitesse.h" | #include "Commande_vitesse.h" | ||||||
|  | |||||||
							
								
								
									
										93
									
								
								Strategie_2024_panneaux.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								Strategie_2024_panneaux.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,93 @@ | |||||||
|  | #include "math.h" | ||||||
|  | #include "Strategie.h" | ||||||
|  | #include "Geometrie_robot.h" | ||||||
|  | #include "Commande_vitesse.h" | ||||||
|  | #include "Strategie_2024_pots.h" | ||||||
|  | #include "i2c_annexe.h" | ||||||
|  | #include "Localisation.h" | ||||||
|  | #include "Score.h" | ||||||
|  | 
 | ||||||
|  | /// @brief Fonction demande au robot d'aller activer les panneaux solaires
 | ||||||
|  | enum etat_action_t Strat_2024_tourner_panneaux(enum couleur_t couleur, uint32_t step_ms){ | ||||||
|  |     enum etat_action_t etat_action; | ||||||
|  |     struct trajectoire_t trajectoire; | ||||||
|  |     static int tempo_ms; | ||||||
|  | 
 | ||||||
|  |     static enum { | ||||||
|  |         TP_APPROCHE_PANNEAU_1, // Position et orientation pour attaquer le panneau 1, bras 2 qui pousse
 | ||||||
|  |         TP_TOURNE_PANNEAU_1, | ||||||
|  |         TP_TOURNE_PANNEAU_2, | ||||||
|  |         TP_TOURNE_PANNEAU_3, | ||||||
|  |         TP_TOURNE_PANNEAU_4, | ||||||
|  |         TP_TOURNE_PANNEAU_5, | ||||||
|  |         TP_TOURNE_PANNEAU_6, | ||||||
|  |     } etat_tourne_panneaux = TP_APPROCHE_PANNEAU_1; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     switch (etat_tourne_panneaux) | ||||||
|  |     { | ||||||
|  |         case TP_APPROCHE_PANNEAU_1: | ||||||
|  |             Trajet_config(TRAJECT_CONFIG_AVANCE_ET_TOURNE); | ||||||
|  |             if(couleur == COULEUR_BLEU){ | ||||||
|  |                 etat_action = Strategie_tourner_et_aller_a( | ||||||
|  |                     323, 300, (150. *DEGRE_EN_RADIAN), | ||||||
|  |                     EVITEMENT_ARRET_DEVANT_OBSTACLE, step_ms); | ||||||
|  |             }else{ | ||||||
|  |                 etat_action = Strategie_tourner_et_aller_a( | ||||||
|  |                     323, 300, (150. *DEGRE_EN_RADIAN), | ||||||
|  |                     EVITEMENT_ARRET_DEVANT_OBSTACLE, step_ms); | ||||||
|  |             } | ||||||
|  |             if (etat_action == ACTION_TERMINEE){ | ||||||
|  |                 etat_tourne_panneaux = TP_TOURNE_PANNEAU_1; | ||||||
|  |             }else if(etat_action == ACTION_ECHEC){ | ||||||
|  |                 return ACTION_TERMINEE; | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  | 
 | ||||||
|  |         case TP_TOURNE_PANNEAU_1: | ||||||
|  |             if(couleur == COULEUR_BLEU){ | ||||||
|  |                 etat_action = Strategie_tourner_et_aller_a( | ||||||
|  |                     323, 200, (150. *DEGRE_EN_RADIAN), EVITEMENT_PAUSE_DEVANT_OBSTACLE, step_ms); | ||||||
|  |             }else{ | ||||||
|  |                 etat_action = Strategie_tourner_et_aller_a( | ||||||
|  |                     323, 300, (150. *DEGRE_EN_RADIAN), EVITEMENT_PAUSE_DEVANT_OBSTACLE, step_ms); | ||||||
|  |             } | ||||||
|  |             if (etat_action == ACTION_TERMINEE){ | ||||||
|  |                 Score_ajout_panneau(1); | ||||||
|  |                 etat_tourne_panneaux = TP_TOURNE_PANNEAU_2; | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  | 
 | ||||||
|  |         case TP_TOURNE_PANNEAU_2: | ||||||
|  |             if(couleur == COULEUR_BLEU){ | ||||||
|  |                 Trajectoire_bezier(&trajectoire, 323, 200, 405, 310, 548, 400, 548, 200, (150. *DEGRE_EN_RADIAN), (150. *DEGRE_EN_RADIAN)); | ||||||
|  |             }else{ | ||||||
|  |                 Trajectoire_bezier(&trajectoire, 3000-323, 200, 3000-405, 310, 3000-548, 400, 3000-548, 200, (150. *DEGRE_EN_RADIAN), (150. *DEGRE_EN_RADIAN)); | ||||||
|  |             } | ||||||
|  |             etat_action =Strategie_parcourir_trajet(trajectoire, step_ms, EVITEMENT_ARRET_DEVANT_OBSTACLE); | ||||||
|  |             if (etat_action == ACTION_TERMINEE){ | ||||||
|  |                 Score_ajout_panneau(1); | ||||||
|  |                 etat_tourne_panneaux = TP_TOURNE_PANNEAU_3; | ||||||
|  |             }else if(etat_action == ACTION_ECHEC){ | ||||||
|  |                 return ACTION_TERMINEE; | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  | 
 | ||||||
|  |         case TP_TOURNE_PANNEAU_3: | ||||||
|  |             if(couleur == COULEUR_BLEU){ | ||||||
|  |                 Trajectoire_bezier(&trajectoire, 548, 200, 630, 310, 773, 400, 773, 200, (150. *DEGRE_EN_RADIAN), (150. *DEGRE_EN_RADIAN)); | ||||||
|  |             }else{ | ||||||
|  |                 Trajectoire_bezier(&trajectoire, 3000-548, 200, 3000-630, 310, 3000-773, 400, 3000-773, 200, (150. *DEGRE_EN_RADIAN), (150. *DEGRE_EN_RADIAN)); | ||||||
|  |             } | ||||||
|  |             etat_action =Strategie_parcourir_trajet(trajectoire, step_ms, EVITEMENT_ARRET_DEVANT_OBSTACLE); | ||||||
|  |             if (etat_action == ACTION_TERMINEE){ | ||||||
|  |                 Score_ajout_panneau(1); | ||||||
|  |                 //etat_tourne_panneaux = TP_TOURNE_PANNEAU_3;
 | ||||||
|  |                 return ACTION_TERMINEE; | ||||||
|  |             }else if(etat_action == ACTION_ECHEC){ | ||||||
|  |                 return ACTION_TERMINEE; | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  |     } | ||||||
|  |     return ACTION_EN_COURS; | ||||||
|  | } | ||||||
							
								
								
									
										3
									
								
								Strategie_2024_panneaux.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Strategie_2024_panneaux.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | #include "Strategie.h" | ||||||
|  | 
 | ||||||
|  | enum etat_action_t Strat_2024_tourner_panneaux(enum couleur_t couleur, uint32_t step_ms); | ||||||
| @ -175,7 +175,7 @@ enum etat_action_t Strat_2024_plante_dans_pot(uint step_ms, uint bras_depose_pot | |||||||
|     enum validite_vl53l8_t validite; |     enum validite_vl53l8_t validite; | ||||||
|     enum etat_action_t etat_action; |     enum etat_action_t etat_action; | ||||||
|     float angle_rad, distance_mm; |     float angle_rad, distance_mm; | ||||||
|     static nb_essai_prise; |     static int nb_essai_prise; | ||||||
| 
 | 
 | ||||||
|     switch (etat_plante_dans_pot) |     switch (etat_plante_dans_pot) | ||||||
|     { |     { | ||||||
| @ -267,7 +267,7 @@ enum etat_action_t Strat_2024_plante_dans_pot(uint step_ms, uint bras_depose_pot | |||||||
|             position_initiale.angle_radian += ANGLE_PINCE; |             position_initiale.angle_radian += ANGLE_PINCE; | ||||||
|             position_recule = Geometrie_deplace(position_initiale, -100); |             position_recule = Geometrie_deplace(position_initiale, -100); | ||||||
|             Trajet_config(TRAJECT_CONFIG_AVANCE_DROIT); |             Trajet_config(TRAJECT_CONFIG_AVANCE_DROIT); | ||||||
|             if(Strategie_aller_a(position_recule.x_mm, position_recule.y_mm, step_ms) == ACTION_TERMINEE){ |             if(Strategie_aller_a(position_recule.x_mm, position_recule.y_mm, EVITEMENT_PAUSE_DEVANT_OBSTACLE, step_ms) == ACTION_TERMINEE){ | ||||||
|                 commande_vitesse_stop(); |                 commande_vitesse_stop(); | ||||||
|                 etat_plante_dans_pot=PDP_ALLER_PLANTE; |                 etat_plante_dans_pot=PDP_ALLER_PLANTE; | ||||||
|                 return ACTION_TERMINEE; |                 return ACTION_TERMINEE; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user