Talking to each other · Robot club · about 20 min
One robot at a time through a corridor: announce, wait, go.
[1 mark]In the corridor task, which message tells you it is time to go?
corridor clearcorridor busyenteringout[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?
[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")[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.
Drive through, holding the middleWait for corridor clearsend("entering")send("out")[1 mark]The Porter does not listen to messages. Why send entering anyway?
forward only works after a send[1 mark]Driving along the corridor, the robot faces heading 90. Why does it steer from y and not x?
position() only gives yWait 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.
out when you reach the zone, then come back through the corridor the same way.busy arrives while you are still waiting, print missed it and keep waiting for the next clear.