Catapult¶
We are going to be working to use data and computer science as a tool to engineer the best LEGO catapult. Ms. Arendsee, Data Scientists and FabLab Program Manager built our first catapult. We started with a simple program that moved a LEGO beam to strike the pingpong ball.
Design 1¶
The motor speed changed with each trial. Here is how the program started (this is translated from an original block code program):
The robot is elevated and sends the ball up a ramp when struck.
from IPython.display import YouTubeVideo
YouTubeVideo('kZhy3R39_OA', width=800, height=600)
Below you will see the data we gathered from this
Motor Speed (%) | Distance (cm) |
---|---|
60 | 10 |
70 | 13.5 |
80 | 16 |
90 | 19 |
100 | 20 🎉 |
Below is a graph from MatPlotLib showing our data in a visualization
import matplotlib.pyplot as plt
import numpy as np
speed = np.array([60, 70, 80, 90, 100]) #speeds we set the motor to
distance = np.array([10, 13.5, 16, 19, 20]) #distances that the ball was thrown
plt.figure(100) #namming the figure
plt.scatter(speed, distance)
plt.title("Catapult 1 Performance") # adding the title
plt.xlabel("Motor Speed (%)")
plt.ylabel("Distance Ball Travels (cm)") # adding the lables
plt.show() #show the plot
This graph shows an increase in distance travelled as the motor speed increases. This means that the faster we move the ball, the further we can send it. We can aim the ball by controlling the motor speed.
Design 2¶
Considering the initial robot we sketched an idea for a robot that works more like a trebuchet. Here is the basic idea. Our second design focused on having a long arm and a basket.
You can find a basic introduction to running micropython on your LEGO Spike Prime Hub at this LEGO Tutorial Our basic program looked like this:
We changed the angle at which the program stopped as our variable. We are also running several trials with varying arm lengths.
Degress Motor Runs (°) | Distance Ball Thrown by 10 peg arm (cm) | Distance Ball Thrown by 15 peg arm (cm) | Distance Ball Thrown By 20 peg arm (cm) |
---|---|---|---|
30 | 12 | 13 | 15 |
45 | 17 | 19 | 25 🎉 |
60 | 14 | 12 | 18 |
import matplotlib.patches as mpatches
plt.figure(101) #starting a new figure
x = np.array([30, 45, 60]) #angles we launched at
y1 = np.array([12, 17, 14]) #distances the 10 peg arm threw
plt.scatter(x, y1, color = 'hotpink')
y2 = np.array([13, 19, 12]) # distances the 15 peg arm threw
plt.scatter(x, y2, color = '#88c999')
y3 = np.array([15, 25, 18]) # distances the 20 peg arm threw
plt.scatter(x, y3, color = '#2faed4')
plt.title("Catapult 2 Performance") # Add a title to the plot
plt.xlabel("Degrees Motor Runs ($^\circ$)")
plt.ylabel("Distance Ball Travels (cm)") #Add labels to the plot
pink_patch = mpatches.Patch(color='hotpink', label='10 peg arm')
green_patch = mpatches.Patch(color='#88c999', label='15 peg arm')
blue_patch = mpatches.Patch(color='#2faed4', label='20 peg arm')
plt.legend(handles=[pink_patch, green_patch, blue_patch]) # add a color key in the corner
plt.show()
Goal¶
We are designing a catapult that can get closest to landing at 80 cm from the launch point. Documenting our reasoning and research process is key!