# Line following robot path planning

I have built a mobile robot with several ultrasonic sensors to detect obstacles and an infrared sensor to track a line as a path. I have written a simple algorithm to follow the line which works fine, but avoiding obstacles are a problem because the robot doesn't know the layout of the path, so even if it does move around the obstacle, it is not guaranteed that it will find the path line again(unless the line is perfectly straight). Therefore, I think I may need to use a path/motion planning algorithm or find a way to store the layout of the path so that robot could predict where to move and get back to the path line and keep on following after overcoming an obstacle. I would like to hear suggestions or types of algorithms I should focus on for this specific problem.

Picture might help specifying the problem I'm facing.

Thank you.

• I was also working on a line follower for a very complicated track. This is the image of the track. That is why I also want to use a path/motion planning algorithm or find a way to store the layout of the path so that robot could predict where to move and choose which path to go on. I found several videos on this but none if these show the algorithm or how to implement it! There are the links for the videos: youtu.be/EHAT8ixtxmg (near around 2:30), youtu.be/jVfeRIMLf80 youtu.be/Cbpj1HAaa6s – user8395964 Nov 18 '17 at 8:18

Line following is a simple reactive behaviour. Before you get into planning to solve the obstacle avoidance problem - which can get quite complex - you should consider simpler solutions.

What this simpler solution could be depends a bit on the environment and on your robot. But let me make a suggestion:

while()
if( detect obstacle )
turn left (leave line)
while( not detect line )
keep obstacle within distance d to the right


The devil is in the implementation and sensor setup, but the principle idea is that you track the contours of your obstacle to get you back to your line.

• Thank you, I already have something similar to that to avoid obstacles. You have just re-described the problem I have stated. – JVTura Sep 28 '15 at 22:06
• I think the difference lies in the assumption that the line is straight. By going around the object until you find the line, you will also cover the case for your second illustration. – Jakob Sep 29 '15 at 13:39
• Jakob is correct here. If the obstacle is on the line, you can think of it as having exactly 2 lines touching it: the one you are coming in on, and the one you want to find as you're leaving. If you can detect the obstacle on your side, you are guaranteed that by leaving one line and moving around it, the next line you find will be the one you want. – Ian Sep 30 '15 at 18:46
• You can test whether your solution is working properly by putting the obstacle at the end of a dead-end line. If your robot should find the obstacle, go around it, and re-join the line -- going back the way it came. – Ian Sep 30 '15 at 18:48
• Thank you. The problem becomes more complex if robot meets another obstacles while going around the object and its off the line. It will make another move to avoid it and will possibly end up further away from the line, which makes it almost impossible to find the path again. So I have to return to my main question,a way to store the layout of the path or something equivalent.Blindly going around the object and assuming the path will be detected is not a very consistent solution.If I have time following week,I will be looking into traditional path planning algorithms and will post my solution. – JVTura Sep 30 '15 at 19:37

My suggestion is to start very slowly but comfortable. At first step, don't try to control the robot automatically, instead use manual control and see the robot as a RC-car. Drive a little bit around with the toy and have fun with the obstacles. The second step is to program the domain knowledge into the robot. This is done via a surveillance parser. The software tracks the manual actions of the human operator and prints conclusions on the screen. Like “robot drives straight ahead” “obstacle in front of robot” “robot is on the waypointline”, “robot is off road”. The third and last step is to add a recommendation function to the surveillance system. The software gives an advice what the human operator has to do next. In all steps, the human operator must stay in the loop, it should be a semiautomatic system:

quote: “In this game, the robots are semi-autonomous: Although the robots have intelligence (machine low level) that allows them to follow colored lines, users interact with them and provide high level commands“ Semi-autonomous Color Line-Following Educational Robots: Design and Implementation, 2011