Need help for building an advanced Line Following Robot

I’m new in this project and also in this forum. Let me explain my current situation and my next target.
I’ve used Pololu QTR -8A sensor for sensing the line. I’ve used the QTR Library to calculate the error and take action according to the error. So far my success is:

  1. The bot is following simple line i.e. a straight and circular line, but not any cross line or T shaped line or broken line or else.
  2. If the bot gets out of the track, it finds back the track

The main problem I’m facing is:
I need to calibrate the same line each time I start the bot.

My next goal and the reason I’m writing here:
In the competitions, there’s some situations where:

  1. The line breaks and continues at a distance of 20cm with ±30degree angle
  2. The line breaks and the bot needs to go straight, turn left when an object is detected, go straight again, and when a line is found, follow the line

These are the main two problems I’m looking for solution. According ot the QTRA library, if the line is lost from sensor 0, then the reading would be 0. And if the line is lost from sensor 7, the reading would be 7000. Thus error = 3500-readline() finds the error. What I’m trying to do is, If the line is lost from the middle of the sensor, keep the error 3500 until it finds the line again so that it can go straight. How can I do so?


One way you could do something like that would be to add a variable to track of the previous line reading, so you can verify that the line disappeared and did not drift out of range (e.g. line is under sensor 1 or line was lost from sensor 0). Then if the line gets lost and was last seen somewhere in the middle of the sensor, you can set the error to 3500 like you mentioned.

As for your issue with calibrating your QTR sensor array every time at start-up, you could try storing the QTR calibration in your microcontroller’s EEPROM.

- Amanda