Modifications

Sauter à la navigation Sauter à la recherche
2 651 octets ajoutés ,  16 septembre 2013 à 06:48
Page créée avec « {{Arduino-Robot-NAV}} <h4>lineFollowConfig()</h4> == Description == Classe RobotControl, librairie d'[[Arduino Robot-Librair... »
{{Arduino-Robot-NAV}}

<h4>lineFollowConfig()</h4>

== Description ==
Classe [[Arduino Robot-Librairie#Classe_RobotControl|RobotControl]], librairie d'[[Arduino Robot-Librairie|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 ==

<nowiki>#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(){
}</nowiki>

== 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 :

# Set KP as 5, KD as 0, choose your robot speed. Set intergrationTime as 10
# Run the robot on a line-following track
# If the robot goes off the track, increase KP by 1
# Repeat as long as the robot improves keeping on the line. Stop changing KP when it's no longer improved.
# Increase KD by 1
# Run the robot, note if the robot is waving less
# Continue incrementing KD by 1, until it stops improving.
# 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 ==
* [[RB-ARD-ROBOT-Func-setMode|setMode()]]
* [[RB-ARD-ROBOT-Func-pauseMode|pauseMode()]]
* [[RB-ARD-ROBOT-Func-isActionDone|isActionDone()]]

{{Arduino-Robot-TRAILER}}
29 918

modifications

Menu de navigation