Vision Sensor detection

How does the vision sensor send back to the code that it is sensing a object? I am trying to have the robot turn until it senses the object but don’t know how the sensor returns its information.

1 Like

It returns its information to the Brain via messages over its cable. As for how to access that information, check the documentation of your chosen programming API.

3 Likes

@Regomors , for coding in C++ within Vexcode Pro V5, I know this works:

     //Spin motors to turn
     leftback.spin(reverse);
     rightback.spin(forward);
     leftfront.spin(reverse);
     rightfront.spin(forward);
     //start detecting for desired colour that should already be configured in the sensor' config
     while (true) {
         visionSensor.takeSnapshot(visionSensor__BLUEGOAL); 
         if (visionSensor.largestObject.centerX > 145 && visionSensor.largestObject.centerX < 155) { //145 and 155 are values that worked for my robot, yours may change.
           break;
         }
         wait(.05, sec);
       }
     leftback.stop(hold);
     rightback.stop(hold);
     rightfront.stop(hold);
     leftfront.stop(hold);
1 Like

Hey @Bean, welcome to the forum, and thank you for posting your solution. However, it has been 2 years since the OP had this problem. In the future, try to reply to more current topics.

6 Likes

@DRow Close this thread?

3 Likes