TRR2018 omar

Dependencies:   mbed

Fork of biniou by TRR 2018

Revision:
29:fc984fe08ca7
Parent:
28:af53caf04446
Child:
30:21642fb8297a
--- a/stateMachines.h	Mon Sep 17 11:08:02 2018 +0000
+++ b/stateMachines.h	Tue Sep 18 18:28:19 2018 +0000
@@ -1,3 +1,6 @@
+#ifndef STATE_MACHINES_H 
+#define STATE_MACHINES_H
+
 #include "mbed.h"
 #include <stdint.h>
 
@@ -8,37 +11,39 @@
 
 #define NB_INTEGRAL_SAMPLES 5
 
-#define TACHY_CM 8
+#define TACHY_CM 8.0
+#define COEF_RAYON_BR_S_DIST 1
 //#define FREINAGE_ADAPTATIF
 #define PUISSANCE_FREINAGE_W 1000 //en W
 #define MASSE_BINIOU_KG 1.8
+#define DEMI_LARGEUR_BINIOU_CM 10.0
 
 #define DIERCTION_PERIOD_MS 10000
 #define DIRECTION_PULSE_MAX 2100
 #define DIRECTION_PULSE_MIN 800
 #define DIRECTION_PULSE_MIDDLE 1530
 
+#define DIST_MIN_LONG_CM 30
+
 #define SPEED_PERIOD_US 20000
 #define BRAKING_PULSE_US 1350
 #define MAX_PULSE_WIDTH_FOR_TACHY_US 1850
 #define INITAL_PULSE_SPEED_US 1590
 #define ZERO_PULSE_SPEED_US 1500
-#define COEF_CMPS_TO_PULSE 25
 
 #define NB_ECHANTILLONS_IR 8
 
 #define LIDAR_STRENGTH_THRESOLD 25 //pour la gestion de la vitesse MAX (MAXSpeed_ST)
 #define LIDAR_ERR 65535
 
-#define IR_DEADZONE_U16_22cm 48000
-#define IR_FAR_U16_105cm 12000
-
 #define SPEED_DELTA_CMPS 30
 
 #define CAPT_45_DROITE PC_2
 #define CAPT_45_GAUCHE PC_0
 #define CAPT_90_DROITE PA_1
 #define CAPT_90_GAUCHE PC_1
+#define CAPT_90_GAUCHE_SHORT PA_0
+#define CAPT_90_DROITE_SHORT PA_2
 #define CAPT_10_GAUCHE PB_0
 #define CAPT_10_DROITE PC_3
 #define CAPT_DEVANT    PA_4
@@ -46,7 +51,7 @@
 
 
 #ifdef SAMPLING
-#define TAILLE_SAMPLES 4000
+#define TAILLE_SAMPLES 1500
 typedef struct states
 {
     char murs_dlvv;
@@ -55,15 +60,16 @@
     char throttle;
     }s_States;
 
-typedef struct sample 
+typedef struct sample
 {
     s_States states;
     int time;
-    int16_t diffgd45;
-    int16_t diffgd90;
     int16_t pwm_thro_us;
     int16_t pwm_dir_us;
-    int16_t dist;
+    double largeurPiste;
+    double position45;
+    double position90;
+    double dist;
     int16_t distLidar;
     int16_t strLidar;
 } s_Sample;
@@ -71,16 +77,17 @@
 #endif
 
 typedef enum{
-    ATTRACTIF_G,
-    ATTRACTIF_D,
-    EQUILIBRAGE_REPULSIF
+    REF_BIDIR,
+    REF_A_DROITE,
+    REF_A_GAUCHE
 }MUR_ST;
 
 #ifdef DLVV
 typedef enum{//uniquement activé pour dlvv, se rajoute au PID de murOutput
-    FRONT_CLEAR,//pas d'obstacle droit devant
-    RIGHT_LANE,//un obstacle à été detecté à gauche
-    LEFT_LANE,//un obstacle à été detecté à droite
+    ALL_CLEAR,
+    FRONT_OBSTRUCTED,//pas d'obstacle droit devant
+    RIGHT_OBSTRUCTED,//un obstacle à été detecté à gauche
+    LEFT_OBSTRUCTED//un obstacle à été detecté à droite
 }OBSTACLE_ST;
 #endif
 
@@ -105,25 +112,28 @@
 
 
 typedef struct s_section {
-   int targetSpeed_cmps;//supérieure a 328
-   int slowSpeed_cmps;//supérieure a 328; pour effectuer les virages: pour ne pas avoir d'a coups entre la vitesse variable et la vitesse limitée: brakingCoefficient = 30*((targetSpeed_cmps/slowSpeed_cmps)-1)
-   int brakingCoefficient;
-   int coef_p_speed;
-   int lidarWarningDist_cm;
-   int lng_section_cm;
-   int coef_p;
-   int coef_i;
-   int coef_d;
+   double targetSpeed_cmps;//supérieure a 328
+   double slowSpeed_cmps;//supérieure a 328; pour effectuer les virages: pour ne pas avoir d'a coups entre la vitesse variable et la vitesse limitée
+   double coef_p_speed;
+   double consigne_position;
+   double lidarWarningDist_cm;
+   double lng_section_cm;
+   double coef_p;
+   double coef_i;
+   double coef_d;
    s_section* nextSection;
 }s_Section;
 
 //*************** fonctions utilitaires ***************
 
 void getTachySpeed();
-uint16_t getDistMoy(uint16_t* tab, int size);
+double getDistMoy(AnalogIn* p, double *tab, int size);
 void it4cm();
 void it_serial();
 void sampleLog();
+void initSamples();
+void initIntegrationTable();
+void pressed();
 
 //*************** fonctions states machines ***************
 //gestion de la direction quand la vue est dégagée
@@ -152,3 +162,5 @@
 void throttleInit(void);
 void throttleUpdate(void);
 void throttleOutput(void);
+
+#endif