ajout module_mouvement
Dependencies: mbed xbee_lib ADXL345_I2C IMUfilter ITG3200 Motor RangeFinder Servo mbos PID
Fork of Labo_TRSE_Drone by
Module_Asservissement/Sous_Module_Mouvement/Module_Mouvement.cpp
- Committer:
- arnaudsuire
- Date:
- 2013-04-17
- Revision:
- 29:f8bda24002f6
- Parent:
- 15:793cf784dc7a
- Child:
- 30:8374d1017296
File content as of revision 29:f8bda24002f6:
/* 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 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Description * Input * Output */ #include "Module_Mouvement.h" // Pointeur sur la classe systeme d'exploitation instancié dans le main extern mbos *os; /* 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){ // recuperation commande provenant de trajectoire, comment recup, quel format, quel taille? // gestion motors // gestion stabilisation, get services? } } 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(); }