FIRST-Tech-Challenge / SkyStone

FTC SDK
https://www.firstinspires.org/robotics/ftc/what-is-first-tech-challenge
275 stars 1.04k forks source link

Javadoc error - ColorSensor interface #140

Open AlecHub opened 4 years ago

AlecHub commented 4 years ago

Javadoc says the argb() method of the ColorSensor interface returns "hue", which is incorrect.

argb() returns Alpha/Red/Green/Blue channels packed into an int.

You have to use the colorToHSV() method to convert the argb() value to HSV:

float[] hsvValues = new float[3];
Color.colorToHSV(color_sensor.argb(), hsvValues);
float hue = hsvValues[0];  // [0, 360]
float sat = hsvValues[1];  // [0, 1]
float val = hsvValues[2];  // [0, 1]