Obstacle avoidance with line following

Hi all.

I know this is an oft-repeated question but I did not manage to find a satisfactory reply anywhere.

My robot is following the line perfectly with the line following code in it.

My robot is also avoiding the obstacle perfectly with the avoidance code.

But…

When I combine the two, even basic line following does not work!! :frowning:

Algorithm is like this:

follow_line()
{
if(obstaclepresent)
{
avoid_it_by_going_around_it;
}
}

Please help!

It’s urgent!

sulivuli:
I know this is an oft-repeated question

Actually I don’t recall seeing it before

sulivuli:
Please help!

How, without seeing your code?

What troubleshooting have you tried?

The fundamental problem with that is "How does it find the line again?" Usually line followers can only stop and wait until the obstacle moves. If it has good enough vision to find the line (a staggeringly difficult task) then it doesn't need to follow lines at all.