profile picture

Line-following robot

On our mission to learn Robotics an opportunity presented it self; a line-following competition hosted by IEEE Iceland, November 22nd, 2009. What was known beforehand was this:

  • Track is a 25mm black line on a white 1250x2500mm board
  • Lines perpendicular will cross the track
  • The toughest turn will have a radius of 100mm
  • Five light gates will measure the distance made and 2 points given for each gate
  • Each team gets two attempts
  • The team with the most points and then the best time will win

Some limitations on the robot were:

  • Height 200mm
  • Length 250mm
  • Width 200mm

What we came up with a was a “racer” which can be seen on the following photos:

Picture of Racer car 1Picture of Racer car 2

On the front is the Arduino board with connections to the motor controller which was used to control the motors. The controller can pulse the motors to decrease the 9V from the batteries and change the direction of the motors. This way (and with the help of the steel ball on the front rotating in all directions) the the racer could make any kind of turns and in fact turn on the spot - making it very maneuverable. A plate with LEDs was mounted under the racer with light sensors. The light sensors measure the light reflected from the surface under the racer and therefore sensing where the 25mm black track was.

Picture of Racer car 3

We assigned the sensors a value from -3 (the sensor second furthest to the left) to +3 (the sensor second furthest to the right). As can be seen from the picture there are 8 sensors but because the Arduino board only has 6 analog inputs and we were unable to connect a comparator to connect the remaining 2 to the digital inputs of the board we left the two sensors on the edges unused.

Armed with a way to control the motors and measure the location of the track the only thing left was to create a steering controller. After some pondering we decided to go with a PID controller which I implemented in C++. The aim of the PID controller was to keep the average of the values of the sensors equal to zero. The code for the whole project can be found here.

When we arrived it was announced that the track was a modeled after the F1 Suzuka track in Japan. After a few test rounds where we tweaked the parameters of our racers we were ready to go. 

The race track

Four teams participated in the competition and we were the first team to race. We decided to be on the safe side and we reduced the speed to be sure to finish the track. And we did. Our time 29 seconds. None of the other teams made a successful lap. As we had the lead we decided to try for a faster lap. This time we however we went too fast into one of the turns and the racer lost control. Fortunately none of the other teams made it either and we were declared the winners with 10 points and a time of 29 seconds :)

@robotics