RB-ARD-ROBOT-Func-lineFollowConfig

De MCHobby - Wiki
Révision datée du 16 septembre 2013 à 06:48 par Admin (discussion | contributions) (Page créée avec « {{Arduino-Robot-NAV}} <h4>lineFollowConfig()</h4> == Description == Classe RobotControl, librairie d'[[Arduino Robot-Librair... »)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Sauter à la navigation Sauter à la recherche


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

lineFollowConfig()

Description

Classe RobotControl, librairie d'Arduino Robot.

Change the parameters for line following.

Use this function if line-following is not working as expected, or you want to change the robot's speed while line-following.

This function changes the "PD algorithms" that enable to robot to think about what may happen next while line reading. The robot attempts to predict any possible errors on the next reading of the IR sensors, and corrects its movement accordingly by changing the speed of each wheel separately.

See the note below for a deeper explanation.

Syntaxe

Robot.lineFollowConfig(KP,KD,robotSpeed,intergrationTime)

Paramètres

  • KP : int, proportional gain
  • KD : int, derivative gain
  • integrationTime: int, delay time between each time we run the algorithm in ms
  • robotSpeed: int, between 0 and 100, indicating the percentage speed of motors.

Résultat

aucun

Exemple

#include <ArduinoRobot.h>
long timer;

void setup(){
  Robot.begin();
  Robot.beginLCD();
  delay(3000);

  Robot.lineFollowConfig(11,5,50,10);//initialise les paramètres PID
  Robot.setMode(MODE_LINE_FOLLOW);
  timer=millis();
  while(!Robot.isActionDone()){
    //Fait une pause de 3 secondes toutes les 5 secondes
    if(millis()-timer>=5000){
      Robot.pauseMode(true);
      delay(3000);
      Robot.pauseMode(false);
      timer=millis();
    }
    Robot.debugPrint(millis());
  }
  Robot.text("Fait!",0,10,true);
  while(true);

}
void loop(){
}

Note

In the function, KP helps the robot follow the line, and KD dampens the oscillation of the robot.

To find good values for this, there needs to be some experimentation to find a good pair of values. An example test is listed below :

  1. Set KP as 5, KD as 0, choose your robot speed. Set intergrationTime as 10
  2. Run the robot on a line-following track
  3. If the robot goes off the track, increase KP by 1
  4. Repeat as long as the robot improves keeping on the line. Stop changing KP when it's no longer improved.
  5. Increase KD by 1
  6. Run the robot, note if the robot is waving less
  7. Continue incrementing KD by 1, until it stops improving.
  8. When you get the robot following the track without running off the line, you are done with tuning. Take down the numbers so you can use it in the future.

Voir aussi


Source: Arduino Robot, getting started with the Arduino Robot, the Robot's library pages. Crédit: Arduino.cc, licence Creative Common Attribution ShareAlike.

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.