Hi, James from 2977 here.
I was wondering if anyone would be willing to share some knowledge of PixyCam with us? We just got one and are wondering how to implement it with Java, and as well how to connect it to the roboRIO. If anyone knows anything, help would be appreciated!
:deadhorse:
There are many ways to connect the Pixy camera to RoboRIO: SPI, I2C, Serial, Analog etc. How to implement code to work with Pixy depends on how you connect the camera. The easiest way is to connect it via Analog if you only want to get an idea on whether your one target is on your left or right. If you want info on multiple targets, you may have to go with any of the digital serial interface. That may require you to write a “driver” to communicate with it.
I’ve never used it, but you may want to check this out.
Ok so, I found some code (I used the post by user “2B || !2B”), but I have no idea how to make this show in the SmartDahsboard. Our team is planning to aim with camera tracking on the reflective tape, and I would like to know how I import/use the signature I want from the camera, and how I could put this into the SmartDahsboard.
For testing we just dumped all the signatures to smart dashboard. See
https://github.com/BHSRobotix/Steamworks2017/blob/master/src/org/usfirst/frc2876/Steamworks2017/subsystems/Vision.java#L55
We just called textPixy from teleopPeriodic.
You can find what other teams are doing with pixy by searching on github, for example: https://github.com/search?utf8=%E2%9C%93&q=frc+pixy&type=Code&ref=searchresults
Are you guys just using the Pixy(s) with an LED ring? How do you have the Pixy itself configured to see the electric tape?
Yes, we (2876) are using a green LED ring to see the reflective tape. We are currently trying to work out seeing (and then averaging) both sides of the peg. I think we’re good with the boiler tape.
To add to what Rick said… we are using pixymon to help configure the pixy settings. We set brightness to something low(40?), so that only the reflective tape tends to show up. Then while laptop with pixymon is connected to pixy we press the button on pixy to enter training mode. Move the pixy or target to be centered in front of camera lens. Pixy sees the reflective tape. Press button on pixy again and done. Using the laptop w/ pixymon makes it easier to determine if pixy is detecting the tape.
Couple of key things we messed up on… make sure the tape is centered in front of lens when teaching. Pixy needs to have the thing it is learning about centered. The color of the led in teach mode DOES NOT correspond to hue of object you are seeing. Both these things and the steps to teach pixy we are using are covered here: http://www.cmucam.org/projects/cmucam5/wiki/Teach_Pixy_an_object_2
FWIW - I ported the I2C java code to SPI java and SPI C++. I’ve changed the behavior of the object and how it’s called, it’s functional and works well over SPI at 1Mbit. Slave select is not working currently, not sure if it’s an issue with WPILib SPI, roborio or Pixy itself. Will investigate more after season is over. Also scheduled for the off season is adding pixy config from robot code and if possible adding visualizer for the smartdashboard.
I don’t monitor Chief Delphi, so please use email or GitHub if you have any questions.
Has anyone seen any Pixy RoboRIO libraries (in Java) that can connect over USB? I know SPI and I2C work but a mini-b usb cable seems much more reliable as an off-the-shelf non-custom cable.
I’ve actually been working on porting libpixyusb to the RoboRIO. For ease of development I’ve just been using JNA for the native bindings, but I’ll probably write proper JNI bindings once I finish up the library. The results using the Java bindings look something like this for a single Pixy (also, if anyone has suggestions for making a custom UI component for SmartDashboard, or at least grouping things better, I’d love to know):
Screenshot
So far I’ve successfully tested it with streaming from three Pixy cams simultaneously, but there are still a few bugs that I need to iron out before releasing it. USB is definitely much more pleasant to work with than I2C though.
That looks super cool…I’m glad somebody also is interested in using the Pixy usb connection. I wouldn’t however recommend making a final smart dashboard widget as shuffleboard is in active development and I think is gonna be released for 2018 [it has its own API for widgets though that could be used]
Sent from my iPhone using Tapatalk
Out of curiosity, how did you get two Pixy cams in one I2C port?
I2C is a bus. You can connect multiple devices to it. The four wires are Vcc, GND, SDA and SCL. As long as each device has its own unique I2C address, you can connect them parallel to each other.