Shop OBEX P1 Docs P2 Docs Learn Events
Questions regarding TCS230DB programming — Parallax Forums

Questions regarding TCS230DB programming

LexLex Posts: 13
edited 2009-02-26 13:59 in BASIC Stamp
I'm trying to incorporate the color sensor into my autonomous robot. The user will input the target's color and the robot will navigate using the sensors.

The question is, should I create a library of RGB values such that when the user input a color, the corresponding RGB values will be loaded?
If this is the case, how can I create a range of RGB values that the sensor can detect?

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-02-23 21:01
    My first approach would be to pick a single, representative RGB triplet for each target color, rather than a range. Then, when the detector encounters an unknown color, it can compare it to all the colors in the target list and pick the closest one. For the BASIC Stamp, I like to use a "minimax" measure to compare colors. The distance between any two colors will be:

    ····ABS(Rsample - Rtarget) MIN ABS(Gsample - Gtarget) MIN ABS(Bsample - Btarget)

    In other words it's the absolute difference between the color components that are furthest apart. The closest color will be the one with the smallest distance, as measured above. In other words, you're MINImizing the MAXimum distance. You can also set a threshold for "close enough", in case the unknown color is "none of the above".

    -Phil
  • LexLex Posts: 13
    edited 2009-02-26 13:59
    Thanx Phil. Will try it out once i've figure out the specific requirements for my project.
Sign In or Register to comment.