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
constraints~
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:
- Be the right height to fly between the gap in the speaker (assuming there is no hood).
- 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!