The answersDownload the PDF
Worksheet

9.1 Sending

Talking to each other · Robot club · about 15 min

BugBotLab
NameClassDate

What this lesson is about

send(): a broadcast everyone hears; numbers into text.

Questions 6 marks in all

  1. [1 mark]You call send("hello"). Who hears it?

    1. AEvery other robot on the mat
    2. BOnly the nearest robot
    3. COnly a robot you name
    4. DNobody until they reply
  2. [1 mark]Which line sends your position in a way another robot can read?

    1. Asend(f"at {x:.0f},{y:.0f}")
    2. Bsend("at x,y")
    3. Csend(position())
    4. Dsend(x, y)
  3. [1 mark]What does this program print?

    x, y = 12.6, 30.4
    print(f"at {x:.0f},{y:.0f}")
  4. [1 mark]Two robots are not understanding each other. Where do you look first?

    1. AThe radio log under the robot view, which shows every message with its time and sender
    2. BThe depth grid
    3. CThe robot's position
    4. DThe gripper
  5. [1 mark]You send a question. Is a reply guaranteed?

    1. ANo: the radio is a shout, and nobody has to answer
    2. BYes, every robot must reply
    3. CYes, but only from the nearest robot
    4. DOnly if you send it twice
  6. [1 mark]What type of Python value is every radio message?

The task: call out

Send hello, drive forward 20 cm, then send your position as at <x>,<y> in whole centimetres from the start.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
# radio this to every other robot
send('hello')
# pause 1 s (the robot keeps doing what it was told)
wait(1)
print(messages())

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

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

Challenges

  1. Send your heading as facing <degrees>.
  2. Send tick <seconds> once a second for five seconds, using clock().
  3. Send your position as JSON (json.dumps({"x": x, "y": y})), the way lesson 8.7 saved a model.