I’m running the hello_pixy.cpp example program in visual studio 2012 64bit. From looking at the code, I would expect the program to continuously pull frames from Pixy and for each frame, print out any detected objects (blocks). For some reason, the code is only able to get one frame. From what I can tell, the program gets the first frame, prints it, and then when it loops back around, pixy_block_are_new() never returns true. I don’t believe this is an issue with that function. For some reason I’m not getting new frames from Pixy.
I’ve made a bit of progress…
Pixy is now streaming block data out to me, though I’m really not happy about the solution. I put hello_pixy.cpp into the debugger to try and see what was going on in the pixy_blocks_are_new() function. This was not very fruitful, it just told me that Pixy is returning false for new data. My next thought was that maybe Pixy was disconnecting for some reason after grabbing the first frame. To test this, I added more or less the following code to the pixy_blocks_are_new() while loop:
while(!pixy_blocks_are_new() && run_flag) {
uint16_t major;
uint16_t minor;
uint16_t build;
int return_value;
return_value = pixy_get_firmware_version(&major, &minor, &build);
}
After checking the firmware, I would print the return to screen. I figured this would be a good way to make sure I’m still talking to Pixy. For some reason, this fixed my issue. With this code in place I’m getting new frames. My next thought was that maybe the while loop is being called too quickly, and this code is introducing a small delay. I removed the code above and put in a 50ms sleep, 100ms sleep , and even 1 second sleep. This did not resolve the issue…so it doesn’t seem like I’m calling Pixy too often; however, the code requires this line to run properly. What is going on?
Hello Austin,
I would make sure that the worker thread in libpixyusb is running. This thread is constantly reading data from Pixy and putting it into the blocks data structure.
It’s in pixyinterpreter.cpp
PixyInterpreter::interpreter_thread()
(make sure receiver_->service(false) is being called repeatedly.) If the thread isn’t running it sounds like something is not right with the boost library.
Edward