Angled Shooter Math Analysis

Hello everyone. I’m a mentor for Team 8248 and we’ve been thinking about the shooter math. I was originally going to post this earlier but I got busy. I decided better late than never so here we goooooooooo.

I have decided to do a bunch of mathematics for the shooter. Let’s get started then, shall we? It’s quite an adventure. A common problem for controls teams is to determine an angle \theta and shooter velocity v_0 given your distance from the shooter L. We will also denote length of the shooter arm R.

Basic kinematics yields that we have:

x = \cos(\theta)v_0t + R\cos(\theta)
y = -\dfrac{1}{2}gt^2 + \sin(\theta)v_0 t + R\sin(\theta)

Notice that we can solve for t quite easily in terms of x.

t = \dfrac{x - R\cos(\theta)}{\cos(\theta)v_0} = \dfrac{x}{v_0\cos(\theta)} - \dfrac{R}{v_0}

Substituting back into the equation for y we have:

y = -\dfrac{1}{2}g\left( \dfrac{x}{v_0\cos(\theta)} - \dfrac{R}{v_0}\right)^2 + \sin(\theta) v_0 \left( \dfrac{x}{v_0\cos(\theta)} - \dfrac{R}{v_0}\right)

This is an interesting equation since x = L is known (from vision, odometry, choreographed autonomous, etc.). So we can see that we have an equation for y in terms of the unknown parameters shooter angle \theta. Luckily for us this is a 3D graph (2 inputs, 1 output)

We can actually graph this equation in a graphing calculator such as Desmos | 3D Graphing Calculator! We’ll have to modify it a bit so that the graphing calculator will accept it.

z = -\dfrac{1}{2}g\left(\dfrac{L}{\cos(y)x} - \dfrac{R}{x}\right)^2 + \sin(y) x \left(\dfrac{L}{\cos(y)x} - \dfrac{R}{x} \right) + R\sin(y)

For the graphing calculator we’ll use the x axis to represent the shooter velocity in m/s and the y axis to represent the angle in radians. The z-axis represents the height of a point projectile (obviously the note isn’t a point and this complicates things but let’s just assume that the note is a point and spherical cows). This is a wacky shape.

I’ve modified the graph below to be in degrees. I’ve also used some constraints to avoid the periodicity of the angle and capped the max speed to 30 m/s (which is around 60 mph… there’s no way you’re shooting a note that fast!) You can play around with it here.

Wow! That’s a lot of parameters and a huge search space! Luckily for us, we have additional

:sparkles: constraints~ :sparkles:

We can denote the lowest height of the opening and highest height of the speaker opening (assuming there is no “hood”) y_{\textrm{min}} and y_{\textrm{max}}. We can also denote the width of the “hood” structure w_h and the height of the bottom plane of the hood y_{\textrm{hood}}.

At distance L:

y_{\textrm{min}} \le -\dfrac{1}{2}g\left(\dfrac{L}{\cos(\theta)v_0} - \dfrac{R}{v_0}\right)^2 + \sin(\theta) v_0 \left(\dfrac{L}{\cos(\theta)v_0} - \dfrac{R}{v_0}\right) + R\sin(\theta) \le y_{\textrm{max}}

And at distance L - w_h:

-\dfrac{1}{2}g\left(\dfrac{L - w_h}{\cos(\theta)v_0} - \dfrac{R}{v_0}\right)^2 + \sin(\theta) v_0 \left(\dfrac{L- w_h}{\cos(\theta)v_0} - \dfrac{R}{v_0}\right) + R\sin(\theta) \le y_{\textrm{hood}}

These two constraint sets correspond to:

  1. Be the right height to fly between the gap in the speaker (assuming there is no hood).
  2. Clear the hood. (i.e you can’t be above it at the point it starts)

The set of (v_0, \theta) that satisfies these constraints is the intersection of three 2D surfaces in the plane. We can graph these using regular old 2D desmos. You can find it here.

I draw constraint (1) as the intersection of the two blue regions (indicated by the dark blue band). Constraint (2) is the intersection of the dark blue region with the red region (indicated by the purple band). Again I graph \theta on the y axis (in degrees) and v_0 on the x axis (in radians).

I also indicate the max velocity with the black line.

Any of the points in the purple band work. However, not all points in this region are created equal. Why? Because we also have uncertainty about how well we can control our angle \theta and our velocity v_0. We can visualize this uncertainty with something we call the “uncertainty ellipsoid”.

In general, we want not only the (v_0, \theta) to be inside the purple region, but also its uncertainty ellipsoid. We depict this below.

So we have a new problem. What’s the “thickest” part of the band? It turns out, the higher your velocity, the thicker your band is. You should aim to select an angle in the middle of the thickest part of the band.

