Hi there
For my bachelor thesis, I’m creating an air hockey robot, with ESP32 and Pixy2 cam. Because the speed of the puck can be quite high in some cases, high framerate is an absolute necessity. With the pixymon app, it says the Pixy2 has about 60 FPS. However, when in Arduino IDE, I’ve tried seeing how much recordings the pixy2 will make of an object in tracks, I’ve found that it sends only about 34 recordings (I’ll attach the code I used for this). Is there something I’m doing wrong? Or is this because of Arduino IDE? Or maybe something to do with the Baud rate? How can I be sure I’m actually getting 60 recorded positions of the puck every second, and thus be able to track the puck and predict it’s next move?
(FYI : I’ve assigned Signature 1 to a red puck and have kept the red puck in front of the pixy2 to track from the moment the program starts running.)
Kind regards,
LT
Code :
#include <Pixy2SPI_SS.h>
Pixy2SPI_SS pixy;
//------------------------
int counter = 0;
void setup()
{
Serial.begin(9600);
Serial.print(“Starting…\n”);
pixy.init();
}
void loop()
{
pixy.ccc.getBlocks();
if (pixy.ccc.numBlocks)
{
if (pixy.ccc.numBlocks == 1)
{
while(millis()<1000)
{
Serial.println(" Puck detected");
Serial.print("X : “);
Serial.print(pixy.ccc.blocks[0].m_x);
Serial.print(” Y : ");
Serial.print(pixy.ccc.blocks[0].m_y);
counter++;
}
}
}
Serial.print(“There were “);
Serial.print(counter);
Serial.print(” recordings.”);
}