FTC Java - Lots of confusion on using REV Color Sensors

First post on Delphi if I need to correct or add anything please let me know.

I’m assisting a team who is trying to use the REV Color Sensor v2/v3 to move forward to the center spike mark and stop for this years competitions, but we have ran into a number of issues and it seems these parts and libraries are not well documents, so I’m completely lost and unsure how to proceed in helping them troubleshoot.

Our issue is no matter what methods we use or hardware configurations we use, everything just gives the value of 0. This includes .red() .blue() .green() .argb() all of the ones in the com.qualcomm.robotcore.hardware.ColorSensor library as well as the rev v3 one. We even tried the ones just returning the light intensity and everything is 0 no matter what with the LED switch on and off. We first tried some old v2 sensors and then moved on to the v3 sensors (unsure what the difference is) and tried both “Rev Color/Range Sensor” and “Rev Color Sensor v3” in the Robot Configuration and all combinations yield similar results. We are confident everything is electrically working, we have no i2c errors or failed to communicate errors on the Driver Hub. The sensor is about 1.5 centimeters above the ground, which I would think should be good. We tried using the block programming from the Control Hub’s web interface too, it programs it exactly how we did in Java and as expected same issue, everything returns 0. I dont have code to post at the moment I’m at my university right now but I can post some later. We made a new blank auto op mode and all it does is get values from the sensor using various methods and prints them to the Driver Hub with Telemetry, and there are no runtime or compile errors. I can post code later today but in the meantime I have a couple questions:

  • What is the difference between the v2 and v3 sensors?
  • Do I need to use different libraries between the v2 and v3? The example code uses the same robotcore libraries for both sensors (v2: Application Examples - Color Sensor v3: Application Examples - Color Sensor)
  • I found the example code for using this sensor with FRC (to which I am familiar, I used to help with FRC and we used the same sensors). I can’t link it here because of some sort of new member rule on this forum but just google “Rev Color Sensor v3 example code” and click the first GitHub link. The libraries in FRC use Color objects to compare and read values from the sensor, does an equivalent library exist for FTC?
  • What’s up with the lack of documentation for these sensors in FTC? All I can find is the stuff on the rev website that I linked above. Is there another color sensor that is better supported and more popular?

Thank you for any assistance, and I’ll get back here with some code for sanity check purposes, although like I said its just printing the returned value of the ColorSensor methods to Telemetry, and we have checked everything every which way by mentors much more experienced than me.

Sample code built with the blocks, everything prints as 0 on the Driver Hub:

'package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.ColorSensor;
import com.qualcomm.robotcore.hardware.NormalizedColorSensor;
import com.qualcomm.robotcore.hardware.OpticalDistanceSensor;

@Autonomous(name = “colortest (Blocks to Java)”)
public class colortest extends LinearOpMode {

private ColorSensor color_sensor;
private ColorSensor color_sensor_REV_ColorRangeSensor;

/**

  • This function is executed when this OpMode is selected from the Driver Station.
    */
    @Override
    public void runOpMode() {
    double count;
color_sensor = hardwareMap.get(ColorSensor.class, "color_sensor");
color_sensor_REV_ColorRangeSensor = hardwareMap.get(ColorSensor.class, "color_sensor");

// Put initialization blocks here.
waitForStart();
if (opModeIsActive()) {
  // Put run blocks here.
  while (opModeIsActive()) {
    // Put loop blocks here.
    while (true) {
      telemetry.addData("Blue: ", color_sensor.blue());
      telemetry.addData("Light: ", ((OpticalDistanceSensor) color_sensor_REV_ColorRangeSensor).getLightDetected());
      telemetry.addData("NormalizedColors:", ((NormalizedColorSensor) color_sensor).getNormalizedColors());
      telemetry.addData("ToText:", color_sensor.toString());
      telemetry.addData("Count:", count);
      count += 1;
      telemetry.update();
    }
  }
}

}
}

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.