Another question we can answer with this is figuring out how much tolerance/uncertainty we have in our shooter velocity and angle at various distances from the speaker. Say we want to make a shot at the maximum legal boundary at around 5.877m from the speaker. How much tolerance can we accept in each? Well we can play around with this a bit and see that we can have around 0.3 m/s of uncertainty in our velocity and 0.95 degrees of uncertainty in our angle. Whew, that’s a tight tolerance!

I haven’t addressed in this post how to deal with the fact that notes are not in fact points but viewed from the side, notes are rectangles and you’re only interested in if the top and bottom corners of such a rectangle can clear the constraints. You’ll also end up getting an additional constraint which is the angle of the note as it enters (since your shot becomes more and more flat as it proceeds). I may update this with corrections or with the additional constraints if time allows.

Hopefully you all find this useful! Happy coding!

13 Likes

Wow, very nice analysis.

I appreciate that everything confirms intuition, higher shot speed → higher upward shot angle on goal → most leeway in angle and shot speed accuracy.

In other words, the closer to a bullet you can get, the more you can afford to not have very precise control.

In your model, is there a closed form solution for the optimal shot angle given a constant shot speed as a function of distance?
(optimal meaning that angle which allows for maximum uncertainty)

No there isn’t. The midpoint is the mean of the solutions of the \theta to the highest and lowest y constraints since the midpoint will be the center of your uncertainty ellipsoid at the widest part of the band… Even not accounting for the hood you have:

y = -\dfrac{1}{2}g\left( \dfrac{x}{v_0\cos(\theta)} - \dfrac{R}{v_0}\right)^2 + \sin(\theta) v_0 \left( \dfrac{x}{v_0\cos(\theta)} - \dfrac{R}{v_0}\right)

=-\dfrac{1}{2} \left(\dfrac{x^2}{v_0^2}\sec^2(\theta) - 2\dfrac{xR}{v_0^2}\sec(\theta) + \dfrac{R^2}{v_0^2}\right) + \left(x\tan(\theta) - R\dfrac{\sin(\theta)}{v_0}\right)

It is not possible to isolate \theta for such an equation. The equation is quadratic in \sec(\theta) and moreover also contains a \tan(\theta) and a \sin(\theta).

But this should not be that surprising. The solution space is highly nonlinear. This is not accounting for the fact that the upperbound actually is piecewise. If you observe the upper-edge of the allowable values of (v_0, \theta), the upperbound is sometimes the red dashed region and sometime the blue region. There is a critical point in which they switch.

However, if you do fix v_0, the overall graph of the height becomes purely a 1 variable equation. There are many sophisticated ways of solving nonlinear equations (a simple one is just binary search for the solution aka bisection); however, this is unnecessary.

Just use the classical method employed by humans in history. Solve the equation geometrically and estimate the solution based on the graph. Solve this for maybe 50 points and then fit a polynomial to the the midpoints. You may want to employ different polynomials for different parts of the solution. I did this in a different desmos graph (though that one didn’t account for the the fact that the radius of the arm of the shooter changes your height). A 4th or 5th degree polynomial should do the trick.

1 Like

That’s funny, that’s exactly what my students did! They came up with a 5th degree polynomial fitting a relationship they graphed and I thought “there must be a better way” but I think I owe them an apology.

I guess what I’m wondering is how bad it would be to make a few naive approximations.
The first would be to reduce R to 0, and assume gravity comes into effect from the pivot. For the large arms that shoot tangential to the pivot, this definitely wouldn’t work, but our shooter shoots roughly colinear to the pivot radius.

The other approximation I’d make is that t = sqrt(L^2 + y_{target}^2) / v_0
Essentially approximating the path as a straightline path to the goal (again, assumption being a very fast shot speed)
This lets you calculate a drop distance y_{drop} = 1/2 g t^2
Then, the angle is just atan((y_{max} + y_{drop}) / L)

I suppose this would effectively give you an iterative approximation. You could repeat this process again for your new y_{goal}' = y_{goal} + y_{drop}, calculate a new t and a new y_{drop}

Tomorrow I’ll throw this in excel and see how it compares to the “proper” solution, as I’m just curious.

This looks very similar to the analysis I took a stab at a few years back!

It’s cool to see someone apply some real math to this instead of the disaster zone of an Excel sheet that I ended with. I’m excited to check this out in more detail tomorrow.

R \approx 0 is not a good assumption. Check how much it changes the graph in the ones I posted.

R \approx 0

R = 1

R = 1 is a reasonable length for most shooter arms. Notice how the edge shifts down by a lot if your arm is 1m long. Every variable matters at a distance. Close-up, maybe not. I realized the graph I posted had my previous version without accounting for the length of the arm. I’ve edited the link and you can play around with it.

Can’t seem to edit my post for some reason so I’ll just post the updated link here for the 2d graph: FRC 2024 Crescendo: Shooter Math 2D | Desmos

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.