Some footage of the robot running in the stadium. The process of tweaking the PID values is tricky. Even after a long time working on these values, I have given up (for the day!) and stayed with slow speeds, which are easier to work with.
At the beginning, the main challenge I faced was to get the sensors to distinguish between the line from the red background. Calibrating them is done using another Arduino sketch, one by one.The RGB values differ slightly from one sensor to another, and determining the threshold is a trial and error process. After overcoming this hurdle, I started to work on the interesting (and yet tedious) part – tuning the control algorithm.
This process is mostly done using trial and error as well. I have decided on a general value for the Proportional part of the PID, using a simple linear equation. Because I have decided the steering servo’s maximum value should be 93 degrees at position 6 (line is the most left), and minimum value 75 degrees at position 0 (line on the right) and 84 degrees is moving straight, I have got the function:
angle = 3*position + 75
That way, the coefficient of the position, is the Proportional part’s base value. I have proceeded and further tweaked it throughout the day.