My team is trying to use vision sensors to detect blue balls for testing. Unfortunately our robot just stops moving when it is close to the robot. Our vision sensor points down and stops driving forward when the ball is in the center of the image. Here is our code. Our vision sensor detects it when we use the in vision sensor configure but it doesn’t in code.
while(x == 1) {
LeftIntake.spin(reverse);
RightIntake.spin(reverse);
i = 0;
Controller1.Screen.clearScreen();
Controller1.Screen.newLine();
Vision5.takeSnapshot(Vision5__BLUEBOX);
if(Vision5.objects[0].exists){
while(i <= Vision5.objectCount && found == false){
if(Vision5.objects[i].width > 30 || Vision5.objects[i].height > 30){
found = true;
Controller1.Screen.print("found");
if(Vision5.objects[i].centerX < 140){
Drivetrain.setDriveVelocity(10, percent);
Drivetrain.turn(left);
}
else if(Vision5.objects[i].centerX > 160){
Drivetrain.setDriveVelocity(10, percent);
Drivetrain.turn(right);
}
if(Vision5.objects[i].centerX > 100 && Vision5.objects[i].centerX < 200) {
Drivetrain.setDriveVelocity(20, percent);
Drivetrain.drive(forward);
}
}
else{
Drivetrain.stop();
}
Controller1.Screen.newLine();
Controller1.Screen.print(i);
i += 1;
}
}
else{
Drivetrain.stop();
}
LeftIntake.stop();
RightIntake.stop();
if(BumperA.pressing()){
x = 3;
Controller1.Screen.clearScreen();
Controller1.Screen.newLine();
Controller1.Screen.print("nextThing");
}
found = false;
}