Line tracker Question...

Our team is planning on using line trackers on our bot but we do not have the official field mat or a way to get one before our next competition, so does anybody happen to know the value that the line tracker returns on the mat so that our programmers can calculate a threshold value?

I’ve used line trackers in the past, and there really is no threshold value you can use. The value that the sensor detects depends on the lighting in the room, how bright it is, how little light is getting under the robot etc etc, when you get to the competition early you should be able to use the skills field to calibrate the value. If there is no skills field you should ask a ref to calibrate it before hand on the actual field, we found this out the hard way as the lighting makes a huge impact.

@science_fair if you are going to hardcode the threshold value, then what @Parker suggested is the best way to do it. However, be aware that the numbers may depend on lighting at the specific field and could differ between the practice field and actual skill field that you will be running at.

Alternative way is to estimate the threshold values on the fly. Essentially, you will need to average sensor reading over several seconds of the drive time. For example:

avg = some_initial_hardcoded_guess; 
while(1)
{
          val = SensorValue[lineTracker];
          if( abs(val-avg) < some_constant ) // crude filtering to exclude white lines and colored tiles
          {
              avg = 0.1*val + 0.9*avg; // smoothing averaged value 
          }
          if( val > avg + while_line_over_grey_tile_threshold )
          {
              // white line detected
          }

         // do something

         delay(20);
}

You will still need to calibrate at least three constants (or make them dependent on estimated “avg”), and you will need to make sure that “avg” is not going to run away while you are parked on the colored tile or over the white line, but this method should be able to adapt to the lighting condition and possible variations in floor tile brightness on the different fields at the event.

You could also use a threshold value determined at the event (which is usually the best way to ensure your autonomous will run without any hitches). A few suggestions for this:

  1. You could drive your robot over the lines and have your program look for a rising and falling edge on the sensor input. Then it could determine a threshold or an expected value input and save it to flash (or output it to an LCD for your programmer to hardcode in).
  2. You could also just place your robot on the white line and derive the sensor value at that point (which should work most of the time, assuming a few things about your robot).