Here is the image of the vision camera. So it should clearly see the purple (PU) block and return 166, 72.
Just an FYI, I have tried running it with both the Micro-USB Cable connected and disconnected. I realize that the vision system stops taking snapshots when you are on the live preview.
Here is the GEN2 Code just in case it changed.
// User defined function
void myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed(double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__x, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__y, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__h, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__w, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__heading, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__speed, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__newheading, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__newspeed);
int Brain_precision = 0, Console_precision = 0, Eye_objectIndex = 0;
float myVariable, objCount;
event purpleFoundMsg = event();
event orFoundMessage = event();
event message1 = event();
// User defined function
void myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed(double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__x, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__y, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__h, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__w, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__heading, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__speed, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__newheading, double myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__newspeed) {
Brain_precision = 0;
Brain.Screen.print("At ");
Brain.Screen.print(printToBrain_numberFormat(), static_cast<float>(myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__x));
Brain.Screen.print(" , ");
Brain.Screen.print(printToBrain_numberFormat(), static_cast<float>(myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed__y));
Brain.Screen.newLine();
}
// "when started" hat block
int whenStarted1() {
Brain.Screen.clearScreen();
Brain.Screen.setCursor(1, 1);
Brain.Screen.print("Hello World!");
Brain.Screen.newLine();
return 0;
}
// "when started" hat block
int whenStarted2() {
while (true) {
Eye.takeSnapshot(Eye__PU);
Brain.Screen.clearLine(2);
Brain.Screen.clearLine(3);
Brain.Screen.clearLine(4);
Brain.Screen.clearLine(5);
if (Eye.objectCount > 0) {
orFoundMessage.broadcastAndWait();
}
else {
Brain.Screen.setCursor(2, 1);
Brain.Screen.print("Who took my block\?");
Brain.Screen.newLine();
wait(1.0, seconds);
}
wait(20, msec);
}
return 0;
}
// "when I receive orFoundMessage" hat block
void onevent_orFoundMessage_0() {
Brain.Screen.setCursor(2, 1);
Brain.Screen.print("I found ");
Brain.Screen.print(printToBrain_numberFormat(), static_cast<float>(Eye.objectCount));
Brain.Screen.print("block(s).");
Brain.Screen.newLine();
myVariable = 1.0;
repeat(Eye.objectCount) {
Eye_objectIndex = static_cast<int>(myVariable) - 1;
myVariable = myVariable + 1.0;
myblockfunction_foundVision_x_y_h_w_heading_speed_newheading_newspeed(Eye.objects[Eye_objectIndex].centerX, Eye.objects[Eye_objectIndex].centerY, Eye.objects[Eye_objectIndex].width, Eye.objects[Eye_objectIndex].height, 1.0, 1.0, 1.0, 1.0);
wait(20, msec);
}
wait(1.0, seconds);
}
int main() {
// register event handlers
orFoundMessage(onevent_orFoundMessage_0);
wait(15, msec);
vex::task ws1(whenStarted2);
whenStarted1();
}