Go to Post How we respect the rules of the game is a reflection of our character and integrity - win, lose, or draw - 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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #17   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: 17
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
 


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 13:18.

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