diff --git a/Localisation.c b/Localisation.c index 446fe1c..a1bddbc 100644 --- a/Localisation.c +++ b/Localisation.c @@ -17,6 +17,7 @@ void Localisation_set(double x_mm, double y_mm, double angle_radian){ position.x_mm = x_mm; position.y_mm = y_mm; position.angle_radian = angle_radian; + gyro_set_angle_radian(angle_radian); } void Localisation_set_x(double x_mm){ diff --git a/gyro.c b/gyro.c index f5bad2d..78c6b75 100644 --- a/gyro.c +++ b/gyro.c @@ -6,7 +6,9 @@ #include "spi_nb.h" #include "Temps.h" #include "gyro.h" +#include "math.h" +#define RADIAN_VERS_DEGRES (180. / M_PI) #ifdef GYRO_L3GD20H @@ -35,6 +37,9 @@ uint32_t rot_x_zero, rot_y_zero, rot_z_zero; struct t_angle_gyro_double angle_gyro, vitesse_gyro; +void gyro_set_angle_radian(double angle_radian){ + angle_gyro.rot_z = angle_radian * RADIAN_VERS_DEGRES; +} struct t_angle_gyro_double gyro_get_angle_degres(void){ return angle_gyro; diff --git a/gyro.h b/gyro.h index cad0519..34fa7ff 100644 --- a/gyro.h +++ b/gyro.h @@ -3,6 +3,7 @@ void Gyro_Init(void); void Gyro_Read(uint16_t); void gyro_affiche(struct t_angle_gyro_double angle_gyro, char * titre); +void gyro_set_angle_radian(double angle_radian); struct t_angle_gyro_double gyro_get_angle_degres(void); struct t_angle_gyro_double gyro_get_vitesse(void); int16_t gyro_get_temp(void); \ No newline at end of file