Correction rotation + ajout fonction PWM dans AsserMoteur
This commit is contained in:
parent
d1f7efe398
commit
5b2edfcfd1
@ -1,5 +1,6 @@
|
||||
#include <stdint.h>
|
||||
#include "Asser_Moteurs.h"
|
||||
#include "Moteurs.h"
|
||||
#include "Plateforme.h"
|
||||
|
||||
#define NB_MOTEURS 2
|
||||
@ -18,6 +19,29 @@ void AsserMoteur_Init(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @brief Défini une commande PMW pour le moteur indiqué.
|
||||
/// @param moteur : Moteur à commande
|
||||
/// @param vitesse : Vitesse entre -32767 et 32767
|
||||
void AsserMoteur_commande_PWM(enum t_moteur moteur, int16_t commande_PWM){
|
||||
Moteur_SetVitesse(moteur, commande_PWM);
|
||||
asser_actif[moteur] = 0;
|
||||
}
|
||||
|
||||
void AsserMoteur_moteur_off(enum t_moteur moteur){
|
||||
Moteur_SetVitesse(moteur, 0);
|
||||
asser_actif[moteur] = 0;
|
||||
}
|
||||
|
||||
void AsserMoteur_moteurs_off(){
|
||||
for(enum t_moteur moteur=MOTEUR_A; moteur<NB_MOTEURS; moteur++ ){
|
||||
Moteur_SetVitesse(moteur, 0);
|
||||
asser_actif[moteur] = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @brief Défini une consigne de vitesse pour le moteur indiqué.
|
||||
/// @param moteur : Moteur à asservir
|
||||
/// @param _consigne_mm_s : consigne de vitesse en mm/s
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
#include "Moteurs.h"
|
||||
#include "QEI.h"
|
||||
#include "Moteurs.h"
|
||||
|
||||
uint32_t AsserMoteur_RobotImmobile(int step_ms);
|
||||
void AsserMoteur_setConsigne_mm_s(enum t_moteur moteur, float consigne_mm_s);
|
||||
float AsserMoteur_getConsigne_mm_s(enum t_moteur moteur);
|
||||
float AsserMoteur_getVitesse_mm_s(enum t_moteur moteur, int step_ms);
|
||||
void AsserMoteur_commande_PWM(enum t_moteur moteur, int16_t commande_PWM);
|
||||
void AsserMoteur_moteur_off(enum t_moteur moteur);
|
||||
void AsserMoteur_moteurs_off();
|
||||
void AsserMoteur_Gestion(int step_ms);
|
||||
void AsserMoteur_Init(void);
|
||||
void AsserMoteurs_stop(void);
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include "Asser_Moteurs.h"
|
||||
#include "Rotation.h"
|
||||
#include "Trajet.h"
|
||||
|
||||
enum evitement_t{
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
// Codeurs
|
||||
#define PIN_QEI_CODEUR_A 11
|
||||
#define PIN_QEI_CODEUR_B 2
|
||||
#define IMPULSION_PAR_MM_50_1 (12.45f)
|
||||
#define IMPULSION_PAR_MM_50_1 (14.15f)
|
||||
#define IMPULSION_PAR_MM_30_1 (7.47f)
|
||||
#define IMPULSION_PAR_MM IMPULSION_PAR_MM_50_1
|
||||
// Asservissement en position
|
||||
|
||||
@ -41,7 +41,7 @@ Dans le fichier CMakeLists.txt, ajouter le dossier du sub module:
|
||||
|
||||
add_subdirectory(Module_deplacement_robot_differentiel)
|
||||
|
||||
Dans le fichier CMakeLists.txt, ajouter la bibliothèque RP2040_Servomoteur :
|
||||
Dans le fichier CMakeLists.txt, ajouter la bibliothèque Deplacement_Robot_differentiel :
|
||||
|
||||
target_link_libraries(Modele_RPiPico
|
||||
...
|
||||
|
||||
@ -17,8 +17,8 @@ void rotation_init(float angle_cible){
|
||||
struct position_t position = Localisation_get();
|
||||
rotation_angle_cible = Geometrie_get_angle_optimal(position.angle_radian, angle_cible);
|
||||
rotation_vitesse_rad_s = 0;
|
||||
rotation_vitesse_max_rad_s = 5;
|
||||
rotation_acceleration_rad_ss = 25;
|
||||
rotation_vitesse_max_rad_s = 2;
|
||||
rotation_acceleration_rad_ss = 4;
|
||||
|
||||
if(rotation_angle_cible - position.angle_radian > 0){
|
||||
rotation_angle_sens = 1;
|
||||
@ -41,13 +41,12 @@ void rotation_set_vitesse(float vitesse_rad_s){
|
||||
enum etat_trajet_t rotation_gestion(float pas_de_temps_s){
|
||||
struct position_t position = Localisation_get();
|
||||
rotation_vitesse_rad_s = Rotation_calcul_vitesse(position.angle_radian, pas_de_temps_s);
|
||||
rotation_set_vitesse(rotation_vitesse_rad_s);
|
||||
|
||||
if (rotation_angle_sens == 1 ){
|
||||
rotation_set_vitesse(rotation_vitesse_rad_s);
|
||||
if (position.angle_radian > rotation_angle_cible){
|
||||
return TRAJET_TERMINE;
|
||||
}
|
||||
|
||||
}else{
|
||||
if (position.angle_radian < rotation_angle_cible){
|
||||
return TRAJET_TERMINE;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user