Hands and feet · Robot club · about 30 min
Every ball into the home zone.
[1 mark]The first ball is home. On the second trip, what goes wrong with a plain find_ball("red")?
blobs() can only see one ball per runfetch always returns False after the first ballballs_out works out where each blob is and ignores the ones already home.[1 mark]What does this program print?
def at_home(bx, by):
return abs(bx) < 15 and by < 16
for bx, by in [(5, 10), (-20, 10), (0, 40)]:
print(bx, by, "home" if at_home(bx, by) else "still out")5 10 home -20 10 still out 0 40 still out
Home needs x within 15 cm of the start on either side and y under 16. (-20, 10) is too far left and (0, 40) too far up.
[1 mark]What does this program print?
import math px, py = 0, 0 heading = 90 bearing = 0 dist = 4 * 92 / 23 h = math.radians(heading + bearing) print(round(px + math.sin(h) * dist), round(py + math.cos(h) * dist))
16 0
The ball is 16 cm away. Heading 90 faces right (clockwise from up the mat), so the ball is 16 cm along x and 0 along y.
[1 mark]After opening the jaws at home, put the moves in order so the robot never drives through the ball it just dropped.
Number the lines 1 to 4 to put them in the right order.
gripper("open")backward(50, distance=8)forward(50, distance=20)right(50, distance=14)gripper("open")
backward(50, distance=8)
right(50, distance=14)
forward(50, distance=20)Let go, step back, step aside, and only then drive off for the next search.
[1 mark]Why step back and then sideways before driving away?
go_to only works facing sideways[1 mark]Three balls must be home within two minutes. On average, how many seconds can each ball take?
Bring all three red balls into the home zone within two minutes.
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.