Automated Ball Shooter

Inspiration

This was done for the 2020 FRC game Infinite Recharge, where part of the game involved shooting these yellow foam balls (called power cells) into the top of a tower to score points. We wanted to automate the process of lining up with the tower and scoring the power cells. Doing so would make us much efficient at scoring and thus much more competitive.

The ball shooting mechanism consisted of two moving parts: a flywheel, and a hood. The former would control the exit velocity of the ball, the latter controls the exit angle of the ball as it leaves the mechanism.

How it Works

It uses a Limelight to find the target (the reflective strip on the bottom half of the hexagonal hole) and determine how far away we are from it, and our orientation with respect to it. A Limelight is an all-in-one computer vision platform that runs the computer vision pipelines we used. The pipelines are the bit of software that take the raw images from the camera and processes them to extract the information about the target.

Once we know how far away the target is, and our orientation in relation to it, we automatically line up with the target, and configure the ball shooting mechanism such that the balls go straight through the goal in the tower. All of this is done in a fraction of a second, as opposed to spending multiple second manually lining up with it.

Challenges

The biggest challenges were the math behind all the calculations (to find our distance and orientation with respect to the target), and getting the Limelight's pipelines to properly pick up the target on the tower. It took a lot of trial and error, but in the end, I believe it worked flawlessly the entire competition season (never failing even once).

What I Learned

Learning the physics behind the ball shooting mechanism was very interesting, as we got to apply concepts such as projectile motion and the doppler effect, and even built a simulation for the ball shooter.

An interesting data structure I learned was interpolation tables. Basically, we calibrated our ball shooting mechanism from 4 feet, 5 feet, 6 feet, etc. all the way to 24 feet, and our table would store the configuration of the mechanism at each of those distances. If the robot was 5.5 feet away from the tower, the table would interpolate between the entries from 5 and 6 feet, which worked very well.

See the Code

Here is the bit of code that rotates the robot to face the goal, and here is the bit of code sets the flywheel and hood using the values from the interpolation table.