Hlimi Omar
/
biniou
TRR2018 omar
Fork of biniou by
stateMachines.h@12:51b1b40cc017, 2018-09-10 (annotated)
- Committer:
- GaspardD
- Date:
- Mon Sep 10 20:23:03 2018 +0000
- Revision:
- 12:51b1b40cc017
- Parent:
- 11:bc24b3ba51a9
- Child:
- 13:af9a59ccf60b
complile propre
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GaspardD | 12:51b1b40cc017 | 1 | #include "mbed.h" |
GaspardD | 8:1d8c3ca5e508 | 2 | #include <stdint.h> |
GaspardD | 8:1d8c3ca5e508 | 3 | |
GaspardD | 11:bc24b3ba51a9 | 4 | #define NB_ECHANTILLONS_IR 4 |
GaspardD | 11:bc24b3ba51a9 | 5 | #define NB_ECHANTILLONS_LIDAR 4 |
GaspardD | 11:bc24b3ba51a9 | 6 | |
GaspardD | 11:bc24b3ba51a9 | 7 | #define LIDAR_STRENGTH_THRESOLD 200 //pour la gestion de la vitesse MAX (MAXSpeed_ST) |
GaspardD | 11:bc24b3ba51a9 | 8 | #define LIDAR_STRENGH_DELTA 50 |
GaspardD | 11:bc24b3ba51a9 | 9 | |
GaspardD | 11:bc24b3ba51a9 | 10 | #define IR_DEADZONE_U16_22cm 49677 |
GaspardD | 11:bc24b3ba51a9 | 11 | #define IR_FAR_U16_105cm 11915 |
GaspardD | 11:bc24b3ba51a9 | 12 | |
GaspardD | 11:bc24b3ba51a9 | 13 | #define SPEED_DELTA_CMPS 2 |
GaspardD | 11:bc24b3ba51a9 | 14 | |
GaspardD | 11:bc24b3ba51a9 | 15 | //#define DLVV |
GaspardD | 11:bc24b3ba51a9 | 16 | |
GaspardD | 11:bc24b3ba51a9 | 17 | |
GaspardD | 8:1d8c3ca5e508 | 18 | typedef enum{ |
GaspardD | 8:1d8c3ca5e508 | 19 | ARRET, |
GaspardD | 8:1d8c3ca5e508 | 20 | LOADING_SECTION, |
GaspardD | 8:1d8c3ca5e508 | 21 | RUNNING_SECTION |
GaspardD | 8:1d8c3ca5e508 | 22 | }SECTION_ST; |
GaspardD | 8:1d8c3ca5e508 | 23 | |
GaspardD | 8:1d8c3ca5e508 | 24 | typedef enum{ |
GaspardD | 8:1d8c3ca5e508 | 25 | UNDER_SPEED, |
GaspardD | 8:1d8c3ca5e508 | 26 | OVER_SPEED, |
GaspardD | 8:1d8c3ca5e508 | 27 | AT_SPEED |
GaspardD | 8:1d8c3ca5e508 | 28 | }THROTTLE_ST; |
GaspardD | 8:1d8c3ca5e508 | 29 | |
GaspardD | 8:1d8c3ca5e508 | 30 | typedef enum{ |
GaspardD | 11:bc24b3ba51a9 | 31 | ATTRACTIF_G, |
GaspardD | 11:bc24b3ba51a9 | 32 | ATTRACTIF_D, |
GaspardD | 11:bc24b3ba51a9 | 33 | EQUILIBRAGE_REPULSIF |
GaspardD | 8:1d8c3ca5e508 | 34 | }MUR_ST; |
GaspardD | 8:1d8c3ca5e508 | 35 | |
GaspardD | 8:1d8c3ca5e508 | 36 | typedef enum{ |
GaspardD | 11:bc24b3ba51a9 | 37 | SPEED_MAX,//pas de mur, on va a fond |
GaspardD | 11:bc24b3ba51a9 | 38 | SPEED_VARIABLE,//signal suffisement fort pour gérer la vitesse |
GaspardD | 11:bc24b3ba51a9 | 39 | SPEED_LIMITED//nous somme dans la plage de distance ou la vitesse doit être limitée |
GaspardD | 11:bc24b3ba51a9 | 40 | }MAX_SPEED_ST; |
GaspardD | 11:bc24b3ba51a9 | 41 | |
GaspardD | 11:bc24b3ba51a9 | 42 | #ifdef DLVV |
GaspardD | 11:bc24b3ba51a9 | 43 | typedef enum{//uniquement activé pour dlvv, se rajoute au PID de murOutput |
GaspardD | 11:bc24b3ba51a9 | 44 | FRONT_CLEAR,//pas d'obstacle droit devant |
GaspardD | 11:bc24b3ba51a9 | 45 | FRONT_OBSTRUCTED//un obstacle à été detecté à moins de 20/30 cm tbd |
GaspardD | 8:1d8c3ca5e508 | 46 | }OBSTACLE_ST; |
GaspardD | 11:bc24b3ba51a9 | 47 | #endif |
GaspardD | 8:1d8c3ca5e508 | 48 | |
GaspardD | 8:1d8c3ca5e508 | 49 | typedef struct s_section { |
GaspardD | 11:bc24b3ba51a9 | 50 | int targetSpeed_cmps; |
GaspardD | 11:bc24b3ba51a9 | 51 | int slowSpeed_cmps;//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) |
GaspardD | 11:bc24b3ba51a9 | 52 | int brakingCoefficient; |
GaspardD | 11:bc24b3ba51a9 | 53 | float ms_accel; |
GaspardD | 11:bc24b3ba51a9 | 54 | float ms_decel; |
GaspardD | 11:bc24b3ba51a9 | 55 | int lidarWarningDist_cm; |
GaspardD | 8:1d8c3ca5e508 | 56 | int lng_section_cm; |
GaspardD | 12:51b1b40cc017 | 57 | double coef_p; |
GaspardD | 12:51b1b40cc017 | 58 | double coef_i; |
GaspardD | 12:51b1b40cc017 | 59 | double coef_d; |
GaspardD | 8:1d8c3ca5e508 | 60 | s_section* nextSection; |
GaspardD | 8:1d8c3ca5e508 | 61 | }s_Section; |
GaspardD | 8:1d8c3ca5e508 | 62 | |
GaspardD | 11:bc24b3ba51a9 | 63 | //*************** fonctions utilitaires *************** |
GaspardD | 8:1d8c3ca5e508 | 64 | |
GaspardD | 11:bc24b3ba51a9 | 65 | void getTachySpeed(); |
GaspardD | 12:51b1b40cc017 | 66 | uint16_t getDistMoy(uint16_t* tab, int size); |
GaspardD | 12:51b1b40cc017 | 67 | void it4cm(); |
GaspardD | 12:51b1b40cc017 | 68 | void it_serial(); |
GaspardD | 11:bc24b3ba51a9 | 69 | |
GaspardD | 11:bc24b3ba51a9 | 70 | //*************** fonctions states machines *************** |
GaspardD | 8:1d8c3ca5e508 | 71 | //gestion de la direction quand la vue est dégagée |
GaspardD | 11:bc24b3ba51a9 | 72 | void mursInit(void); |
GaspardD | 11:bc24b3ba51a9 | 73 | void mursUpdate(void); |
GaspardD | 11:bc24b3ba51a9 | 74 | void mursOutput(void); |
GaspardD | 8:1d8c3ca5e508 | 75 | |
GaspardD | 11:bc24b3ba51a9 | 76 | #ifdef DLVV |
GaspardD | 8:1d8c3ca5e508 | 77 | //gestion de la direction en mode course et de l'évitement en mode DLVV |
GaspardD | 11:bc24b3ba51a9 | 78 | void obstacleInit(void); |
GaspardD | 11:bc24b3ba51a9 | 79 | void obstacleUpdate(void); |
GaspardD | 11:bc24b3ba51a9 | 80 | void obstacleOutput(void); |
GaspardD | 11:bc24b3ba51a9 | 81 | #endif |
GaspardD | 8:1d8c3ca5e508 | 82 | |
GaspardD | 11:bc24b3ba51a9 | 83 | //gestion du comportement en fn de l'avancement sur le parcours |
GaspardD | 11:bc24b3ba51a9 | 84 | void sectionInit(void); |
GaspardD | 11:bc24b3ba51a9 | 85 | void sectionUpdate(void); |
GaspardD | 11:bc24b3ba51a9 | 86 | void sectionOutput(void); |
GaspardD | 11:bc24b3ba51a9 | 87 | |
GaspardD | 11:bc24b3ba51a9 | 88 | //gestion de la gesion de la vitesse max/rotation max des roues la rotation est plus importante que la vitesse :) |
GaspardD | 11:bc24b3ba51a9 | 89 | void maxSpeedInit(void); |
GaspardD | 11:bc24b3ba51a9 | 90 | void maxSpeedUpdate(void); |
GaspardD | 11:bc24b3ba51a9 | 91 | void maxSpeedOutput(void); |
GaspardD | 8:1d8c3ca5e508 | 92 | |
GaspardD | 8:1d8c3ca5e508 | 93 | //gestion de l'allure en fonction des paramètres de la section |
GaspardD | 11:bc24b3ba51a9 | 94 | void throttleInit(void); |
GaspardD | 11:bc24b3ba51a9 | 95 | void throttleUpdate(void); |
GaspardD | 11:bc24b3ba51a9 | 96 | void throttleOutput(void); |