The answersDownload the PDF
Worksheet

7.7 Project: clear the mat

Hands and feet · Robot club · about 30 min

BugBotLab
NameClassDate

What this lesson is about

Every ball into the home zone.

Questions 6 marks in all

  1. [1 mark]The first ball is home. On the second trip, what goes wrong with a plain find_ball("red")?

    1. AIt can find the red ball already sitting in the home zone
    2. BThe gripper only works once per run
    3. Cblobs() can only see one ball per run
    4. Dfetch always returns False after the first ball
  2. [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")
  3. [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))
  4. [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.

    1. gripper("open")
    2. backward(50, distance=8)
    3. forward(50, distance=20)
    4. right(50, distance=14)
  5. [1 mark]Why step back and then sideways before driving away?

    1. ASo the robot's body never passes through the spot where it left the ball
    2. BTo reset the gripper servo
    3. CSo the camera can count the balls at home
    4. DBecause go_to only works facing sideways
  6. [1 mark]Three balls must be home within two minutes. On average, how many seconds can each ball take?

The task: clear the mat

Bring all three red balls into the home zone within two minutes.

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/7-7-project-clear-the-mat/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Print the time each ball took.
  2. Fetch the nearest ball first: compare the blob widths before choosing.
  3. Add a fourth ball in the free-play editor and clear all four.