# Shooter speed calculation from vision tracking

Hi,
I was wondering how other teams who used a shooter this year calculated its
speed with vision tracking.
In our team, we built a table for speed-distance, plug it into excel and used polynomial regression to give us a function that transfers a given distance from the high goal to the desired shooter speed needed to score. with this method we managed to hit the goal from almost any given point on the field.

The disadvantages of this method,i think, are that

1. it can maybe be not precise if you have not done your measurement right, 2) it is a little time consuming and need to be redone after every slight change in the shooter mechanism.

My question is, how did your team calculate your flywheel/angle/shooter speed from a given distance?

i know some teams did it with physical calculation but i have always thought that air drag / ball spin (magnus effect) are really hard to predict and calculate. maybe someone did it that way and can explain how? or maybe someone did it with a different approach and can share their experience?

if you have any external resources / reading material on the subject please share them:)

You don’t need to turn the table into a polynomial. You can use a lookup table, or a carefully-chosen piecewise-linear function.

i know some teams did it with physical calculation but i have always thought that air drag / ball spin (magnus effect) are really hard to predict and calculate.

Gathering empirical data for your specific shooter and using that data as you did is likely the most accurate approach.

maybe someone …explain how?

Here’s a paper for students interested in the physics, math, and computer simulation aspects of this problem: Free-body force diagram, derivation of differential equations of motion, and C pseudo-code for trapezoidal numerical integration.

thank you for your quick response:)

so a piecewise linear function will be more accurate than a polynomial regression?

and physical calculations will be generally more precise than a table?

Not as a general proposition, no. It depends on your empirical data.

For data that is shaped such that it is not well-modeled by a polynomial of reasonable degree, a piecewise-linear function might be more accurate.

Also, depending on the processor being used, a piecewise-linear function may execute faster than a high-order polynomial.

and physical calculations will be generally more precise than a table?

I don’t know what you mean by “physical calculations” so I’ll wait till you have clarified before answering that.

The thing you should be focusing on is consistency. If you shoot several times from the same location using boulders of different weight, age, and state of disrepair, do you always score the goal, regardless of the battery’s state of charge? If you don’t have a consistent shooter, it’s fruitless to worry to much about polynomial vs piecewise-linear vs lookup table.

by physical calculation i mean calculating the position and height of the ball at a given point with physical equation that include air drag and magnus effect

That will be very precise but not as accurate as empirical data.

Besides, there is no closed-form solution to the differential equations of motion when you introduce air drag and magnus. You would have to do a numerical simulation as discussed in the paper I linked. You probably don’t want to be doing that in the roboRIO.

by empirical data you mean like a table of values?

By “empirical data” I mean the test data you collected by actually firing your shooter from different distances.

You can put that empirical data into a table and do a table lookup in your code.

Or you can fit a polynomial to that data and compute the polynomial in your code.

Or you can construct a piecewise-linear function from that empirical data, and compute that function in your code.

Or you can construct a piecewise-cubic-spline function from that empirical data, and compute that function in your code.

We use a catapult-like pneumatic arm instead of a shooter wheel, but we have found that as other people have stated on this thread, the values we set to make shots look really arbitrary. They’re most likely a combination of multiple physical effects and very hard to predict.
We used linear interpolation between values in a lookup table we got from test data. It’s been very successful so far, and I suggest you do something similar instead of trying to simulate the physics of the shot. Retaking values for the table took us about 15 minutes on the practice field before our competition last weekend, so it shouldn’t be too hard after you’ve done it a few times.

A piecewise linear function is essentially the same thing as an interpolated lookup table with unevenly-spaced x values.