enter image description here

I am trying to figure out the logic for a line follower with the path shown in the attached image. I am having trouble with <= 90 degree angle turns. So far, I have been using the logic where if the middle and a side's sensor are on the line and the other sensor is on white, then I turn 90 degrees after driving forwards a little. This does not work for the part marked in blue since the distance designated by the arrows is too small to drive forward any amount and the acute angle causes my car to keep going side to side perpetually half the time I run the program.

Also, if I am using proportional line following in order to approach intersections more perpendicularly, do I have to keep track of which side of the line I am on?

Suggestions on how to improve my design would be appreciated

  • 2
    \$\begingroup\$ The usual way to build a line tracker requires only two detectors. You keep the vehicle on track by keeping the brightness equal. That kind of tracker handles acute angles without any kind of special algorithm. \$\endgroup\$
    – JRE
    Sep 8 '19 at 15:03
  • \$\begingroup\$ In order to approximate the position of the line between the two sensors, will it suffice to just subtract the two sensor readings? Also, is derivative and integral controller usually necessary in this type of line tracking or no? \$\endgroup\$ Sep 8 '19 at 17:34
  • 1
    \$\begingroup\$ @MiteshKumar I see the potential for a good question and, sadly, a lack of detail about your sensor system itself. Interpreting your words, I now imagine you have three optical sensors of some kind that may probably all be colinear -- but I couldn't prove it by what you write above. I also don't know the orientation of them with respect to "forward." Etc. A LOT more detail would help make this question interesting. I'd like to know what that perpendicular line means. Is that a starting point? Or is the vehicle supposed to track over all of it, somehow? And what does "too small" mean, exactly? \$\endgroup\$
    – jonk
    Sep 8 '19 at 22:36
  • \$\begingroup\$ I was unsure about the sensor system I should use when I as asking this question. Since then, I have tried 3 sensor with Proportional on the middle sensor and 4 sensor with proportional on the middle two sensors. It is still not working very well. The perpendicular line is just to test the cross over case. When I see black on all sensors then I keep going forward but this doesn't work since only 2 of my sensors reach the line before it starts to turn. I have tried to work around this with driving forward a little as soon as atleast 2 sensors detect a line but this hasn't been working. \$\endgroup\$ Sep 8 '19 at 22:42
  • \$\begingroup\$ *Driving forward a little and then checking if the middle sensor is still black. If it is then I continue PID, otherwise I turn left or right 90 degrees depending on what I saw last. This doesn't work consistently. 3 COLINEAR AND 4 COLINEAR \$\endgroup\$ Sep 8 '19 at 22:43

If you use analog processing of the photodiodes, you can get away with just two photodiodes with slightly overlapping areas so you know exactly how misaligned you are before losing sight of the line completely. But you still might want a pair of outermost sensors to catch the line if the center pair loses track. With four analog sensors in a 2x2 grid (a nearly minimal ring) and slightly overlapping fields I dont think you would ever lose track of the line

A full blown method is to use a ring of photodiodes and search where the line enters the circle and where it leaves, and remember those positions 200ms in the past so you can track which ones are which so you know if a crossover suddenly appeared or which direction is forward at sharp angles. Though if your ring has enough elements you could use phototransistors and get by without analog processing, relying on the number of elements for resolution.

The key here is not to check whether the sensors read black or white. It is to check how dark it is relative to the opposite sensor so you know exactly how much you are veering off by and to be able to do it on more than one axis.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.