|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#31
|
|||
|
|||
|
Re: Reliability of Pixy Camera?
If you mean the price, it's $75. If you are referring to like, framerate or baud or something then I'm pretty sure that they're configurable to whatever
<complaining>Tangentially, I myself purchased my own unit through the Kickstarter campaign, so it was at a discounted price of ~$60. They then tell us that they encountered production issues and had to spend the shipping fees they had charged on the problem, so we all needed to spend an extra $12 to get our already-bought boards actually sent to us, ultimately eliminating the discount we received for backing the campaign.</complaining> |
|
#32
|
|||
|
|||
|
Re: Reliability of Pixy Camera?
Quote:
In robotMap: Code:
public static I2C pixyi2c; pixyi2c = new I2C(Port.kOnboard, 0x54); Code:
public static void printPixyStuff(){
byte[] pixyValues = new byte[64];
pixyValues[0] = (byte) 0b01010101;
pixyValues[1] = (byte) 0b10101010;
RobotMap.pixyi2c.readOnly(pixyValues, 64);
if (pixyValues != null) {
int i = 0;
while (!(pixyValues[i] == 85 && pixyValues[i + 1] == -86) && i < 50) {
i++;
}
i++;
if (i > 50)
i = 49;
while (!(pixyValues[i] == 85 && pixyValues[i + 1] == -86) && i < 50) {
i++;
}
char xPosition = (char) (((pixyValues[i + 7] & 0xff) << 8) | (pixyValues[i + 6] & 0xff));
char yPosition = (char) ((pixyValues[i + 9] & 0xff << 8) | pixyValues[i + 8] & 0xff);
char width = (char) ((pixyValues[i + 11] & 0xff << 8) | pixyValues[i + 10] & 0xff);
char height = (char) ((pixyValues[i + 13] & 0xff << 8) | pixyValues[i + 12] & 0xff);
SmartDashboard.putNumber("xPosition", xPosition);
SmartDashboard.putNumber("yPosition", yPosition);
SmartDashboard.putNumber("width", width);
SmartDashboard.putNumber("height", height);
SmartDashboard.putNumber("Raw 5", pixyValues[5]);
}
}
![]() |
|
#33
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
Quote:
pixyValues[0] = (byte) 0b01010101; pixyValues[1] = (byte) 0b10101010; and is there some reason why if you counter goes above 50 you change what you do? |
|
#34
|
|||
|
|||
|
Re: Reliability of Pixy Camera?
So, i might be wrong, but I think that when it goes over 50, it is doing the same thing? That can't be right, but I will ask someone else about it. The two bytes at the begging I think are to align the data so the data is always in the same spot in the array. There is no writing because we just want what the Pixy sees. Pixymon, a separate program, configures and saves all the setting that you want on the Pixy, so there is no need for writing.
|
|
#35
|
|||
|
|||
|
Re: Reliability of Pixy Camera?
So, this is what I was told about the two loops.
"check if the index is getting so high that you can’t align and see an entire frame." I think this is that it takes too long to parse all the data so we split it up? Looking back at documentation, this is how the code should look. Now with comments! Code:
// set the number of bytes to get from the pixycam each read cycle. The pixycam outputs 14 byte blocks
// of data with an extra 2 bytes between frames per Object Block Format Figure
int maxBytes=64;
// declare the object data variables
int xPosition = 0;
int yPosition = 0;
int width = 0;
int height = 0;
// declare a byte array to store the data from the camera
byte[] pixyValues = new byte[maxBytes];
// the remainder of this snippet should be placed in a loop where the data is also used.
// a while loop is suggested where the loop exits when the target is identified or a break button is
// depressed on the OI
boolean target = false;
boolean oiExit = false;
while (!target && !oiExit){
// read the array of data from the camera
RobotMap.pixyi2c.readOnly(pixyValues, 64);
// check for a null array and don’t try to parse bad data
if (pixyValues != null) {
int i = 0;
// parse the data to move the index pointer (i) to the start of a frame
// i is incremented until the first two bytes (i and i+1) match the sync bytes (0x55 and 0xaa)
// Note: In Java, the and operation with 0xff is key to matching the 0xaa because the byte array is
// automatically filled by Java with leading 1s that make the number -86
while (!((pixyValues[i] & 0xff) == 0x55) && (pixyValues[i + 1] & 0xff) == 0xaa) && i < 50) { i++; }
i++;
// check if the index is getting so high that you can’t align and see an entire frame. Ensure it isn’t
if (i > 50) i = 49;
// parse away the second set of sync bytes
while (!((pixyValues[i] & 0xff) == 0x55) && (pixyValues[i + 1] & 0xff) == 0xaa) && i < 50) { i++; }
// build the target data from the framed data
xPosition = (char) (((pixyValues[i + 7] & 0xff) << 8) | (pixyValues[i + 6] & 0xff));
yPosition = (char) (((pixyValues[i + 9] & 0xff) << 8) | (pixyValues[i + 8] & 0xff));
width = (char) (((pixyValues[i + 11] & 0xff) << 8) | (pixyValues[i + 10 & 0xff));
height = (char) (((pixyValues[i + 13] & 0xff) << 8) | (pixyValues[i + 12] & 0xff));
}
![]() |
|
#36
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
Quote:
Did you have the pixy in Lego mode or just I2C mode? |
|
#37
|
|||
|
|||
|
Re: Reliability of Pixy Camera?
We had a regular pixy communicating through I2C.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|