Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 7:20d05f0d11a2, committed 2019-06-08
- Comitter:
- Mrlinkblue
- Date:
- Sat Jun 08 09:41:48 2019 +0000
- Parent:
- 6:9af875ef7b30
- Commit message:
- version_8_juin
Changed in this revision
lidar.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9af875ef7b30 -r 20d05f0d11a2 lidar.h --- a/lidar.h Thu Jun 06 16:30:59 2019 +0000 +++ b/lidar.h Sat Jun 08 09:41:48 2019 +0000 @@ -1,13 +1,14 @@ #include "mbed.h" Serial ld(PC_10,PC_11,115200); - +DigitalOut myled3(LED3); PwmOut pwm_lidar(PC_8); void Interrupt_ldRX(void); DigitalOut myled1(LED1); uint16_t data[4]; // donnees traitees uint16_t prevData[4] = {1, 10, 0, 1000}; // donnees traitees precedentes +uint16_t dataReady[4]; // donnees traitees prete a utilisation int newData = 0; // flag indiquant de nouvelles donnees bool newRadar = false; // flag indiquant un nouveau tour effectué @@ -56,7 +57,7 @@ angleHex2 = data_received[2]; checkC = (angleHex1&0x01); angle = (((uint16_t)angleHex2) <<1) + ((uint16_t)angleHex1>>7); - angle = angle - 180; // Decalage par rapport au centre du lidar et de la voiture + angle = angle; // Decalage par rapport au centre du lidar et de la voiture // distance distanceHex1 = data_received[3]; distanceHex2 = data_received[4]; @@ -127,8 +128,7 @@ static int i=0; // indice dans un paquet de donnees (5 octets) static uint8_t data_received_temp[5]; uint16_t data[4]; - //static uint16_t prevData[4]; - //static int newData = 0; + static int16_t angle_old=0; data_received_temp[i] = ld.getc(); // on recup l info @@ -136,22 +136,30 @@ if(i==4){ // on met les donnees utilisables dans data ldConvert(data_received_temp, data); + if((data[2]>=0)&&(data[2]<360)) + Radar[data[2]]=data[3]; + if((int16_t)data[2]<(angle_old-180)) + newRadar=1; + angle_old=(int16_t)data[2]; + //creation tableau de travail, traiter les 0 ou vider // on verifie le bit de check et la qualite - if (data[0] &&(data[1]>=8)){ - // data -> prevData + /* if (data[0] &&(data[1]>=8)){ + // data -> dataReady + addRadar(data,prevData); + for(int k=0; k<4; k++){ prevData[k] = data[k]; } newData = 1; } - if (data[0] &&(data[1]<8)){ + if (data[0] &&(data[1]<8)){ // muvaise mesure //addRadar(Radar,data,prevData); - //for(int k=0; k<3; k++){ - // prevData[k] = data[k]; - //} - } + for(int k=0; k<3; k++){ + prevData[k] = data[k]; + } + }*/ } i=(i+1)%5; }
diff -r 9af875ef7b30 -r 20d05f0d11a2 main.cpp --- a/main.cpp Thu Jun 06 16:30:59 2019 +0000 +++ b/main.cpp Sat Jun 08 09:41:48 2019 +0000 @@ -9,7 +9,7 @@ // Timer DigitalOut myled2(LED2); -DigitalOut myled3(LED3); + Serial pc(USBTX,USBRX,115200); float tnul = 0.0; @@ -60,7 +60,7 @@ voiture_deltat = t.read() - t1; } - while (start) { //while(start){ + while (1) { //while(start){ // données de la centrale inertiel // data_distances = Radar; recuperer_start(deltat_start); @@ -78,16 +78,24 @@ // L'actualisation ne se lance que si on a un tableau complet - + // if (newData){ + // newData = 0; + // addRadar(dataReady, prevData); + // for(int k=0; k<4; k++){ + // prevData[k] = dataReady[k]; + // } + //} if (newRadar) { cpt++; newRadar = false; - myled3 = !myled3 ; + //myled3 = !myled3 ; // Conversion tableau -> vector for (int i =0; i<360; i++) { data_distances[i]=float(Radar[i])/1000.0; // (m) } + myled3=!myled3; actualisation(); + //myled3=0; if(cpt%100==0) { for(int i=0; i<360; i++) { pc.printf("%3d %4.3f%\n",i,data_distances[i]);