Advanced Line Follower # Sharp 90 Degree

Hey,
I'm a little new to arduino. But I have been using them for a while and now familiar with them. I'm building a line following robot for a contest. But I want it to be more advanced.
As we know usually line followers are programmed to switch off one wheel when the relevant sensor is out of the line. I want some more precise control for it.
I saw some videos of robots using the PID method. It's good.
My robot has two "powered" wheels in the middle and two caster balls in front and back. Awkward design but you will see why I have to do so in the questions.

These are what I am using.
#Geared motor with wheels- eBay

#IR sensor TCRT5000L TCRT5000- eBay

#L298N Motor driver- eBay
(I am going to build a motor shield too.)

Now these are what I want to know.

1)Because of the terms of the contest I can't use ready-made modules. (Eg-QTR-8RC, L298N module). I had to make a P.C.B even for the motor driver, and the arduino itself! anyway they function just as the original ones.
The track which the robot has to follow is black and contains a "Y" junction(doesn't matter which way the robot takes) , a sharp 90 degree turn and curves. And has a width of 3cm. The starting point is a 25x25cm black square and at the end of the line there is a 25cm diameter black circle where the robot should stop automatically. (Image 01)

How many sensors should I use as you think? And please give me some idea about the arrangement of the sensors too.

2)I thought of performing a special manoeuvre at the sharp 90 degree turn. It is something like this. The robot goes straight and stops at a certain point on the 90degree turn. And the two wheels rotate in the two opposite directions making the whole robot "rotates" until it faces and align with the other side of the turn(Y side). It's hard to explain. I have uploaded pictures too .Hope you get the idea. This is why I'm going to use two caster balls back and front.

I drafted one using 8 sensors. At the 90degree turn it works like this.
1- moving forward. Sensors read 00111100(image 2)

2- the sensors just get the side of the turn.(image 3) The sensors read 11111100
And command like
"Move forward for a 'x' time.
Then stop. Rotate the wheels in two opposite directions for a 'y' time or until the sensors read 00111100."
I adjust x and y until I get the robot turned perfectly aligned with the track.(image 4)
Is this possible? Please point me out to some code guides on the web.

3)I have no idea about what to do at the Y junction. I think I should use another sensor in the middle a head of the others. Will it work?
Any comments?(image 5)

I studied PID a lot. What I can't figure out is how to get the sharp 90 degree turn and the Y junction decision.

#This is a time based contest and the robot has to be fast.

Any tips,tricks,guides or anything are welcome. Thank you very much.
After completing I will post a clear description of everything.

1 Like

I'm not sure about the number of sensors to use. More sensors may be hard to code properly.

On an (almost) straight line a couple of sensors should be on the track, some to the left/right be off track. Eventual false readings (00110100) can make it hard to distinguish the on-track sensors from off-track or other situations. A center-ahead sensor may be helpful for detecting 90° turns or Y.

My problems with such a robot were:

  • could not be steered fast enough (scripted, not Arduino code)
  • could not move slowly for debugging (DC motors with encoders, here stepper motors should work better)
  • single caster wheel didn't prevent tilting with fast braking (two caster balls should work better)
  • the robot moved or turned the paper plane (course) on my carpet, when braking/accelerating/rotating too fast

I couldn't fix all these issues and gave up after some experiments, my (universal) robot kit was not well designed for that purpose. You should be able to avoid these problems with your own design. I've seen a video with cars following a round (oval) course at about 30km/h, so it's feasible in general :slight_smile:

From my experience I'd use stepper motors, which can be controlled precisely (speed and distance), not DC motors. Once your sketch works fine at low (snail) speed, you can start tuning it for higher speed. Eventually I'd try analog sensors, covering a larger (sideways) area, instead of multiple digital spotting sensors. This could give a better value (difference) for a PID controller on (almost) straight lines. Eventually two such pairs near the casters, not at center - not sure whether this is a good idea. The code can use additional sensors in case of sharp bends or Y. An ahead sensor can be used to slow down the robot, in preparation of a sharp curve or tendency of losing the track. The Y IMO should be handled very specially, not mixed up with a single line following. Same for the end of the track, and 90° bends, where the sensors may deliver values that never can occur in other situations (all off while turning...). The start situation occurs only once, can be handled separately and once only. Is the robot started in direction of the course, or must it find the outgoing line?

Good luck with your project :slight_smile: