I know there is code for the pixy camera, but I was wondering if you have to write code in order for the robot to receive any data from the pixy camera.
The short answer is yes, but the first thing you need to determine is which of the possible interfaces you intend to use. Pixy can connect to the roboRIO in multiple ways:
Analog / Digital X
Analog / Digital Y
I2C
SPI
UART
We are connecting to SPI
SPI devices aren’t allowed to send data until the bus master (in this case the roboRIO) asks for it. I’m sure there are others here who can provide greater detail than I can.
For the Pixy2, yes: All serial interfaces require the host device to initiate a data request, and then the Pixy2 will reply with a response. This is in contrast with the Pixy1, which can be configured to “stream” data without an initial request.
The general approach most teams have used for engaging with a Pixy is as follows:
- Wire the Pixy to an Arduino
- Use the Arduino Pixy library to handle incoming and outgoing responses
- Stream/send simplified data requests to the Rio (typically using UART)
We used a pixy last year, and I’d recommend that approach. It’s simple, robust, and can be done with relatively ease thanks to Pixy-supplied libraries.
Handling the Pixy2 stream directly into the Rio in Java is a bit more complicated, and probably more work than most teams want to tackle given the simplicity of the sensor itself. We did this last year to use the Pixy for line following.
The limitation is that we never fully developed or tested the Block response and parsing, since we were using the Pixy2 only for the line detection. That means there’s still some development to do if you want a java-only solution for this year’s goal or energy cell detection, but it should serve as a starting point or reference for anyone attempting this.
Our team used this library last year to implement line follow with the pixy2.
Do you put the responses on the camera first using Arduino, before hooking it up to the rio?
I’ll prefix this by recommending you try the library linked by RandomString first. That looks pretty solid and robust, and it appears they actually completed the port for Blocks/Main Features (which we did not). If that gets you communicating with the Pixy, then you’re done. I wasn’t aware of another such library or I’d have mentioned it earlier.
Ultimately, your goal here is “what’s the easy way to get data out of the pixy.” If a native Java library does this without adding additional electronics, that’s a huge win for overall system complexity.
To answer the question though,
Do you put the responses on the camera first using Arduino, before hooking it up to the rio?
Yes, this would be the case. With this setup The Arduino would be doing 3 different tasks:
- Using the Pixy Arduino library to communicate with the Pixy
- Parsing out any appropriate data, and converting to a simplified format
- Sending that simplified data to the Rio
You still have to ultimately run some sort of interface on the Rio, and write some sort of Java code to handle the incoming data.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.