Catapult Parabola Programming

Hello everyone,

I’m starting to make a code for my catapult in VEXcode IQ Blocks for the new Level Up season. I’m planning to utilize a distance sensor and a TouchLED sensor in my bot to create some things that would be useful in competitions. First, the distance sensor senses the distance between the bot and the level 1 goal. Then, it would calculate the parabola of where the bean bag would launch, and based on that, the touchLED sensor would flash a color based on what level goal it would score on. At this point, you might think I could just calibrate and have a specific distance between the bot and the goal. However, I am having a tensioner. So, the touchLED sensor would let me know if I need to tighten or ease the tensioner. The problem is that, I don’t know what equations to use to calculate the parabola. I’ve done some research, but I thought I will understand it better if people explained it knowing the context, instead of pure research. If you know an equation, please explain the equation like you’re explaining it to a 7th grader. But, if you have an equation that “I might not understand”, please still explain it anyways because I’m here to learn. Thank you!

I believe this is the equation you’d need:

v_0 = \sqrt{\frac{g \cdot x^2}{2 \cdot \cos^2(\theta) \cdot (x \cdot \tan(\theta) + h_0 - y)}}

x = Horizontal distance from the goal.
y = The height of the bean bag at X.
\theta (Theta) = The height of the bean bag when it leaves the catapult.
\theta = The launch angle (degrees)
v_0 = The initial speed of the bean bag. (launch Velocity
g = Gravity (9.81 \text{ m/s}^2 or 9810 \text{ mm/s}^2)

Basically what this equation does is once you input launch angle, distance from the goal, and how tall the goal is, it tells you how much speed/power needed to get the bean bag to the desired endpoint. Or in other words do you need to tighten or loosen the tensioner.

There are a couple of problems with using this though, first being it’s not the easiest equation to solve with block code to be fair I don’t even know where to begin solving this in blocks. Second, it would be very hard to calculate the speed of the bean bag on release and what you would have to do to get this equation to work is take the speed it tells you let’s say 4 m/s well then somehow you have to figure out how much tension you need to get the beanbag to that speed, which I wouldn’t even know where to start on that problem.

So, in short I probably wouldn’t go about trying to solve this with an equation instead I would use a lookup table. What I mean by that is you set the robot at a fixed position from the goal then see how much tension you need to use to get the beanbag to the desired endpoint, then move back and repeat the process keep repeating this process until you’ve collected a lot of data (the more the better). Now you might have a table something like this

Distance from Goal Tension
500 mm 25%
800 mm 45%
1000 mm 55%
1500 mm 80%
1800 mm 100%

What you can do this this table is in your code your robot knows how far away it is from the goal, let’s say 650 mm, well it knows its half way between 500mm and 800mm and so can calculate how much power to use in this example it would be 35%. This calculation is called Linear Interpolation and I believe you can use this equation

\text{Power} = \text{Power}_1 + (\text{Distance} - \text{Distance}_1) \cdot \left( \frac{\text{Power}_2 - \text{Power}_1}{\text{Distance}_2 - \text{Distance}_1} \right)

\text{Distance}_1, \text{Power}_1 = Your smaller test point (In that last example it would’ve been 500mm and 25%)
\text{Distance}_2, \text{Power}_2 = your bigger testing point (In that last example it would’ve been 800mm and 45%)
Distance = The actual distance from the goal. (In that last example it would’ve been 650mm)
Power = The output of the equation in our example it would’ve been 35% this is the number that really matters and how much you tension you should apply.

I hope this helped! I’m happy to explain anything further if need just lmk. Your idea of using the LED is really cool, good luck!

Thanks for the reply! I haven’t thought of this method, but linear interpolation seems way easier to calculate than calculating the parabola. I’m most likely going to use this method, so thank you so much! By the way, it doesn’t really matter much but there are two definitions for theta, and the actual definition is the launch angle one right? Thank you!

I totally know what that is :l lol Nice explanation tho

It just looks hard for reference I think it’s like 9th grade math if I’m not wrong​:grin:

I’m glad you found it helpful! Yeah, I realized just as the post was approved that theta was duplicated but you’re right the correct definition is the launch angle. The other one is meant to be ℎ0.

Thank you for the clarification. This is out of curiosity, but is making the square root equation more accurate than the Linear Interpolation? And also do you know what the equation is called? Thank you!

The equation I gave you was a rearrangement of the Trajectory Equation. To answer the question of which one is more accurate I would say the lookup table with Linear Interpolation is. While in an ideal world the trajectory equation would be more accurate once you introduce things like friction in your mechanisms and air resistance things become quite messy, with the lookup table it’s based on how your catapult really works not the measurements you’ve made of it.

Thanks for the reply! I guess I was just overthinking it, thank you so much for introducing me to these equations! These equations will definitely be useful this season, and my overall robotics experience​:grin: