Modifications

Sauter à la navigation Sauter à la recherche
Ligne 19 : Ligne 19 :  
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
/*
 
/*
  * Demo line-following code for the Pololu Zumo Robot
+
  * Code de démo suiveur de ligne (line-following) pour le Robot Zumo de Polulo
 
  *
 
  *
  * This code will follow a black line on a white background, using a
+
  * Ce code suivra une ligne noire sur un fond blan et utilise un
  * PID-based algorithmIt works decently on courses with smooth, 6"
+
  * algorithme de type PID.  Il fonctionne correctement sur des
  * radius curves and has been tested with Zumos using 30:1 HP and
+
  * circuits avec des courbes ayant un rayon de 15 cm.
  * 75:1 HP motorsModifications might be required for it to work
+
* L'algorithme à été testé sur Zumo avec des moteurs 30:1 HP et
  * well on different courses or with different motors.
+
  * 75:1 HP.  Pourrait demander des modifications pour fonctionner
 +
  * sur d'autres circuits ou avec d'autres moteurs.
 
  *
 
  *
 
  * http://www.pololu.com/catalog/product/2506
 
  * http://www.pololu.com/catalog/product/2506
 
  * http://www.pololu.com
 
  * http://www.pololu.com
 
  * http://forum.pololu.com
 
  * http://forum.pololu.com
 +
*
 +
* Zumo également disponible chez MC Hobby (le traducteur du tutoriel)
 +
*
 +
* http://shop.mchobby.be/product.php?id_product=448
 
  */
 
  */
   Ligne 45 : Ligne 50 :  
int lastError = 0;
 
int lastError = 0;
   −
// This is the maximum speed the motors will be allowed to turn.
+
// Ceci est la vitesse de rotation maximale des moteurs.
// (400 lets the motors go at top speed; decrease to impose a speed limit)
+
// (400 permet au moteur d'aller a vitesse max; diminuer la valeur pour imposer une vitesse limite)
 
const int MAX_SPEED = 400;
 
const int MAX_SPEED = 400;
   Ligne 52 : Ligne 57 :  
void setup()
 
void setup()
 
