Color sensor sensing a color when the color isnt present

For our color sensor, it works as it detects the colors accordingly on the control panel and is capable of turning our motor to certain positions for each color; however, a major issue for our color sensor right now is that everytime it does not sense the colors on the control panel, it’ll say that the color is green for the rest of the time the robot is enabled. This is a big issue as I am not sure as to why it always sees the color green when looking at its surroundings, so I really appreciate if anyone could guide me as to why the robot always detects green.

The code for the color sensor is on our github in case there’s anything in my code that is the issue.

I haven’t used this sensor, but as a couple of stabs in the dark:

  • The four colors this year are red, yellow, green, and blue, leaving cyan and majenta. Try putting a light cyan or magenta transparent filter in front of the sensor (likely magenta as it’s opposite green) to see how much it helps.
  • Add a proximity sensor next to your color sensor. If there isn’t anything at about the range you expect the control panel to be, ignore the color sensor.

I’ve found the default values provided by REV’s example code lean toward green a bit and need some massaging to get right. Try adjusting the values for the 4 colors. You can retrieve the specific values by sending (or green or blue) to SmartDashboard

There’s a setConfidenceThreshold member in the color matcher. You could tell it to be less generous with its matching and you could likely tune it so that you get your expected “unknown” value if it’s not close enough to any of the colors. There’s also a confidence score returned by the color match that you could check yourself.

However…as a purely practical matter, the fact is that you never care what the color is unless you’re actively trying to spin the wheel. It’s not being done during autonomous mode, so the approach 6933 took was to ignore the color entirely unless the operator was actively holding down the “please spin the wheel” button on the controller. While you’re doing that, presumably the robot is jammed against the control panel with the color sensor in a place that couldn’t possibly be seeing anything other than the wheel.

The worst-case scenario is failing to color match when you need to and missing rotations or goal colors. Matching a color when you’re not trying to spin seems like it should be irrelevant. We used an extremely generous color match setting because we really didn’t want to miss anything.

1 Like

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