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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 7:dc7e66870bd0
- Parent:
- 6:83dafe088914
- Child:
- 8:2ce9493549e8
diff -r 83dafe088914 -r dc7e66870bd0 main.cpp --- a/main.cpp Fri May 24 07:48:37 2019 +0000 +++ b/main.cpp Fri May 31 12:05:59 2019 +0000 @@ -2,7 +2,7 @@ #include <math.h> // Définition des ports séries -Serial pc(SERIAL_TX, SERIAL_RX, 115200); +Serial pc(USBTX, USBRX, 115200); Serial lidar(PC_6, PC_7, 115200); // Définition des variables globales @@ -46,12 +46,12 @@ theta = i; r = list_lidar[theta]; - if (r == 0) break; // non calcul en cas de distance nul (donnée non capté) + if (r == 0) break; // non calcul en cas de distance nul (donnée non captée) //x = 0; //y = 0; - x = r*cosf(theta); - y = r*sinf(theta); + y = r*cosf(theta); + x = r*sinf(theta); sum_inv_dist += 1/pow(r, 2); avg_x -= x/sum_inv_dist; avg_y -= y/sum_inv_dist; @@ -91,13 +91,9 @@ //Affiche les données du lidar dans la liaison série int angle; for(angle=0;angle<360;angle++){ - float distance = tableau_distances[angle]; - pc.printf("%i,%f\n\r",angle,distance); - - - - - } + float distance = tableau_distances[angle]; + pc.printf("%i,%f\n\r",angle,distance); + } } int main(){ @@ -109,14 +105,18 @@ int i; - + + + + + // pwm du LIDAR pwm_lidar.period_us(40); pwm_lidar.pulsewidth_us(40); // vitesse fixe // pwm du Moteur pwm_moteur.period_ms(20); - pwm_moteur.pulsewidth_us(1400); // correspond à une vitesse nulle + pwm_moteur.pulsewidth_us(1440); // correspond à une vitesse nulle // Gaspard : 1450, Solal : 1480. Tester les deux // pwm de la direction @@ -135,7 +135,7 @@ while (1){ //printf("pwm_moteur = %f, pwm_direction = %f", pwm_moteur, pwm_direction); - if(affiche_lidar==10){ + if(1){ afficher_lidar(tableau_distance); affiche_lidar = 0; } @@ -183,15 +183,14 @@ // On vérifie que l'on écrit pas en dehors du tableau if(Angle_d>359) Angle_d=359; if(Angle_d<0) Angle_d=0; - - /* + if (Quality < SEUIL) { // Fiabilisation des données du LIDAR naïve tableau_distance[Angle_d] = tableau_distance[Angle_d - 1]; } else tableau_distance[Angle_d] = Distance_d; -*/ - tableau_distance[Angle_d] = Distance_d; + + //tableau_distance[Angle_d] = Distance_d; } }