|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
Quote:
|
|
#2
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
We used the Pixy camera from week 5 on in Stronghold. It was the key to our autonomous high shot and a major contributor to our 9-11 high goal matches. The interface we chose to use was the simplest one (digital/analog X). I found it to be a bit touchy to set up, but once calibrated to the lighting in each venue it worked well.
We did change the lens from the stock one (75 degree horizontal field of view) to I think 51 degrees field of view. Last edited by electroken : 24-10-2016 at 14:46. |
|
#3
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
I could be wrong about using it on the FRC robot. Sounds like lots of people have had good luck with it
Has anyone seen the problem where if the board browns out you loss your config . Maybe there is just something wrong with my board |
|
#4
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
Quote:
-not a programmer. ![]() |
|
#5
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
After seeing how much great results people have had i started looking into the i2c communication. Any chance anyone has written the i2c communication for Labview?
|
|
#6
|
|||
|
|||
|
Re: Reliability of Pixy Camera?
To teams that got the Pixy to work. Where did you shoot from? Did you shoot from the defenses? Did you have to be centered and perpendicular to the target? What did you do about getting 2 targets when positioned to the side and 2 targets were in view?
|
|
#7
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
Quote:
The 2 target problem turned out to be no problem at all. Using the digital/analog X interface the Pixy gave the X position for only the largest target it saw. In every case that target was the goal most perpendicular to our catapult, and therefore the goal we wanted to be aiming at. For clarification, we used the two signals from the Pixy as follows: The digital output told the robot when the Pixy saw what we taught it to look for anywhere within its visual field. At that point the robot removed the yaw authority from our driver and aimed itself. A large indicator on the driver station told our operator when the robot was aligned and ready to shoot. At that same time full drive authority was returned to our driver, just in case we needed to relocate due to being defended. |
|
#8
|
|||
|
|||
|
Re: Reliability of Pixy Camera?
Mittens (1296) shot from most places, the best/favorite places were along the defenses in positions 3 and 4 for the safe shot, about 10ft past the low bar(when cycling) or between the batter and the defenses in front of the center goal. The driver was trained to know where the pixy would get confused (seeing two goals) and he would avoid those areas.
|
|
#9
|
|||
|
|||
|
Re: Reliability of Pixy Camera?
I have it working for java, and would be glad to share. It might be along the same lines as labview?(maybe)
|
|
#10
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
that would be great. Are you just getting the largest value or how do you have it working?
|
|
#11
|
|||
|
|||
|
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]);
}
}
![]() |
|
#12
|
||||
|
||||
|
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? |
|
#13
|
|||
|
|||
|
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.
|
|
#14
|
|||
|
|||
|
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));
}
![]() |
|
#15
|
||||
|
||||
|
Re: Reliability of Pixy Camera?
Quote:
Did you have the pixy in Lego mode or just I2C mode? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|