Modern Robotics Color Sensor

Modern Robotics Color Sensor Calibration

Updated 7/24/2017 with a new OpMode for version 3.1 of the FTC App.

The Modern Robotics Color Sensor may need calibration depending on its intended use. For example, a calibration that works for distinguishing illuminated red and blue beacons may not be suitable for detecting a colored piece of tape. While it is possible to initiate calibration using the Core Device Discovery application, it isn’t very easy.

To help, we’ve written an OpMode that can help. We can add this file to our TeamCode directory and run it to see instructions printed in the driver station’s telemetry. It assumes we called our color sensor color, so be sure to change this (line 45) depending on the name used in the robot controller configuration file.

 

CalibrateColorSensor.java

 

Sidenote: If you’re interested in writing I2C commands in an OpMode, use this file as an instructive example.

Using the OpMode

Completing the calibration will require a GamePad set up as User 1 (press Start+A). Modern Robotics recommends we perform the white calibration with the sensor approximately 2 inches away from a white surface, such as several layered sheets of white printer paper. On the other hand, they suggest we perform the black calibration while the sensor faces empty (dark) space. You may choose an alternative path, by calibrating black while facing a grey field tile, and white over a white piece of tape. Changing the calibration scheme will affect the range of values you see in different circumstances.

While running the OpMode, you can start the black calibration with button X, and white with button Y. The calibration only takes a second or so (64 measurements, at 60 Hz). There will be a small blink of the sensor’s LED when it is done. If we don’t look carefully, we might miss it.

Try it out, and see how the calibration affects the values read. If you have any feedback or suggestions for improvement concerning CalibrateColorSensor.java, please let us know.

AJ Foster

AJ is an FTA for the Tesla Robotics League in Orlando, FL. He enjoys teaching FTC-related stuff, helping teams at competitions, and making the things he learns accessible to everyone.