diff --git a/.vscode/settings.json b/.vscode/settings.json index 4217d5b..742253c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "files.associations": { - "string.h": "c" + "string.h": "c", + "messagerie_applicative.h": "c" } } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index dd71dda..1a86444 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ add_executable(Modele_RPiPico communication.c main.c messagerie.c + messagerie_applicative.c ) target_link_libraries(Modele_RPiPico diff --git a/Readme.md b/Readme.md index 771dfe2..08627a5 100644 --- a/Readme.md +++ b/Readme.md @@ -27,4 +27,101 @@ Méthode de test Difficultés rencontrées ----------------------- -En testant avec Linux, le terminal peut manger certains caractères lorsqu'il les reçoit (0x11, 0x12 et 0x13). \ No newline at end of file +En testant avec Linux, le terminal peut manger certains caractères lorsqu'il les reçoit (0x11, 0x12 et 0x13). + + +Annexe +====== + +Table des registres : +--------------------- + +| Adresse | R/W | Type | Donnée | +| ------- | --- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 0x00 | RW | flottant 32 bits | Position X en mm | +| 0x01 | RW | flottant 32 bits | Position X en mm | +| 0x02 | RW | flottant 32 bits | Position X en mm | +| 0x03 | RW | flottant 32 bits | Position X en mm | +| 0x04 | RW | flottant 32 bits | Position Y en mm | +| 0x05 | RW | flottant 32 bits | Position Y en mm | +| 0x06 | RW | flottant 32 bits | Position Y en mm | +| 0x07 | RW | flottant 32 bits | Position Y en mm | +| 0x08 | RW | flottant 32 bits | Orientation en radian | +| 0x09 | RW | flottant 32 bits | Orientation en radian | +| 0x0A | RW | flottant 32 bits | Orientation en radian | +| 0x0B | RW | flottant 32 bits | Orientation en radian | +| 0x0C | R | Boolean | Mouvement en cours : 1
Mouvement terminé : 0 | +| 0x0D | RW | uint8_t | Mode
0 : arrêt des moteurs
1 : pilotage des moteurs PWM
2 : pilotage en vitesse des roues
3 : pilotage avec la loi de commande
4 : Trajectoire | +| 0x0E | RW | int_16 | Commande PWM moteur gauche | +| 0x0F | RW | int_16 | Commande PWM moteur gauche | +| 0x10 | RW | int_16 | Commande PWM moteur droit | +| 0x11 | RW | int_16 | Commande PWM moteur droit | +| 0x12 | RW | Flottant 32 bits | Consigne vitesse gauche en mm/s | +| 0x13 | RW | Flottant 32 bits | Consigne vitesse gauche en mm/s | +| 0x14 | RW | Flottant 32 bits | Consigne vitesse gauche en mm/s | +| 0x15 | RW | Flottant 32 bits | Consigne vitesse gauche en mm/s | +| 0x16 | RW | Flottant 32 bits | Consigne vitesse gauche en mm/s | +| 0x17 | RW | Flottant 32 bits | Consigne vitesse gauche en mm/s | +| 0x18 | RW | Flottant 32 bits | Consigne vitesse gauche en mm/s | +| 0x19 | RW | Flottant 32 bits | Consigne vitesse gauche en mm/s | +| 0x1A | RW | Flottant 32 bits | Consigne d’avance du robot | +| 0x1B | RW | Flottant 32 bits | Consigne d’avance du robot | +| 0x1C | RW | Flottant 32 bits | Consigne d’avance du robot | +| 0x1D | RW | Flottant 32 bits | Consigne d’avance du robot | +| 0x1E | RW | Flottant 32 bits | Consigne de rotation du robot | +| 0x1F | RW | Flottant 32 bits | Consigne de rotation du robot | +| 0x20 | RW | Flottant 32 bits | Consigne de rotation du robot | +| 0x21 | RW | Flottant 32 bits | Consigne de rotation du robot | +| 0x22 | RW | Enum 8 bits | Trajectoire, type :
0 : Droite
1 : Circulaire
2 : Bézier
3 : Composée
4 : Rotation | +| 0x23 | RW | Flottant 32 bits | Point 1, X | +| 0x24 | RW | Flottant 32 bits | Point 1, X | +| 0x25 | RW | Flottant 32 bits | Point 1, X | +| 0x26 | RW | Flottant 32 bits | Point 1, X | +| 0x27 | RW | Flottant 32 bits | Point 1, Y | +| 0x28 | RW | Flottant 32 bits | Point 1, Y | +| 0x29 | RW | Flottant 32 bits | Point 1, Y | +| 0x2A | RW | Flottant 32 bits | Point 1, Y | +| 0x2B | RW | Flottant 32 bits | Point 2, X | +| 0x2C | RW | Flottant 32 bits | Point 2, X | +| 0x2D | RW | Flottant 32 bits | Point 2, X | +| 0x2E | RW | Flottant 32 bits | Point 2, X | +| 0x2F | RW | Flottant 32 bits | Point 2, Y | +| 0x30 | RW | Flottant 32 bits | Point 2, Y | +| 0x31 | RW | Flottant 32 bits | Point 2, Y | +| 0x32 | RW | Flottant 32 bits | Point 2, Y | +| 0x33 | RW | Flottant 32 bits | Point 3, X | +| 0x34 | RW | Flottant 32 bits | Point 3, X | +| 0x35 | RW | Flottant 32 bits | Point 3, X | +| 0x36 | RW | Flottant 32 bits | Point 3, X | +| 0x37 | RW | Flottant 32 bits | Point 3, Y | +| 0x38 | RW | Flottant 32 bits | Point 3, Y | +| 0x39 | RW | Flottant 32 bits | Point 3, Y | +| 0x3A | RW | Flottant 32 bits | Point 3, Y | +| 0x3B | RW | Flottant 32 bits | Point 4, X | +| 0x3C | RW | Flottant 32 bits | Point 4, X | +| 0x3D | RW | Flottant 32 bits | Point 4, X | +| 0x3E | RW | Flottant 32 bits | Point 4, X | +| 0x3F | RW | Flottant 32 bits | Point 4, Y | +| 0x40 | RW | Flottant 32 bits | Point 4, Y | +| 0x41 | RW | Flottant 32 bits | Point 4, Y | +| 0x42 | RW | Flottant 32 bits | Point 4, Y | +| 0x43 | RW | Flottant 32 bits | orientation_debut_rad | +| 0x44 | RW | Flottant 32 bits | orientation_debut_rad | +| 0x45 | RW | Flottant 32 bits | orientation_debut_rad | +| 0x46 | RW | Flottant 32 bits | orientation_debut_rad | +| 0x47 | RW | Flottant 32 bits | orientation_fin_rad | +| 0x48 | RW | Flottant 32 bits | orientation_fin_rad | +| 0x49 | RW | Flottant 32 bits | orientation_fin_rad | +| 0x4A | RW | Flottant 32 bits | orientation_fin_rad | +| 0x4B | RW | Flottant 32 bits | rayon mm | +| 0x4C | RW | Flottant 32 bits | rayon mm | +| 0x4D | RW | Flottant 32 bits | rayon mm | +| 0x4E | RW | Flottant 32 bits | rayon mm | +| 0x4F | RW | Flottant 32 bits | Angle début rad | +| 0x50 | RW | Flottant 32 bits | Angle début rad | +| 0x51 | RW | Flottant 32 bits | Angle début rad | +| 0x52 | RW | Flottant 32 bits | Angle début rad | +| 0x53 | RW | Flottant 32 bits | Angle fin rad | +| 0x54 | RW | Flottant 32 bits | Angle fin rad | +| 0x55 | RW | Flottant 32 bits | Angle fin rad | +| 0x56 | RW | Flottant 32 bits | Angle fin rad | \ No newline at end of file diff --git a/main.c b/main.c index d3597d0..f8ca059 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,7 @@ #include "communication.h" #include "messagerie.h" +#include "messagerie_applicative.h" void stdio_usb_out_chars(const char *buf, int length); @@ -17,50 +18,8 @@ void stdio_usb_out_chars(const char *buf, int length); #define NB_MORCEAUX 100 absolute_time_t envoie_nb_char(int nb_char); -uint8_t memoire_echange[200]; char chaine_envoie[10000]; -bool mise_a_jour_position = false; -bool mise_a_jour_mode = false; -bool mise_a_jour_pwm = false; -bool mise_a_jour_vitesse_roues = false; -bool mise_a_jour_vitesse_robot = false; -bool mise_a_jour_trajectoire = false; - - -void écriture_données(unsigned int adresse, uint8_t donnée){ - if( adresse <= 11){ - // Position du robot - mise_a_jour_position = true; - }else if(adresse <= 12){ - // Read only - - }else if(adresse <= 13){ - // Mode - mise_a_jour_mode = true; - }else if(adresse <= 17){ - // PWM moteur - mise_a_jour_pwm = true; - }else if(adresse <= 25){ - // Vitesse roues - mise_a_jour_vitesse_roues = true; - }else if(adresse <= 33){ - // Vitesse robot - mise_a_jour_vitesse_robot = true; - }else if(adresse <= 86){ - // Trajectoire - mise_a_jour_trajectoire = true; - }else if(adresse >86){ - // Hors mémoire - printf("adresse = %d\n", adresse); - return; - } - - memoire_echange[adresse] = donnée; - - -} - @@ -190,18 +149,45 @@ void main(void) mise_a_jour_vitesse_roues = false; mise_a_jour_vitesse_robot = false; mise_a_jour_trajectoire = false; + // Copie des données dans la mémoire d'échange - + // Et actualisation des variables "mise_a_jour_..." for (int num_octet=0; num_octet +#include "messagerie_applicative.h" + +uint8_t memoire_echange[200]; + + + +bool mise_a_jour_position = false; +bool mise_a_jour_mode = false; +bool mise_a_jour_pwm = false; +bool mise_a_jour_vitesse_roues = false; +bool mise_a_jour_vitesse_robot = false; +bool mise_a_jour_trajectoire = false; + +void get_données_reçues(uint8_t * dst, unsigned int taille, unsigned int registre){ + memcpy(dst, &(memoire_echange[registre]), taille); +} + + +void écriture_données(unsigned int adresse, uint8_t donnée){ + if( adresse <= 11){ + // Position du robot + mise_a_jour_position = true; + }else if(adresse <= 12){ + // Read only + + }else if(adresse <= 13){ + // Mode + mise_a_jour_mode = true; + }else if(adresse <= 17){ + // PWM moteur + mise_a_jour_pwm = true; + }else if(adresse <= 25){ + // Vitesse roues + mise_a_jour_vitesse_roues = true; + }else if(adresse <= 33){ + // Vitesse robot + mise_a_jour_vitesse_robot = true; + }else if(adresse <= 86){ + // Trajectoire + mise_a_jour_trajectoire = true; + }else if(adresse >86){ + // Hors mémoire + return; + } + + memoire_echange[adresse] = donnée; + + +} diff --git a/messagerie_applicative.h b/messagerie_applicative.h new file mode 100644 index 0000000..cf05b5f --- /dev/null +++ b/messagerie_applicative.h @@ -0,0 +1,12 @@ +#include +#include + +void écriture_données(unsigned int adresse, uint8_t donnée); +void get_données_reçues(uint8_t * dst, unsigned int taille, unsigned int registre); + +extern bool mise_a_jour_position; +extern bool mise_a_jour_mode; +extern bool mise_a_jour_pwm; +extern bool mise_a_jour_vitesse_roues; +extern bool mise_a_jour_vitesse_robot; +extern bool mise_a_jour_trajectoire; \ No newline at end of file diff --git a/messages_propulsion.h b/messages_propulsion.h index 9e6b983..8317e15 100644 --- a/messages_propulsion.h +++ b/messages_propulsion.h @@ -3,10 +3,25 @@ #define USB_ID_PROPULSION 'P' #define REG_PROPULSION_POSITION 0x00 +#define REG_PROPULSION_MODE 0x0D +#define REG_PROPULSION_PWM 0x0E +#define REG_PROPULSION_VITESSE_ROUES 0x12 +#define REG_PROPULSION_VITESSE_ROBOT 0x1A struct msg_propulsion_position_t{ float position_x_mm, position_y_mm, orientation_rad; }; +struct msg_propulsion_pwm_t{ + uint16_t pwm_gauche, pwm_droit; +}; + +struct msg_propulsion_vitesse_roues_t{ + float vitesse_gauche_mm_s, vitesse_droite_mm_s; +}; + +struct msg_propulsion_vitesse_robot_t { + float avance_mm_s, rotation_rad_s; +}; #endif \ No newline at end of file