One thing I’d like to clarify before I begin, I am aware that there are a few posts that ask a similar question to what I’m asking. What I’ve gathered from those posts is that you need to create a lookup table with distance/speed then use linear interpolation to actually have your shooter speed change based off distance.

This is great and all but what I’m confused on is how exactly would I implement that in my code? How do I put a lookup table in code? How do I use interpolation in a command? What I’m basically looking for is some examples of these implementations. Anything would be appreciated

Here is what I would do, but warning I’ve never actually done it myself before.

The previous posts (which you could have just replied to) said used a linear interpolation. So with the robot built and ready to implement, record the data of the limelight of the height of the target. Then shoot balls into the goal and keep changing the speed of the shooter until it is consistent. Then put both data points into an excel table where the input column would be the height of the target from the Limelight and the shooter speed is the output column. Repeat these steps until you have at least 5 rows. Then plot the data points in a scatter plot and add a linear interpolation with excel plotting the equation on the graph. That equation can then be used to take in the height of the goal and will output the speed at which the ball should be shot at. Where the x is the input and y is the output.

I can get to work on the excel graph right now, just one question; how come you use the height of the goal for the x axis? Like wouldn’t it stay the same? I was thinking that the x axis would be the distance from the limelight to the goal

Typically when calculating the distance to the goal you use the height of the goal in the image to covert it from y pixels to distance. So you can either use the calculated distance or directly the y pixel height.

I have an estimate method that uses the d = (h2-h1) / tan(a1+a2) equation showed in the case study. I confirmed that the distance it returns is in fact how far the limelight is from the reflective tape on the top hub.

When you guys shoot using this method do you find the balls shot to be consistent? To be a bit more specific I have this problem where when I shoot 2 balls back to back the second one will lag behind. Whether this is natural or because the first ball slightly slows the shooter down I do not know. I’d be grateful if you could let me know how it works out for you guys

That problem has more to do with inertia than the targeting. The first ball going through slows down the wheels and you are feeding the second ball through before the wheels are up to speed. A well tuned feed forward and PD will help you recover faster. We also have code to make sure the motor is at the set speed within a tolerance before it feeds the ball and the next ball

I see, I think I understand how to bring the table over into the code now.

I figured it would have something to do with pid, but thank you for confirming

One other thing, if I have an secondary shooter motor used to decrease backspin do I also have to make a seperate chart and write seperate code to change its speed?

We used our second motor as a % of the first motor but 2 different tables will work better for allowing angle control. you can dig around our repo. What I posted wasn’t the full targeting code as our BaseTurnToTarget aimed our drivetrain and spun she shooter up. we do at speed checks before firing.

Because you will probably want to spin the two motors at a different speeds you’ll need different tables. In our code we have a shooter speeds (the flywheel motor) and cowling speeds (the backspin motor).

One thing that just came into mind, the feedfoward gains you get for the shooter (whether it be manual or from sysid), is it for both the shooter and cowling motor? To be more specific, did you use seperate gains for each motor or for both of them as a whole?