The answersDownload the PDF
Worksheet

6.4 Seeing other robots

Seeing more · Robot club · about 15 min

BugBotLab
NameClassDate

What this lesson is about

Tags from 100 up say who and how far; LEDs say what.

Questions 7 marks in all

  1. [1 mark]The camera reads a tag with id 101. What is it?

    1. AA marker on the mat
    2. BAnother robot
    3. CA blob
    4. DA misread, because ids stop at 99
  2. [1 mark]What does this program print?

    seen = [['green', 60, 120, 55.0], ['red', 240, 110, 42.0]]
    for colour, cx, cy, dist in seen:
        print(colour, dist, round((cx - 160) * 120 / 320, 1))
  3. [1 mark]What does robots() give?

    1. AOnly the robots in view, each as [colour, cx, cy, distance]
    2. BEvery robot in the arena, seen or not
    3. CThe ids of the robots, as plain numbers
    4. DThe tags on the robots
  4. [1 mark]Which of these are true?

    Tick every answer that is true.

    1. AA robot's dome colour says which robot it is
    2. BIts dome can also say what it is doing
    3. CA robot with its LED off is not in robots()
    4. DDomes are best told apart by shade, like light and dark green
  5. [1 mark]A robot's dome is at cx = 272. What is its bearing in degrees?

  6. [1 mark]Your robot runs led("red"). What can the other robots see?

    1. AA red blob, if they look for red with the blob detector
    2. BA tag with a new id
    3. CNothing, the LED is only for people
    4. DA red line
  7. [1 mark]What does this program print?

    seen = [['green', 90, 120, 30.0], ['red', 200, 115, 42.0], ['blue', 20, 110, 80.0]]
    near = [r[0] for r in seen if r[3] < 50]
    print("near:", near)
    print("nearest:", seen[0][0])

The task: spot the robot

Print robot at <cm> cm, bearing <degrees> and dome: <colour>, both from robots(). Do not drive.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

# every robot in view, nearest first
print(robots())

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

QR code
Do it on the robot
www.bugbotlab.com/learn/6-4-seeing-other-robots/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Turn until the green robot is centred in the picture, then print your heading.
  2. Print the robot's position on the mat, from your position, heading, and its distance and bearing. Hint: math.sin and math.cos.
  3. Flash your own dome red and green alternately every half second while printing what you see.