Our Computer Vision Targeting System

This year is the first year we used a targeting system for our robot. It is designed to target the gear lift. We chose to use an offboard computer vision co-processor. We used the Raspberry Pi 3. 
 
Our first challenge was keeping it powered. It wants a steady 5 volts at 2.5 amps, and the VRM delivers only 2 amps at 5 volts. Our Pi was sad and would not stay on. So we implemented a custom circuit off the PDP with a 3-amp breaker. Then our Pi was happy. 
 
Next we needed to network the Pi with the RoboRIO. We added a 5-port Ethernet switch, giving us ports for the radio, the RoboRIO, the Pi, our driver station, and a programmer’s laptop during competitions. The Ethernet switch is happy with VRM power! 
 
For identifying the target, we chose the Python language on the Raspberry Pi. Python offered the best support for the OpenCV libraries that offer the best vision recognition tools. We learned Python and OpenCV during our fall workshops so we would be prepared. Our Python CV code identifies the two largest green-hued contours in the camera image. We check to be sure the two contours are about equal in size and that their centers share similar Y-axis values. These safeguards help us avoid false positives, and we consistently match only the gear lift reflective patches. To illuminate the patches, we use a green-tinted LED flood lamp as a targeting light. Our targeting light is on a relay so that it doesn’t distract other teams. It only lights when our robot wants target data. 
 
Our next quest was how to get targeting information from the Pi to the RoboRIO. Instead of the typical NetworkTables approach, we opted for a more modern solution.
We chose MQTT (Message Queue Telemetry Transport) as our protocol for sharing targeting data. MQTT is a very popular protocol in the emerging Internet of Things (IoT) discipline. It takes very few resources, and is simple to work with. We have found that it is more reliable and flexible than NetworkTables. We installed the Open Source Moquette MQTT broker on the RoboRIO. That makes the RoboRIO the hub for our MQTT network. The Moquette broker listens on port 5888 in the range permitted for team use by FRC competition fields. It starts when the RoboRIO starts. We added the open source Paho Java MQTT client to our robot Java code and our Python code. We also are able to run MQTT clients on our Driver Station and all our programmer laptops (even Mac!), so we can monitor the MQTT targeting data. 
 
We have plans to build out an entire MQTT-based monitoring and control dashboard during the off season. 
 
Thanks to Team 1261, the RoboLions here in Georgia and Team 5495, The Aluminati from California.