Line following: odd or even number of sensors?

Morning all,

Pololu’s sample code here (scroll down, just above the heading “PID control”), has 3 sensors and talks in its comments of keeping the middle sensor on the line. That makes intuitive sense to me, but then they go and sell an 8-sensor strip (from which you may split 2, making a 6 and a 2) which of course don’t have middle sensors.

What’s the feeling on odd vs even?

I think 6 is overkill anyway, so I might just mount 6 off-centre and use 5 or 3.

EDIT… I just downloaded their latest library, and it has code for a 6-sensor strip. Turns out, that for their recommended line width of 3/4" 19mm, then the two middle sensors are on the line.

Turns out, that for their recommended line width of 3/4" 19mm, then the two middle sensors are on the line.

Which makes detecting the edge of the line faster, since an edge is closer to one of the sensors. The sooner you detect a change in the position of the follower vs. the line, the sooner you can make a correction, and the smaller the correction needs to be.

PaulS:

Turns out, that for their recommended line width of 3/4" 19mm, then the two middle sensors are on the line.

Which makes detecting the edge of the line faster, since an edge is closer to one of the sensors. The sooner you detect a change in the position of the follower vs. the line, the sooner you can make a correction, and the smaller the correction needs to be.

Yep... they also use a cunning method to calculate a weighted (weighted by sensor position) value of sensor readings, so you know where the line is relative to the sensor array. Upfront, you hand calculate the target value for the line in the centre, then hardcode that value onto the sketch. Then in real time you compare the actual value to the target, and steer accordingly. So in fact, the odd vs even question is irrelevant.

I've never messed around with line followers, but I think that the increased number of sensors also relate to how to sense when the vehicle crosses over a line "perpendicular" to the line being followed (so it can be ignored in preference to the actual path being taken).

7th graders make Lego Mindstorm line following robots with just 1 light/dark sensor. Having 5-6-7-8 seems like overkill.

7th graders make Lego Mindstorm line following robots with just 1 light/dark sensor. Having 5-6-7-8 seems like overkill.

I hated using only one light sensor so one of my first electronics projects was making a light sensor array, however, I was reviewing the Mindsensors web sight recently and they now sell an array with 8 Light sensors!

Looks like Lego has expanded since I last used it. Never got far programming it, hated the drag & drop programming environment.

Their programing language (NXT-G) is a piece of crap, however, the after market ones are pretty good like Robot C. I teach STEM classes with the NXT and I hate when I have to work at a facility that only has NXT-G.

cr0sh:
I've never messed around with line followers, but I think that the increased number of sensors also relate to how to sense when the vehicle crosses over a line "perpendicular" to the line being followed (so it can be ignored in preference to the actual path being taken).

Yes, I was thinking that too. I'll be testing that thinking....

Also, with more sensors, you can tell how far away the robot centreline is from the line, and use that fact to dictate the best way to get back on track, say in terms of speed and angle of approach.

From my experience, the most important thing is the width of the line vs. the spacing and sensitivity of the sensors. Having sensors spaced out in a way that two can "see" the line at the same time and there are no gaps in the readings, is a simple and effective way to get higher "resolution". From that point, the more sensors you have in the array, the more options you have to fine-tune your steering and get a faster, smoother line following. Sharp corners are also easier to detect with a larger array of sensors. You maybe able to get decent performance from a lower number of sensors that are spaced out further apart, if you can do an anlog read of the value to estimate the relative position of the line under the array.

You can make your own custom array fairly cheaply with a bunch of TCRT5000 and a few resistors. Some use V shaped sensors arrays etc. to deal with more complex courses, for example.

You can definitely follow a line with a single sensor, but it will not be pretty and it will not be fast.