How to sense for PROS_ERR

When I’m using the vision sensor PROS API (pros::vision_object_s_t rtn = vision_sensor.get_by_sig(0, 1);), the object returned doesn’t allow you to see if it exists or not.
The documentation says that if the object isn’t found, PROS_ERR will be returned. I tried doing if (rtn == PROS_ERR), but my IDE isn’t allowing me to do it.
Is that the correct way to check if the object isn’t found?

That appears correct. Your IDE “not allowing you to do it” is most likely linter issues. Try building your project and seeing if there are any errors. If you are using the PROS VSCode extension, we recommend installing the clangd extension as well to solve the linter errors.

1 Like

I am still getting an issue from the pros make command.
It keeps on returning the message that a pros::vision_object_s_t can’t be compared to a long int.

Error: Failed to build
src/main.cpp:42:11: error: no match for 'operator==' (operand types are 'pros::vision_object_s_t' {aka 'pros::vision_object'} and 'long int')

looks like documentation is wrong, I believe it will always return a vision_object_s_t but with the object signature set to VISION_OBJECT_ERR_SIG when there is no match. easiest way is to look at source code here.


Thank you, it worked!