4
$\begingroup$

I'm working on a robotics project, and I am using grayscale sensors to automatically follow a black line: turning 90 degrees, going round in a circle, and passing through gaps in the lines etc. I was wondering what is an effective way to detect the colours and move it through the lines, with five or six grayscale sensors.

Thank you very much.

$\endgroup$
  • $\begingroup$ The robot is following a black line, what other colours are you talking about? ("effective way to detect the colours ") $\endgroup$ – user2019047 Aug 15 '13 at 15:05
  • $\begingroup$ as u said, follow a black line, on a white surface. There are also green circles which tell the robot to turn right. That is it, white, green and black. But the line is not only straight, but also curvy, and there are white gaps in between lines. $\endgroup$ – C_Beginner_Learner Aug 16 '13 at 7:42
  • $\begingroup$ Somewhat related: PID line follow with three sensors in Not eXactly C $\endgroup$ – Ian Sep 19 '13 at 17:39
4
$\begingroup$

I recommend arranging your sensors like the following:

         Thickness of Line
            <-------->             /\
            |        |            /  \
            | *    * |             ||
            |        |             || moving
         *  |        |  *          || direction
            |        |             ||
            | *    * |             ||
            |        |             ||

This allows you to detect many conditions. Let's say the sensors receives 1 if on black area and 0 if on white. Let's look at some of the configurations that may happen and their interpretations. I will use |, -, / and \ to indicate the borders of the actual line:

  • You are completely lost:

              0    0  
    
         0              0
    
              0    0  
    
  • moving on straight line:

            |        |
            | 1    1 |
            |        |
         0  |        |  0
            |        |
            | 1    1 |
            |        |
    
  • The line turns right:

              0    0 
            ------------------
         0  |           1
            |         
            | 1    1 |--------
            |        |
    
  • The line turns left:

              0    0 
    ------------------
         1           |  0
                     |
    --------| 1    1 |
            |        |
    
  • Gap ahead:

            |________|
              0    0  
             ________ 
         0  |        |  0
            |        |
            | 1    1 |
            |        |
    
  • Gap behind:

            |        |
            | 1    1 |
            |        |
         0  |________|  0
    
              0    0  
             ________ 
            |        |
    
  • leaning out of the line from the left:

                |        |
              0/   1    /
              |         |
         0   /         /0 or 1
             |        |
            / 1    1 /
            |        |
    
  • you are being teased:

              1    1  
    
         1              1
    
              1    1  
    

There are many other variations you can think of. As one of the examples shows, this also gives you the ability to detect when you are leaning out of the line so you can come back smoothly (without having to turn back on the line sharply). Given this, following the circle shouldn't be a problem at all regardless of whether it's green or black.


Detecting color with grey-scale sensors is possible, but probably not what you are looking for. In your specific case, a value that is far from both 0 and 1 (say from 0.2 to 0.8 or something like that) would depict your color, which is only one. You should still pay attention that if only one of the sensors is showing such a value, for example 0.5, it is likely that you are just going out of the line and it's measuring a half white/half black location.

If you really want to detect the actual color you have to do the following:

  • Use three grey-scale sensors instead of one at each location.
  • On each of the three, mount a color filter; one green, one blue and one red. Color filters are as simple as colored transparent pieces of plastic:

    enter image description here

  • Read the three RGB values and convert them to HSL (Hue-Saturation-Lightness).

  • Base your decisions on the calculated hue. I say only on the hue because the environment lighting very easily changes your observed saturation and lightness so they are not very reliable.
$\endgroup$
1
$\begingroup$

Use dynamic threshold to counter variation of ambient light condition, though the color green may still be hard to distinguish from white and black (dependent on the reflective index of the green material, which you might have to experiment with). This is a serious problem if you are using photo reflectors as grayscale sensors. The distribution of grayscale sensors depends on the size of your robot and your expected speed. If your robot aims at 1.0m/s, I would say six sensors are enough, placed at the front of your robot with a distance of roughly 1cm or 2cm. If you want to achieve higher speed (i.e., 3.0m/s) you might need as many as twelve to sixteen sensors. But these numbers are very inconclusive since you are giving out too limited information about your project. As someone who has done this before, I would recommend using the TSL1401 linear sensor array, which is equivalent to 128 grayscale sensors, yet is still quite cheap.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.