Arduino - RobotLineFollowConfig

Arduino

Reference Language | Libraries | Comparison | Changes

Robot

## lineFollowConfig()

#### Description

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.

#### Syntax

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

#### Parameters

- 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.

#### Returns

none

#### Examples

#include <ArduinoRobot.h>
long timer;
void setup(){
Robot.begin();
Robot.beginLCD();
delay(3000);
Robot.lineFollowConfig(11,5,50,10);//set PID parameters
Robot.setMode(MODE_LINE_FOLLOW);
timer=millis();
while(!Robot.isActionDone()){
//pauses line-following for 3 seconds every 5 seconds
if(millis()-timer>=5000){
Robot.pauseMode(true);
delay(3000);
Robot.pauseMode(false);
timer=millis();
}
Robot.debugPrint(millis());
}
Robot.text("Done!",0,10,true);
while(true);
}
void loop(){
}
[Get Code]

#### 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.

#### See also

- setMode()
- pauseMode()
- isActionDone()

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

### Share

### This link has expired.
Please re-subscribe to our Newsletters.

### Subscribe to our Newsletters

Email

Please enter a valid email to subscribe

Arduino Newsletter
Arduino Store Newsletter

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy

###### Newsletter

- ©2015 Arduino
- Copyright Notice
- Contact us
- About us
- Careers