Keep getting this error: 'struct Block' has no member named 'type'

Hello, I'm pretty new with arduino I'm trying to replicate this project for the pixy camera and I'm trying to use this code exactly:

#include <SPI.h>
#include <Pixy.h>

Pixy pixy;

void setup()
{
Serial.begin(9600);
Serial.print("Starting...\n");
pixy.init();
}

void loop()
{
uint16_t type;
static int i = 0;
int j;
int16_t signature;
int16_t angle;
uint16_t blocks;
blocks = pixy.getBlocks();
if (blocks)
{
i++; //<<<<< ----- Delay each 50 Loops everi 50 loop go in
if (i % 50 == 0) //<<<<< ----- Delay each 50 Loops everi 50 loop go in
{
Serial.print("Detected :");
Serial.print(blocks);
Serial.print("\n");

for (j = 0; j < blocks; j++)
{

Serial.print("type =");
Serial.print(pixy.blocks[j].type);
Serial.print("\t");

Serial.print("Sign =");
signature = (pixy.blocks[j].signature);
Serial.print(signature,OCT);
Serial.print("\t");

Serial.print("Loc X =");
Serial.print(pixy.blocks[j].x);
Serial.print("\t");

Serial.print("Loc Y =");
Serial.print(pixy.blocks[j].y);
Serial.print("\t");

Serial.print("width =");
Serial.print(pixy.blocks[j].width);
Serial.print("\t");

Serial.print("Height =");
Serial.print(pixy.blocks[j].height);
Serial.print("\t");

Serial.print("angle =");
angle = (pixy.blocks[j].angle);
Serial.print(angle);
Serial.print("\t");

pixy.blocks[j].print(); //<<<----- This print all one Line
}
Serial.print("\n\n");
}
}
}

But I keep getting the error:

'struct Block' has no member named 'type'

And it always points to this line

Serial.print(pixy.blocks[j].type);

I'm not sure what I'm doing wrong, I made sure the arduino was working fine and the Pixy camera itself works fine and the servos are all working fine individually. And I didn't change anything when I copy and pasted the code. Any help would be appreciated please and thank you.

-Psaro

Where did you get the Pixy library? Maybe some other version has a different definition for the struct.

I downloaded their latest version here which is 0.1.7 but I think the guy in the video was also using this version though. This is also the library for pixy specifically and I didn't see it in there. I think the issue is that the actual ".type" function doesn't exist. I'm not 100% sure though since I'm really new with this and it might be a default in the arduinos library or the SPI library but I just want to be certain.

Open the file Pixy.h and look fir the definition of the object. It may be that the case or the spelling is wrong for your reference to blocks.type.

The documentation (http://www.cmucam.org/projects/cmucam5/wiki/Hooking_up_Pixy_to_a_Microcontroller_(like_an_Arduino)) shows that the block does not have a member named "type". Just remove the lines that refer to ".type".

I think the issue is that the actual ".type" function doesn't exist

The type member of the struct, if it existed, is NOT a function.

johnwasser:
The documentation (http://www.cmucam.org/projects/cmucam5/wiki/Hooking_up_Pixy_to_a_Microcontroller_(like_an_Arduino)) shows that the block does not have a member named "type". Just remove the lines that refer to ".type".

I did do that but I just get the error:

stray '\357' in program

and it directs me to the last "}" in the code but I made sure all the curly brackets have a pair so I'm not sure what it means.

GarethMoffatt:
Open the file Pixy.h and look fir the definition of the object. It may be that the case or the spelling is wrong for your reference to blocks.type.

And I found the file Pixy.h but it gives me this:

Pixy KEYWORD1
PixyI2C KEYWORD1
PixyUART KEYWORD1
PixySPI_SS KEYWORD1
Block KEYWORD1
getBlocks KEYWORD2
init KEYWORD2
print KEYWORD2
setServos KEYWORD2
setBrightness KEYWORD2
setLED KEYWORD2

But I don't see anything with the 'type' member.

PaulS:
The type member of the struct, if it existed, is NOT a function.

And sorry I'm still learning the terminology of this

I did do that but I just get the error:

If you just deleted code, there is no way that you would then get a complaint about a character that wasn't there before.

Post your code here, properly (read the stickies to find out how), then copy the code back, and the stray character will be gone.

The Block struct has the "type" field. So, maybe OP should grab the latest version?

PaulS:
If you just deleted code, there is no way that you would then get a complaint about a character that wasn't there before.

Post your code here, properly (read the stickies to find out how), then copy the code back, and the stray character will be gone.

Okay I'll try that, and sorry for posting it improperly I'm still figuring this out.

#include <SPI.h>
#include <Pixy.h>

Pixy pixy;

void setup()
{
  Serial.begin(9600);
  Serial.print("Starting...\n");
  pixy.init();
}

void loop()
{
  uint16_t type;
  static int i = 0;
  int j;
  int16_t signature;
  int16_t angle;
  uint16_t blocks;           
  blocks = pixy.getBlocks(); 
  if (blocks)                
  {
    i++;         //<<<<< ----- Delay each 50 Loops everi 50 loop go in
    if (i % 50 == 0) //<<<<< ----- Delay each 50 Loops everi 50 loop go in
    {
      Serial.print("Detected :");
      Serial.print(blocks);
      Serial.print("\n");

      for (j = 0; j < blocks; j++)
      {

        Serial.print("type =");
        Serial.print(pixy.blocks[j].type);
        Serial.print("\t");

        Serial.print("Sign =");
        signature = (pixy.blocks[j].signature);
        Serial.print(signature,OCT);
        Serial.print("\t");
        
        Serial.print("Loc X =");
        Serial.print(pixy.blocks[j].x);
        Serial.print("\t");
        
        Serial.print("Loc Y =");
        Serial.print(pixy.blocks[j].y);
        Serial.print("\t");
        
        Serial.print("width =");
        Serial.print(pixy.blocks[j].width);
        Serial.print("\t");
        
        Serial.print("Height =");
        Serial.print(pixy.blocks[j].height);
        Serial.print("\t");
        
        Serial.print("angle =");
        angle = (pixy.blocks[j].angle);
        Serial.print(angle);
        Serial.print("\t");
        
        pixy.blocks[j].print(); //<<<----- This print all one Line
      }
      Serial.print("\n\n");
    }
  }
}

Danois90:
The Block struct has the "type" field. So, maybe OP should grab the latest version?

pixy/src/host/libpixyusb/include/pixy.h at master · charmedlabs/pixy · GitHub

I deleted the old one and downloaded the library from the link you gave but I am still getting the error. Just to clarify I am doing by going from the arduino app Sketch -> Include Library -> Add .zip and then click I click the zip specified for arduino: arduino_pixy-0.1.7.

I deleted the old one and downloaded the library from the link you gave but I am still getting the error. Just to clarify I am doing by going from the arduino app Sketch -> Include Library -> Add .zip and then click I click the zip specified for arduino: arduino_pixy-0.1.7.

Post the pixy.h file you got that way.