First disclaimer; this thread is inspired by, and was requested in, the CheesyVision thread. We do not want to derail or hijack that thread, so here it is.
Second disclaimer; Our original inspiration for this code was provided by Spectrum 3847 and this White paper. As you look through the code, you will see a lot of their original code in there. We intentionally left all our lumps and warts in there so they can be utilized in the future, should the need arise.
The goal of this thread is to share ideas and approaches to different ways to do the task of object tracking. Please feel free to share code if you feel lead to do so. Don’t worry about sidetracking this thread, but try to keep it to object tracking and various methods of doing this that have worked for your team. Ask questions, propose alternatives.
The purpose of “DoubleVision” is to allow the DS to tell the robot which color ball to track. (It can be dynamic if you wish, allowing you to change mid match, but I have not seen a game yet where that would help.) The selection of the color to track is done by reading a switch on the DS, and setting a DIO pin on the robot to the corresponding state. That pin is connected to a GPIO pin on the PCDuino. (WARNING, GPIO pins on PCDuino’s are 3.3vdc. You will need a transistor or other method to convert the 5vdc of the DSC’s DIO pins to 3.3vdc.). You may want to modify your Robot code to use the FMS information to automatically set the color for you. We chose to do it manually with a switch to allow this to work while not connected to FMS.
This code has been configured to run on a PCDuino v.1 This should run just as well on PCDuino v.2. We used a USB Web Cam on the robot for image acquisition. As you look through the code, you will see that it would be easy to have this performed with a Network camera, such as the Axis cameras, instead. In fact, with just minor modification(s), both could work at the same time, for various purposes, and all image processing would be removed from the cRio.
In the attached zip file you will find three files. Their names explain their purpose.
Dual_colorTracking.py is the file that actually runs on the board during competition.
Dual_Cal_Targets.py is used to determine the upper and lower threshold, dilate, and approx values to edit into the Dual_colorTracking.py file.
Dual_colorTracking_DEMO.py This is the file that allowed us to demonstrate visually to the Judges what our code was doing. It was used on a Demo PCDuino setup in the pit with a monitor. With it you can see the tracking changing from a Red ball to a Blue ball with the flip of a switch. (This is part of how we won the Innovation in Control Award at both regional’s we attended.)
DoubleVision.zip (9.47 KB)
DoubleVision.zip (9.47 KB)