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:
- 6:83dafe088914
- Parent:
- 5:32434b497a9b
- Child:
- 7:dc7e66870bd0
--- a/main.cpp Fri May 17 10:19:24 2019 +0000
+++ b/main.cpp Fri May 24 07:48:37 2019 +0000
@@ -8,6 +8,7 @@
// Définition des variables globales
float tableau_distance[360] = {};
int compteur_tours_lidar = 0;
+int affiche_lidar = 0;
// Défintion des pwm
PwmOut pwm_lidar(PB_15); // pwm du Lidar
@@ -79,8 +80,8 @@
angle = atan(x/y);
pwm = 14.662756 * angle*180/3.14 + 1453.08; // à refaire
- if (pwm < 1115) printf("trop petit\n\r");
- if (pwm > 1625) printf("trop grand\n\r");
+ //if (pwm < 1115) printf("trop petit\n\r");
+ //if (pwm > 1625) printf("trop grand\n\r");
return pwm;
}
@@ -90,8 +91,11 @@
//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);
+
+
+
}
}
@@ -117,7 +121,7 @@
// pwm de la direction
pwm_direction.period_ms(20);
- pwm_direction.pulsewidth_us(1469); // correspond à un vitesse faible
+ pwm_direction.pulsewidth_us(1480); // correspond à un vitesse faible
// récupération du premier batch de données (7 bytes) du LIDAR
lidar.putc(0xA5);
@@ -131,7 +135,11 @@
while (1){
//printf("pwm_moteur = %f, pwm_direction = %f", pwm_moteur, pwm_direction);
- afficher_lidar(tableau_distance);
+ if(affiche_lidar==10){
+ afficher_lidar(tableau_distance);
+ affiche_lidar = 0;
+ }
+
update_direction(tableau_distance, dir); // mise à jour à la direction
pwm_direction_value = angle_servo(dir); // calcul du pwm
@@ -154,6 +162,7 @@
uint16_t Distance;
uint16_t Angle_d;
uint16_t Distance_d;
+ affiche_lidar ++;
data[i] = lidar.getc();
i++;
if(i==5)