{
 
{
   // Play a little welcome song
+
   // Jouer une petite chanson d'acceuil
 
   buzzer.play(">g32>>c32");
 
   buzzer.play(">g32>>c32");
   −
   // Initialize the reflectance sensors module
+
   // Initialise le réseau de senseur infrarouge
 
   reflectanceSensors.init();
 
   reflectanceSensors.init();
   −
   // Wait for the user button to be pressed and released
+
   // Attendre que le bouton utilisateur soit pressé et relâché
 
   button.waitForButton();
 
   button.waitForButton();
   −
   // Turn on LED to indicate we are in calibration mode
+
   // Allumer la LED et pour indiquer que l'on est en mode calibration
 
   pinMode(13, OUTPUT);
 
   pinMode(13, OUTPUT);
 
   digitalWrite(13, HIGH);
 
   digitalWrite(13, HIGH);
   −
   // Wait 1 second and then begin automatic sensor calibration
+
   // Attendre 1 seconde puis démarrer la calibration automatique
   // by rotating in place to sweep the sensors over the line
+
   // du senseur en faisant des rotations sur place pour faire passer
 +
  // le senseur au dessus de la ligne
 
   delay(1000);
 
   delay(1000);
 
   int i;
 
   int i;
Ligne 77 : Ligne 83 :  
     reflectanceSensors.calibrate();
 
     reflectanceSensors.calibrate();
   −
     // Since our counter runs to 80, the total delay will be
+
     // Puisque notre compteur va jusque 80, le délais total sera de
 
     // 80*20 = 1600 ms.
 
     // 80*20 = 1600 ms.
 
     delay(20);
 
     delay(20);
Ligne 83 : Ligne 89 :  
   motors.setSpeeds(0,0);
 
   motors.setSpeeds(0,0);
   −
   // Turn off LED to indicate we are through with calibration
+
   // Eteindre la LED pour indiquer que nous avons terminé la calibration
 
   digitalWrite(13, LOW);
 
   digitalWrite(13, LOW);
 
   buzzer.play(">g32>>c32");
 
   buzzer.play(">g32>>c32");
   −
   // Wait for the user button to be pressed and released
+
   // Attendre que le bouton utilisateur soit pressé et relâché
 
   button.waitForButton();
 
   button.waitForButton();
   −
   // Play music and wait for it to finish before we start driving.
+
   // Jouer la musique et attendre qu'elle soit finie pour
 +
  // commencer le pilotage.
 
   buzzer.play("L16 cdegreg4");
 
   buzzer.play("L16 cdegreg4");
 
   while(buzzer.isPlaying());
 
   while(buzzer.isPlaying());
Ligne 99 : Ligne 106 :  
   unsigned int sensors[6];
 
   unsigned int sensors[6];
   −
   // Get the position of the lineNote that we *must* provide the "sensors"
+
   // Obtenir la position de la ligneNotez qu'il FAUT fournit le senseur "sensors"
   // argument to readLine() here, even though we are not interested in the
+
   // en argument à la fonction readLine(), même si nous ne sommes intéressé
   // individual sensor readings
+
   // par les lectures individuelles des différents senseurs.
 
   int position = reflectanceSensors.readLine(sensors);
 
   int position = reflectanceSensors.readLine(sensors);
   −
   // Our "error" is how far we are away from the center of the line, which
+
   // L'erreur ("error") est la distance par rapport au centre de la ligne, qui
   // corresponds to position 2500.
+
   // correspond à la position 2500.
 
   int error = position - 2500;
 
   int error = position - 2500;
   −
   // Get motor speed difference using proportional and derivative PID terms
+
   // Calculer la différence de vitesse (speedDifference) entre les moteurs
   // (the integral term is generally not very useful for line following).
+
  // en utilisant un les termes proportionnels et dérivés du régulateur PID.
   // Here we are using a proportional constant of 1/4 and a derivative
+
   // (Le terme intégral n'est généralement pas très utile dans le
   // constant of 6, which should work decently for many Zumo motor choices.
+
  // suivit de ligne).
   // You probably want to use trial and error to tune these constants for
+
   // Nous utiliserons 1/4 pour la constante proportionnelle et 6 pour la
   // your particular Zumo and line course.
+
   // constante dérivée 6, qui devrait fonctionner correctement avec de
 +
  // nombreux choix de Zumo.
 +
   // Vous aurez probablement besoin d'ajuster ces constantes par
 +
   // essai/erreur pour votre zumo et/ou le circuit.
 
   int speedDifference = error / 4 + 6 * (error - lastError);
 
   int speedDifference = error / 4 + 6 * (error - lastError);
    
   lastError = error;
 
   lastError = error;
   −
   // Get individual motor speeds. The sign of speedDifference
+
   // Calculer la vitesse de chaque moteur. Le signe de la différence (speedDifference)
   // determines if the robot turns left or right.
+
   // determine si le moteur tourne à gauche ou a droite.
 
   int m1Speed = MAX_SPEED + speedDifference;
 
   int m1Speed = MAX_SPEED + speedDifference;
 
   int m2Speed = MAX_SPEED - speedDifference;
 
   int m2Speed = MAX_SPEED - speedDifference;
   −
   // Here we constrain our motor speeds to be between 0 and MAX_SPEED.
+
   // Nous allons contraindre la vitesse des moteurs entre 0 et MAX_SPEED.
   // Generally speaking, one motor will always be turning at MAX_SPEED
+
   // D'une façon générale, un des moteurs est toujours à MAX_SPEED
   // and the other will be at MAX_SPEED-|speedDifference| if that is positive,
+
   // et l'autre sera à MAX_SPEED-|speedDifference| si elle est positif,
   // else it will be stationary. For some applications, you might want to
+
   // sinon il sera en vitesse stationnaire. Pour certaines applications,  
   // allow the motor speed to go negative so that it can spin in reverse.
+
   // vous pourriez désirer une vitesse négative, ce qui permettrai de
 +
  // tourner à l'envers.
 
   if (m1Speed < 0)
 
   if (m1Speed < 0)
 
     m1Speed = 0;
 
     m1Speed = 0;
29 917

modifications

Menu de navigation