ajout module_mouvement
Dependencies: mbed xbee_lib ADXL345_I2C IMUfilter ITG3200 Motor RangeFinder Servo mbos PID
Fork of Labo_TRSE_Drone by
Revision 34:acc8ea8694b4, committed 2013-04-22
- Comitter:
- arnaudsuire
- Date:
- Mon Apr 22 19:13:35 2013 +0000
- Parent:
- 33:ec7d635636bf
- Child:
- 35:3c410cdc4792
- Commit message:
- ajout module_Mouvement (init, deconnexion)
Changed in this revision
--- a/Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.cpp Wed Apr 17 15:52:51 2013 +0000 +++ b/Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.cpp Mon Apr 22 19:13:35 2013 +0000 @@ -1,4 +1,4 @@ - /* Copyright (c) 2012 - 2013 AUTHEUR + /* Copyright (c) 2012 - 2013 AUTHEUR * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF @@ -22,25 +22,203 @@ // Pointeur sur la classe systeme d'exploitation instancié dans le main extern mbos *os; + //communication série USB + Serial pc1(USBTX,USBRX); + + + /* CONSRTRUCTEUR(S) */ ModuleMouvement::ModuleMouvement() { - + m_motor1 = new PwmOut (p21); + m_motor2 = new PwmOut (p22); + m_motor3 = new PwmOut (p23); + m_motor4 = new PwmOut (p24); } /* DESTRUCTEUR */ ModuleMouvement::~ModuleMouvement() { + delete m_motor1; + delete m_motor2; + delete m_motor3; + delete m_motor4; + } - } + + /*Get*/ + int ModuleMouvement::GetpVitesseFonctionnement() + { return pVitesseFonctionnement; } + + int ModuleMouvement::GetuiCommand() + { return m_uiCommand; } + + float ModuleMouvement::GetuiDistance() + { return m_uiDistance; } + + + /*Set*/ + void ModuleMouvement::SetpVitesseFonctionnement(int m) + { pVitesseFonctionnement = m ; } + + void ModuleMouvement::SetuiCommand(int n) + { m_uiCommand = n ; } + + void ModuleMouvement::SetuiDistance(float o) + { m_uiDistance = o ; } + + /* Point d'entrée de la tache Module Mouvement */ void ModuleMouvement::ModuleMouvement_Task(void) { + //init moteurs + InitMotor(); + + //décollage + m_uiCommand = 0; + m_uiDistance = 0.6; //60cm + GestionVitesseMotors(m_uiCommand, m_uiDistance); + + //vol stationnaire + VolStationnaire(); + + while(1){ - // Code + + // recuperation commande provenant de trajectoire, comment recup, quel format, quel taille? + // gestion motors + + // gestion stabilisation, get services? } } - \ No newline at end of file + void ModuleMouvement::VolStationnaire(void) + { + m_motor1->write(0.68); // a def + m_motor2->write(0.68); // a def + m_motor3->write(0.68); // a def + m_motor4->write(0.68); // a def + /*while ( pas de nouvelle commande ) + { + wait(0.1); + }*/ + + return; + } + + void ModuleMouvement::GestionVitesseMotors(int m_uiCommand, float m_uiDistance) + { + bool CommandFin = false; + + switch (m_uiCommand) + { + /*haut*/ + case 0 : + //Liste infos; + break; + + /*bas*/ + case 1 : + //liste infos; + break; + + /*rotation gauche*/ + case 2 : + //liste infos; + break; + + /*rotation droite*/ + case 3 : + //Liste infos; + break; + + /*gauche*/ + case 4 : + //Liste infos; + break; + + /*droite*/ + case 5 : + //liste infos; + break; + + /*avance*/ + case 6 : + //Liste infos; + break; + + /*recule*/ + case 7 : + //Liste infos + break; + + default : + /*erreur pas de commande*/ + + + } + CommandFin = true; + } + + void ModuleMouvement::GestionStabilisation(void) + { + + } + + void ModuleMouvement::TestMotor(void) + { + + //frequence à 500Hz (init à 0.40 PWMmax = 0.99) + m_motor1->period(0.002); + + //initialisation, attends du premier bip + for (float s= 0; s < 0.40; s += 0.01) + { + m_motor1->write(s); + wait(0.2); + pc1.printf("%f", s); + } + wait(2); + + m_motor1->write(0.96); + pc1.printf("test motor"); + + + } + + + void ModuleMouvement::InitMotor(void) + { + //frequence à 500Hz (init à 0.40 PWMmax = 0.99) + m_motor1->period(0.002); + m_motor2->period(0.002); + m_motor3->period(0.002); + m_motor4->period(0.002); + + //frequence à 400HZ (attention : init à 0.30 et PWMmax=0.85, trés rapide à l'acceleration ) + //m_motor1->period(0.0025); + + //initialisation, attends du premier bip + for (float s= 0; s < 0.40; s += 0.01) + { + m_motor1->write(s); + wait(0.2); + pc1.printf("%f", s); + } + wait(1); + } + + + void ModuleMouvement::DeconnexionMotor(void) + { + //deconnexion + for(float s= 0.40; s > 0; s-= 0.01) + { + m_motor1->write(s); + wait(0.01); + pc1.printf("%f", s); + } + wait(1); + } \ No newline at end of file
--- a/Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.h Wed Apr 17 15:52:51 2013 +0000 +++ b/Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.h Mon Apr 22 19:13:35 2013 +0000 @@ -21,15 +21,45 @@ #define MODULE_MOUVEMENT_H #include "mbos.h" + #include "Service.h" + #include "mbed.h" + + class ModuleMouvement { private : /* ATTRIBUTS */ + PwmOut * m_motor1; + PwmOut * m_motor2; + PwmOut * m_motor3; + PwmOut * m_motor4; + + + /*Parametres*/ + int pVitesseFonctionnement; + /*commande*/ + int m_uiCommand; + float m_uiDistance; + public : + + /* Get param*/ + int GetpVitesseFonctionnement(); + int GetuiCommand(); + float GetuiDistance(); + + + + /*Set param*/ + void SetpVitesseFonctionnement(int); + void SetuiCommand(int); + void SetuiDistance(float); + /* CONSTRUCTEUR(S) */ ModuleMouvement(); + //faut-il un constructeur pour initialiser les moteur (vol stationnaire à l'allumage de 20cm)? /* DESTRUCTEUR */ ~ModuleMouvement(); @@ -37,6 +67,12 @@ /* METHODES */ /* Point d'entrée de la tache du Module Mouvement */ void ModuleMouvement_Task(void); + void GestionVitesseMotors(int m_uiCommand, float m_uiDistance); + void GestionStabilisation(void); + void VolStationnaire(void); + void TestMotor(void); + void InitMotor(void); + void DeconnexionMotor(void); /* FONCTIONS */