This is an old revision of the document!
Computer Vision and Shooter Targeting
Color Based Shooter Speed Modulation Computer Vision Pipeline
Github
PrepareShot.java Shoot.java
For this game in particular, it is advantageous to be able to reliably shoot from variable distances. To accomplish this, we needed to figure out a reliable method of targeting the goal and choosing the right shooter speeds. When we saw that there were retro reflective tape strips that lined the goals, we immediately looked into using CV.
In 2020, we attempted to develop in-house CV solutions for ball detection. However, this exposed many issues in our design, development, and testing of this complex system. Learning from that experience, we decided to focus more on the application of CV rather than the development of it. We did some research on the different options that would cover our needs in this space and we eventually settled for PhotonVision with a SnakeEyes HAT. PhotonVision allowed for a rigorous set of options for us to tune our CV while providing easy code integration and a clean web interface. This allowed us to streamline the process of obtaining and installing the CV and shift the onus onto integrating the data that it provided and turning it into useful shooter information.
Our main use of CV was to detect the distance from the robot from the base of the goal and to calculate the angle offset between the robot and the center of the goal. We use the angle offset to align ourselves with the goal, through the use of PID, and we use the distance to determine how far we have to drive forward/backward in order to shoot the ball. We achieved this through the use of a shooter preset, which is a collection of flywheel RPMs that are known to work from specific distances. From this, we select the closest preset based on our current distance, drive to that preset distance, set our shooter RPMs to that of the selected preset, and then fire. Shooting in this manner allows us to always be in the right spot to shoot, thereby increasing reliability and consistency.
