ajout module_mouvement
Dependencies: mbed xbee_lib ADXL345_I2C IMUfilter ITG3200 Motor RangeFinder Servo mbos PID
Fork of Labo_TRSE_Drone by
Revision 29:f8bda24002f6, committed 2013-04-17
- Comitter:
- arnaudsuire
- Date:
- Wed Apr 17 10:10:51 2013 +0000
- Parent:
- 28:8b5ccd2f837e
- Child:
- 30:8374d1017296
- Commit message:
- test motor
Changed in this revision
--- a/Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.cpp Wed Apr 03 13:48:30 2013 +0000 +++ b/Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.cpp Wed Apr 17 10:10:51 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 @@ -26,21 +26,159 @@ /* CONSRTRUCTEUR(S) */ ModuleMouvement::ModuleMouvement() { - + m_motor1 = new Motor(p21, p6, p5); + m_motor2 = new Motor(p22, p6, p5); + m_motor3 = new Motor(p23, p6, p5); + m_motor4 = new Motor(p24, p6, p5); } /* 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; } + + int ModuleMouvement::GetuiDistance() + { return m_uiDistance; } + + + /*Set*/ + void ModuleMouvement::SetpVitesseFonctionnement(int m) + { pVitesseFonctionnement = m ; } + + void ModuleMouvement::SetuiCommand(int n) + { m_uiCommand = n ; } + + void ModuleMouvement::SetuiDistance(int o) + { m_uiDistance = o ; } + + /* Point d'entrée de la tache Module Mouvement */ void ModuleMouvement::ModuleMouvement_Task(void) { 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.speed(0.2); // a def + m_motor2.speed(0.2); // a def + m_motor3.speed(0.2); // a def + m_motor4.speed(0.2); // a def + while ( /*pas de nouvelle commande*/ ) + { + wait(0.1); + } + m_motor1.stop(); + m_motor2.stop(); + m_motor3.stop(); + m_motor4.stop(); + wait(0.01); + return; + } + + void ModuleMouvement::GestionVitesseMotors(int m_uiCommand, int 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; + + CommandFin = true; + } + } + + void ModuleMouvement::GestionStabilisation(void) + { + + } + + void ModuleMouvement:TestMotor(void) + { + for (float s= -1.0; s < 1.0 ; s += 0.01) + { + m_motor1.speed(s); + wait(0.02); + } + m_motor1.stop(); + + + + for (float s= -1.0; s < 1.0 ; s += 0.01) + { + m_motor2.speed(s); + wait(0.02); + } + m_motor2.stop(); + + + for (float s= -1.0; s < 1.0 ; s += 0.01) + { + m_motor3.speed(s); + wait(0.02); + } + m_motor3.stop(); + + + for (float s= -1.0; s < 1.0 ; s += 0.01) + { + m_motor4.speed(s); + wait(0.02); + } + m_motor4.stop(); + } \ No newline at end of file
--- a/Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.h Wed Apr 03 13:48:30 2013 +0000 +++ b/Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.h Wed Apr 17 10:10:51 2013 +0000 @@ -21,15 +21,40 @@ #define MODULE_MOUVEMENT_H #include "mbos.h" + #include "Service.h" + #include "Motor.h" class ModuleMouvement { private : /* ATTRIBUTS */ + Motor * m_motor1; + Motor * m_motor2; + Motor * m_motor3; + Motor * m_motor4; + + /*Parametres*/ + int pVitesseFonctionnement; + /*commande*/ + int m_uiCommand; + int m_uiDistance; + public : + + /* Get param*/ + int GetpVitesseFonctionnement(); + int GetuiCommand(); + int GetuiDistance(); + + /*Set param*/ + void SetpVitesseFonctionnement(int); + void SetuiCommand(int); + void SetuiDistance(int); + /* CONSTRUCTEUR(S) */ ModuleMouvement(); + //faut-il un constructeur pour initialiser les moteur (vol stationnaire à l'allumage de 20cm)? /* DESTRUCTEUR */ ~ModuleMouvement(); @@ -37,6 +62,10 @@ /* METHODES */ /* Point d'entrée de la tache du Module Mouvement */ void ModuleMouvement_Task(void); + void GestionVitesseMotors(int m_uiCommand, int m_uiDistance); + void GestionStabilisation(void); + void VolStationnaire(void); + void TestMotor(void); /* FONCTIONS */