Talking to each other · Robot club · about 25 min
Drive to the handover, then and only then say go.
[1 mark]Put the relay handover in order.
Number the lines 1 to 5 to put them in the right order.
wait(0.5) to settlesend("go")Stay put and listen for finishedstop()Drive into the handover zoneDrive into the handover zone
stop()
wait(0.5) to settle
send("go")
Stay put and listen for finishedArrive, stop, settle, and only then hand over the baton.
[1 mark]The starter code sends go before driving. What happens?
go is sent while you are inside the zone.[1 mark]The handover zone starts 32 cm ahead and is 16 cm deep. How many cm ahead is its middle?
[1 mark]What does this program print?
def in_zone(y):
return 32 <= y <= 48
for y in [30, 40, 49]:
print(y, in_zone(y))30 False 40 True 49 False
The zone runs from 32 to 48. 30 has not arrived yet and 49 has gone past.
[1 mark]Why is there a wait(0.5) between stop() and send("go")?
stop() only works after a wait[1 mark]You sent go and have heard nothing for two seconds. What is a sensible thing to do?
go again, in case the first was missedDrive into the handover zone, stop, send go, and stay there until the Runner says finished.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
# radio this to every other robot
send('go')
# drive forward at 60 for 40 cm, then stop
forward(60, distance=40)The hint students can ask for: Drive into the handover zone, stop there, and only then send go. The Runner sets off when it hears it and says finished at the far end. Stay in the zone.
from bugbot import *
connect()
while position()[1] < 40:
forward(60)
wait(0.1)
stop()
wait(0.5)
send("go")
for tick in range(80):
for sender, text in messages():
print(sender, "says:", text)
if "finished" in text:
break
wait(0.1)
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.