Vision Sensor "no matching function for call to "takeSnapshot" "

 /*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       {author}                                                  */
/*    Created:      {date}                                                    */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// Include the V5 Library
#include "vex.h"
  
// Allows for easier use of the VEX Library
using namespace vex;

vex::motor intakes[6] = { Motor14, Motor12, Motor9, Motor3, Motor2, Motor7 };
competition comp;
void StartIntakesF(){
    for (int i = 0; i < 6; i++){
        intakes[i].spin(forward);
    } 
}
void StartIntakesB(){
    for (int i = 0; i < 6; i++){
        intakes[i].spin(reverse);
    } 
}
void StopIntakes(){
    if (!Controller1.ButtonR1.pressing()&&!Controller1.ButtonL1.pressing()){
        for (int i = 0; i < 6; i++){
            intakes[i].stop();
        } 
    }
}
void driver(){
    Controller1.ButtonR1.pressed(StartIntakesF);
    Controller1.ButtonR1.released(StopIntakes);
    Controller1.ButtonL1.pressed(StartIntakesB);
    Controller1.ButtonL1.released(StopIntakes);
}
void auton(){
    while (true){
        Vision18.takeSnapshot("SIG_1");
            if (Vision18.largestObject.centerX>158){
                Drivetrain.turn(left);
            }else if (Vision18.largestObject.centerX<158){
                Drivetrain.turn(right);
            } else {
              Drivetrain.stop();
            }
        
    }
}
int main() {
    
    for (int i = 0; i < 6; i++){
        intakes[i].setVelocity(999, percent);
    }
    comp.autonomous(auton);
    comp.drivercontrol(driver);
    while (true){
        wait(0.5, seconds);
    }
}

I’m trying to do a basic ā€œfollow the ballā€ script but for some reason the compiler isn’t recognizing the takeSnapshot function, any help?

Did you get an error similar to this:
CXX src/main.cpp
src/main.cpp:31:3: error: use of undeclared identifier ā€˜Vision5’
Vision5.takeSnapshot(Vision5__BLUEBOX);
^

Which would indicate that the VisionSensor18 is not defined.

If it is another error, then please include it.

I am looking at VEXCode Pro V5 here to check.

1 Like

you can not pass a string to takeSnapshot.
it accepts either a signature id (ie. a number) or a signature reference or a color code reference.
see the API here.
https://api.vexcode.cloud/v5/html/classvex_1_1vision.html

some example code in this topic.

4 Likes

When i dont pass it as a string, it gives the same error + a new one that iirc was something along the lines of unexpected identifier.