# Line following help with acute and right angles

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

• 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.
– JRE
Sep 8 '19 at 15:03
• 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? Sep 8 '19 at 17:34
• @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?
– jonk
Sep 8 '19 at 22:36
• 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. Sep 8 '19 at 22:42
• *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 Sep 8 '19 at 22:43