Hey. Last year we programmed the robot entirely in C++, but the guy who was assigned to write the camera code could never get it to work. Looking at it, it makes sense. I don’t see why it wouldn’t work. However, all that ever happened was the camera would seem to track a pair of colors but then swivel to look at random objects, or the ceiling. I’d post our code but it’s really a huge mess, and I think it’s kind of embarrassing. (Note: this past year I was delegated to electronics and the programming was left to other people :P)
We also had immense problems getting the WPI-provided camera example (TwoColorDemo, I think it was called?) working. For a while it simply wouldn’t compile. Then they released a version that did compile but as I remember it exhibited the same behavior as our code. Actually, I’m willing to bet that the camera guy based his code off of TwoColorDemo.
Anyway, perhaps it would help us for next year if someone could post their (working) C++ camera functions. Even if we don’t end up using the camera next year, we’d like to test if we’ve got something wonky with our camera or even the cRIO.
Thanks!
It is very unlikely that something is wrong with your cRIO that allows everything else to work, but the camera only sorta works.
There are plenty of camera settings that could cause the code to be wonky. I’d highly recommend connecting the camera directly to a PC and running NI Vision Assistant. If you set the PC IP to 192.168.1.xx other than 90, it will let you use the camera to get a feel for the focus, color, contrast, etc. It will let you view the settings your camera is using or change them. Once you know that your camera is working as you expect, it may also be useful to isolate your code to make a camera and gimbal only project. Work on this in isolation from the rest of the robot and see if you can debug its behavior.
Once that works well enough, you can hopefully reintegrate it with the robot – without making the code a mess.
Greg McKaskle
Heh. I remember us doing all sorts of fancy (and not-so-fancy) diagnostic stuff with the camera. We did run NI Vision Assistant and recalibrated our color target profile thing a number of times.
I’ve just recently been playing around with the camera and got it to work wonderfully. Took one look at the TwoColorTracking demo and found it too complicated, so I modeled my own based on it.
If your camera is looking at random things, make sure your tracking thresholds are right…I’ve tried unsuccessfully to get the robot to track different color combinations…
You know I’ve finally taken a good look at our camera routines and it’s a freaking mess… Not to bad-mouth the team alumnus that wrote it but I wouldn’t be surprised if our code is just broken. If I can seem to un-screw it I’ll probably post back. I think at the next opportunity we’ll try calibrating the camera again.
Heh… We also coded the robot in C++ last year. The camera was quite the adventure. For the majority of the season no matter what programming approach I tried the thing didn’t work. Then during our second competition I found out that the metal mounting bracket for the camera had been holding the reset button down the entire season, forcing a power cycle on the camera every 15 seconds. I nearly cried.
Even once that was taken care of, the exposure rate and contrast constantly had to be tweaked. Only in the end by using the sample code provided by WPI did we get half-decent results.
The moral I took from this story is that while the camera can be used wonderfully during autonomous and to assist the drivers, your robot should not be built around a strategy that heavily depends on the camera (last year we had a robot with a movable turret that was supposed to use camera-assisted aiming). Use the camera instead to augment your strategy.
I will say, though, I’m extremely excited to be allowed enough network bandwidth this season to send entire camera frames to the dashboard. A live view from the eyes of the robot will do wonders for drivers. I’m currently working on a custom dahsboard project focusing on customization and extremely quick and easy configuration; expect a post later in the season once I have something cool to show you guys.