Robot Golf¶
Our goal is to build a robot and program it so it can that can get 3 balls into their goals within 30 seconds. The playing field has 3 spots where the balls start, a line your robot may not cross and 3 goals with varying values. The score is the sum of the distances the 3 balls are from the goal at the end of the 30 seconds. You want the lowest score in the class.
Playing Field¶
The playing field holds 3 balls. One is placed at red, one at green and another at blue. The goal is then to strike the ball so that you get it onto each of the black circles. This would be a perfect score of 30. You get 30 points just for striking each ball and staying within the field. You, however, lose points for being a distance from the goal. Depending on the distance for each ball you would lose between 1 and 5 points for not landing on the black circle.
We've documented two different approaches to solving this problem so we can analyze data from these attempts to inform our solution.
from IPython.display import YouTubeVideo
YouTubeVideo('As3rRrjFoS4', width=800, height=600)
Bump Bot¶
This robot is simple and can drive directly into the ball. The goal is just to strike the front. It operates by driver control. The inteface is written in FabLabScratch and the program looks like this. A fast and practiced drive is key to succeed with this robot. We aren't going to tell you how to make your interface, but we can show a simple driving progrma that moved our robot forward. After building the robot we coded it using FabLab's Scratch. We used this program in the video and just changed the motor speed variable. Listed below are data collected on the connection between distance the ball travels and the speed at which the car collides.
Speed of Motor (%) | Distance Ball Travels (cm) |
---|---|
50 | 7 |
60 | 15 |
70 | 25.5 |
80 | 19 |
90 | 30.5 |
100 | 25 |
import matplotlib.pyplot as plt
import numpy as np
speed = np.array([50, 60, 70, 80, 90, 100]) #speeds we set the motors to
distance = np.array([7, 15, 25.5, 19, 30.5, 25]) #distances that the ball rolled
#Recording points [(50, 7), (60, 15), (70, 25.5), (80, 19), (90, 30.5), (100, 25)]
plt.figure(100) #naming the figure
plt.scatter(speed, distance)
plt.title("BumpBot Performance") # adding the title
plt.xlabel("Motor Speed (%)")
plt.ylabel("Distance Ball Travels (cm)") # adding the lables
a, b = np.polyfit(speed, distance, 1) #calculate line of best fit
plt.plot(speed, a*speed+b)
plt.show() #show the plot
Swing Bot¶
This robot is designed to hit a ball. You can consider how you can make a robot that can hit 3 balls. This simple example shows how the angle we swing changes the distance that the ball travels.
Angle (°) | Distance Ball Travels (cm) |
---|---|
45 | 23 |
50 | 22.5 |
55 | 28.5 |
60 | 30 |
swing = np.array([45, 50, 55, 60]) #speeds we set the motors to
distance = np.array([23, 22.5, 28.5, 30]) #distances that the ball rolled
#Recording points [(45, 23), (50, 22.5), (55, 28.5), (60, 30)]
plt.figure(101) #naming the figure
plt.scatter(swing, distance)
plt.title("SwingBot Performance") # adding the title
plt.xlabel("Swing Angle ($^\circ$C)")
plt.ylabel("Distance Ball Travels (cm)") # adding the lables
a, b = np.polyfit(swing, distance, 1) #calculate line of best fit
plt.plot(swing, a*swing+b)
plt.show() #show the plot