Go to Post Many people read ChiefDelphi, not just members of FRC teams. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #31   Spotlight this post!  
Unread 08-11-2016, 21:04
Alsch Alsch is offline
Registered User
no team
 
Join Date: Oct 2014
Location: Underneath Canada
Posts: 5
Alsch is an unknown quantity at this point
Re: Reliability of Pixy Camera?

Quote:
Originally Posted by Bpk9p4 View Post
do you know the updated rate for the OpenMC 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>
Reply With Quote
  #32   Spotlight this post!  
Unread 09-11-2016, 08:44
Xanawatt Xanawatt is offline
Registered User
FRC #1024
 
Join Date: May 2015
Location: Indianapolis, Indiana
Posts: 22
Xanawatt is an unknown quantity at this point
Re: Reliability of Pixy Camera?

Quote:
Originally Posted by Bpk9p4 View Post
that would be great. Are you just getting the largest value or how do you have it working?
Here is the code:
In robotMap:
Code:
public static I2C pixyi2c;
pixyi2c = new I2C(Port.kOnboard, 0x54);
In Main:
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]);
	}
}
As for your question, we have it just detecting the largest value. There might be a way to access the other data(It might just be as simple as finding the right memory address), but we did not investigate that further. I will be happy to further explain this code(as it is a little complex), but even I forget and would have to look at it a lot. But, if you want info, then I would gladly do it! Also, so people don´t get mad at me, if you use it, give us credit.
Reply With Quote
  #33   Spotlight this post!  
Unread 09-11-2016, 09:42
Bpk9p4's Avatar
Bpk9p4 Bpk9p4 is offline
Registered User
FRC #1756
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Illinios
Posts: 271
Bpk9p4 is on a distinguished road
Re: Reliability of Pixy Camera?

Quote:
Originally Posted by Xanawatt View Post
Here is the code:
In robotMap:
Code:
public static I2C pixyi2c;
pixyi2c = new I2C(Port.kOnboard, 0x54);
In Main:
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]);
	}
}
As for your question, we have it just detecting the largest value. There might be a way to access the other data(It might just be as simple as finding the right memory address), but we did not investigate that further. I will be happy to further explain this code(as it is a little complex), but even I forget and would have to look at it a lot. But, if you want info, then I would gladly do it! Also, so people don´t get mad at me, if you use it, give us credit.
so it looks like you just read from address x54 and there is no writing? Also what is the point of

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?
__________________
2015 Midwest Regional Finalist
2015 Central Illinois Regional Winner
2015 Newton Division Finalist
2015 Newton Quality Award
Reply With Quote
  #34   Spotlight this post!  
Unread 09-11-2016, 13:39
Xanawatt Xanawatt is offline
Registered User
FRC #1024
 
Join Date: May 2015
Location: Indianapolis, Indiana
Posts: 22
Xanawatt is an unknown quantity at this point
Re: Reliability of Pixy Camera?

Quote:
Originally Posted by Bpk9p4 View Post
so it looks like you just read from address x54 and there is no writing? Also what is the point of

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?
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.
Reply With Quote
  #35   Spotlight this post!  
Unread 09-11-2016, 15:07
Xanawatt Xanawatt is offline
Registered User
FRC #1024
 
Join Date: May 2015
Location: Indianapolis, Indiana
Posts: 22
Xanawatt is an unknown quantity at this point
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));
	}
Hope this helps
Reply With Quote
  #36   Spotlight this post!  
Unread 10-11-2016, 11:06
Bpk9p4's Avatar
Bpk9p4 Bpk9p4 is offline
Registered User
FRC #1756
Team Role: Mentor
 
Join Date: Jan 2013
Rookie Year: 2010
Location: Illinios
Posts: 271
Bpk9p4 is on a distinguished road
Re: Reliability of Pixy Camera?

Quote:
Originally Posted by Xanawatt View Post
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));
	}
Hope this helps
thanks for posting this. I will see if i can get it to work with Labview.

Did you have the pixy in Lego mode or just I2C mode?
__________________
2015 Midwest Regional Finalist
2015 Central Illinois Regional Winner
2015 Newton Division Finalist
2015 Newton Quality Award
Reply With Quote
  #37   Spotlight this post!  
Unread 10-11-2016, 15:15
Xanawatt Xanawatt is offline
Registered User
FRC #1024
 
Join Date: May 2015
Location: Indianapolis, Indiana
Posts: 22
Xanawatt is an unknown quantity at this point
Re: Reliability of Pixy Camera?

Quote:
Originally Posted by Bpk9p4 View Post
thanks for posting this. I will see if i can get it to work with Labview.

Did you have the pixy in Lego mode or just I2C mode?
We had a regular pixy communicating through I2C.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi