1. 3 weeks ago

    I am currently trying to use the V5 Vision sensor in PROS C++. I used the V5 Vision Utility on a windows computer to set the first signature to something I wanted to track, and then I tried running the following code:

    #include "main.h"
    #define VISION_PORT 1
    #define EXAMPLE_SIG 1
    
    void opcontrol() {
      pros::Vision vision_sensor (VISION_PORT);
      while (true) {
        pros::vision_object_s_t rtn = vision_sensor.get_by_sig(0,1);
        // Gets the largest object
        std::cout << "sig: " << rtn.signature;
        pros::delay(2);
      }
    }

    I assumed that 1 in the method call for get_by_sig corresponded to the first signature.
    When running the code, however, the only thing that I get in the terminal is sig: 255. This happens if the object corresponding to the signature is visible or not. Is there anything that I am missing?
    Thanks.

  2. edjubuh

    Dec 24 V5 Beta Moderator West Lafayette, IN

    255 is the value of the signature ID when there was an error. You can check errno to see a more descriptive reason.

    #include "main.h"
    #define VISION_PORT 1
    #define EXAMPLE_SIG 1
    
    void opcontrol() {
      pros::Vision vision_sensor (VISION_PORT);
      while (true) {
        pros::vision_object_s_t rtn = vision_sensor.get_by_sig(0,1);
        // Gets the largest object
        std::cout << "sig: " << rtn.signature;
        if (rtn.signature == 255) std::cout << " " << errno;
        pros::delay(2);
      }
    }

    I suspect you'll see 33, corresponding to EDOM which indicates that the vision sensor wasn't able to find an object with that size/signature combo. You could also see 22 for EINVAL or 117 for EHOSTDOWN (which means we couldn't communicate with the Vision Sensor for some reason).

  3. 2 weeks ago

    Thanks for letting me know! I did some more troubleshooting and figured out that the problem was with the vision sensor utility not properly saving signatures.

 

or Sign Up to reply!