color sensor

My class is currently working with RobotC and the color sensor. We were able to successfully use the color sensor to “stop on red, go on green” with the color sensor facing forward. We then tried to use the greyscale to line track. Although we could get the values for the greyscale from the device info screen on the brain, the robot would not track (it kept turning away) Now we are trying to have the color sensor read when we are on black or red and it is not picking up either color. Can anyone share any experiences they have had with the color sensor that might shed some light on what we are missing here? Thank you in advance.

In my opinion, it is quite hard to track a line using the VexIQ color sensor. Line tracking robots are typically using 3 sensors with a plenty of room for proper course correction, while VexIQ is only using a single grayscale value, trying to follow an edge of the line, not the line itself. For that to work well, you need several things:

  • Wide line. Or even better just a boundary between solid white and solid black.
  • Proper height of the sensor. Too close to the surface and the difference between full white and full black will be just a few millimeters of transverse movement. Too high and it would see the other edge of the line too.
  • Good location of the sensor relative to the robot turning point. Too far upfront and it won't be able to follow curves. Too centred and it won't have feedback on how well is it fixing the course.
  • Reasonable speed [/LIST] But first of all, don't forget it is following the edge, not the line, so if it is turning away, it may be because you placed it on the wrong edge...
  • When we tried line tracking in grayscale mode, we had to use value of 600. Lighting made a difference.

    Here is one where someone tried line following just to give you some ideas.

    Are you using graphical or text programming? I have had pretty good success line tracking with a single sensor on a Clawbot chassis but writing a program in text coding so it can be a little more complex.
    By using lots of different thresholds and turn rates (say 3 different levels of black and 3 different levels of white as well as an “ideal” straight ahead upper and lower threshold) you can make it quite accurate. The robot needs to move reasonably slowly though as not to lose the line.