The answersDownload the PDF
Worksheet

9.5 Taking turns

Talking to each other · Robot club · about 20 min

BugBotLab
NameClassDate

What this lesson is about

One robot at a time through a corridor: announce, wait, go.

Questions 6 marks in all

  1. [1 mark]In the corridor task, which message tells you it is time to go?

    1. Acorridor clear
    2. Bcorridor busy
    3. Centering
    4. Dout
  2. [1 mark]The corridor stays clear for about 9 seconds, and you need about 6 seconds to get through. After hearing clear, how many seconds can you afford to delay before setting off?

  3. [1 mark]What does this program print?

    batches = [[("Porter", "corridor busy")], [], [("Porter", "corridor clear")]]
    clear = False
    checks = 0
    for batch in batches:
        checks += 1
        for sender, text in batch:
            if "clear" in text:
                clear = True
        if clear:
            break
    print("clear" if clear else "waiting", "after", checks, "checks")
  4. [1 mark]Put the steps for getting through the corridor in order.

    Number the lines 1 to 4 to put them in the right order.

    1. Drive through, holding the middle
    2. Wait for corridor clear
    3. send("entering")
    4. send("out")
  5. [1 mark]The Porter does not listen to messages. Why send entering anyway?

    1. AA protocol is the agreement: a robot that did listen could hold back for you
    2. BThe Porter stops if it hears it
    3. CThe checker ignores robots that do not send
    4. Dforward only works after a send
  6. [1 mark]Driving along the corridor, the robot faces heading 90. Why does it steer from y and not x?

    1. AFacing along x, sideways drift shows up in y
    2. Bx is always zero
    3. Cposition() only gives y
    4. DHeading 90 means facing up the mat

The task: one at a time

Wait for corridor clear, send entering, drive through to the green zone without touching the walls or the Porter.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
# radio this to every other robot
send('entering')
# drive forward at 60 for 72 cm, then stop
forward(60, distance=72)
# radio this to every other robot
send('out')

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

QR code
Do it on the robot
www.bugbotlab.com/learn/9-5-taking-turns/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Print how long you waited.
  2. Send out when you reach the zone, then come back through the corridor the same way.
  3. If busy arrives while you are still waiting, print missed it and keep waiting for the next clear.