Color Sensor
The REV Color/Range sensor is a very versatile device used in robotics, particularly in FTC. It combines both color sensing and proximity detection capabilities.
This section will cover the color detection aspect of the sensor.
The color sensor works by measuring the intensity of red, green, and blue light intensity (RGB). Using a combination of these colors, the entire visible color spectrum can be made.
The sensitivity of this measurement is called the gain of a color. It can be set using
Basically, it makes lighter colors lighter and darker colors darker. A higher gain is more useful when there is little light to differentiate between different colors. A low gain is used when there is high amounts of light to help normalize the values.
Different FTC fields will have different amounts of light which can cause the color detector to become uncalibrated. Using the LightDetected block
you can see how intense the light is. You can use the value returned to adjust the gain to allow for optimal color sensing.
Another way the colors are recorded are in Argb format. This is similar to RGB but there is a 4th value alpha (A), which represents the opacity or transparency of a color. A higher alpha value means the colors are more opaque.
You can also use
to get normalized RGBA values instead of raw inputs. This will expand or contrast the color values into a set range, allowing for more predictable color input values.
So now you have these RBG or RBGA values. What do you do with them? Well, in their raw state the values are useless. To get meaningful information out of them you have to interpret parts of the data. You do this by setting a variable to your desired data
and then using a color block to get specific values like saturation, hue, and value. You can then use these values in logic statement to determine if the desired color has been detected.
One way is to use hue. Here we set the variable “hue” to the hue to the normalized colors.
You can then use an if statement to check if the color red has been found and display it on the telemetry.
Finally put the code within a loop for continuous monitoring and you get the following red color detection code.
To find out more about which color codes correspond to which color, please use google where tools are available to help you find out.
RGB Color chart:
https://www.rapidtables.com/web/color/RGB_Color.html
RGBA Color Chart:
Color Format Converter:
https://www.myfixguide.com/color-converter/
Color sensors are invaluable for object detection in FTC, helping to differentiate otherwise equally shaped or hard to find objects. It is also used in autonomous navigation where color lines can help let your robot know its position or indicate when it should stop. The options are limitless!