ajout module_mouvement
Dependencies: mbed xbee_lib ADXL345_I2C IMUfilter ITG3200 Motor RangeFinder Servo mbos PID
Fork of Labo_TRSE_Drone by
Revision 33:ec7d635636bf, committed 2013-04-17
- Comitter:
- IngesupMbed01
- Date:
- Wed Apr 17 15:52:51 2013 +0000
- Parent:
- 32:119e060b45b3
- Child:
- 34:acc8ea8694b4
- Commit message:
- Module communication modifi? et variables globales d?plac?es.
Changed in this revision
--- a/Module_Communication/Module_Communication.cpp Wed Apr 17 13:53:25 2013 +0000 +++ b/Module_Communication/Module_Communication.cpp Wed Apr 17 15:52:51 2013 +0000 @@ -22,6 +22,10 @@ // Pointeur sur la classe systeme d'exploitation instancié dans le main extern mbos *os; + extern unsigned int COMMANDE_TRAJECTOIRE; + extern bool STOP; + extern bool EN_MOUVEMENT; + extern position COORDONNEE_DRONE; /* CONSRTRUCTEUR(S) */ @@ -92,10 +96,87 @@ frame newFrame = m_trameRxBuffer.frameBuffer(); switch(newFrame.moduleIdentifier) { - case 0x31 : + case 0x31 : consigneModuleTrajectoire(newFrame); break; - case 0x32 : + case 0x32 : consigneModuleVideo(newFrame); break; + default : creerTrameSpeciale(0x99); + break; + } - } \ No newline at end of file + } + +void C_ModuleCommunication::consigneModuleTrajectoire(frame newFrame) +{ + switch(newFrame.messageIdentifier) { + case 0x11 : COMMANDE_TRAJECTOIRE = newFrame.data[0]; + EN_MOUVEMENT = true; + while(EN_MOUVEMENT != false); + creerTrameModuleTrajectoire(0x12); + break; + case 0x13 : STOP = true; + EN_MOUVEMENT = true; + while(EN_MOUVEMENT != false); + creerTrameModuleTrajectoire(0x14); + break; + case 0x15 : creerTrameModuleTrajectoire(0x16); + break; + + default : creerTrameSpeciale(0x99); + break; + } +} + +void C_ModuleCommunication::creerTrameModuleTrajectoire(unsigned char idMessage) +{ + frame newFrame; + newFrame.moduleIdentifier = 0x31; + + switch(idMessage) { + case 0x12 : newFrame.messageIdentifier = 0x12; + break; + case 0x14 : newFrame.messageIdentifier = 0x14; + break; + case 0x16 : newFrame.messageIdentifier = 0x16; + union conversionCharFloat conv1; + conv1.f = COORDONNEE_DRONE.x; + newFrame.data[0] = conv1.ch[0]; + newFrame.data[1] = conv1.ch[1]; + newFrame.data[2] = conv1.ch[2]; + newFrame.data[3] = conv1.ch[3]; + conv1.f = 0; + conv1.f = COORDONNEE_DRONE.y; + newFrame.data[4] = conv1.ch[0]; + newFrame.data[5] = conv1.ch[1]; + newFrame.data[6] = conv1.ch[2]; + newFrame.data[7] = conv1.ch[3]; + conv1.f = 0; + conv1.f = COORDONNEE_DRONE.z; + newFrame.data[8] = conv1.ch[0]; + newFrame.data[9] = conv1.ch[1]; + newFrame.data[10] = conv1.ch[2]; + newFrame.data[11] = conv1.ch[3]; + break; + } + + m_trameTxBuffer.frameBuffer(newFrame); +} + +void C_ModuleCommunication::creerTrameSpeciale(unsigned char idMessage) { + frame newFrame; + + switch(idMessage) { + case 0x00 : newFrame.moduleIdentifier = 0x00; + newFrame.messageIdentifier = 0x00; + break; + case 0x99 : newFrame.moduleIdentifier = 0x99; + newFrame.messageIdentifier = 0x99; + break; + } + m_trameTxBuffer.frameBuffer(newFrame); +} + +void C_ModuleCommunication::consigneModuleVideo(frame newFrame) +{ +} \ No newline at end of file
--- a/Module_Communication/Module_Communication.h Wed Apr 17 13:53:25 2013 +0000 +++ b/Module_Communication/Module_Communication.h Wed Apr 17 15:52:51 2013 +0000 @@ -24,6 +24,7 @@ #include "mbos.h" #include "xbee.h" #include "Buffer_Trame.h" + #include "Service.h" class C_ModuleCommunication { @@ -47,6 +48,10 @@ void traitementTrame(void); void envoiDeTrame(void); void receptionDeTrame(void); + void creerTrameModuleTrajectoire(unsigned char idMessage); + void creerTrameSpeciale(unsigned char idMessage); + void consigneModuleTrajectoire(frame newFrame); + void consigneModuleVideo(frame newFrame); /* FONCTIONS */
--- a/Service/Service.cpp Wed Apr 17 13:53:25 2013 +0000 +++ b/Service/Service.cpp Wed Apr 17 15:52:51 2013 +0000 @@ -19,6 +19,14 @@ #include "Service.h" + unsigned int COMMANDE_TRAJECTOIRE; + unsigned int NIVEAU_BATTERIE; + bool STOP = false; + bool EN_MOUVEMENT = false; + position COORDONNEE_DRONE; + position DONNEE_GYROSCOPE; + position DONNEE_ACCELEROMETRE; + /* CONSRTRUCTEUR(S) */ C_Service::C_Service() {
--- a/Service/Service.h Wed Apr 17 13:53:25 2013 +0000 +++ b/Service/Service.h Wed Apr 17 15:52:51 2013 +0000 @@ -47,13 +47,6 @@ float z; }position; - unsigned int COMMANDE_TRAJECTOIRE; - unsigned int NIVEAU_BATTERIE; - position DONNEE_GYROSCOPE; - position DONNEE_ACCELEROMETRE; - - - class C_Service { private : /* ATTRIBUTS */