Vision Sensor not detecting color

I am having trouble with my vision sensor code. It is meant to find the red color of the goal, and orient it to face to the goal:

void Aim(){
  Vision.takeSnapshot(Vision__VEXRED); 
  if(Vision.objectCount > 0){
    //Implementation not shown
  } else {
    //Re-aim
    Controller1.Screen.clearScreen();
    Controller1.Screen.setCursor(1,1);
    Controller1.Screen.print("Unable to detect object");
  }
}

The specific problem is that it keeps going into the else part of the code, not detecting any objects. It just keeps going printing to the screen “Unable to detect object”. I have set up VEXRED in the vision sensor, so I’m not sure what’s causing this.

What does the vision dashboard show when your code is running ? It should see something like this (signature 1 is selected here)

image

If the dashboard does not show the object you are trying to detect, then tune the signature some more using the vision utility.

3 Likes