The answersDownload the PDF
Worksheet

4.1 What the camera sees

Vision · Robot club · about 15 min

BugBotLab
NameClassDate

What this lesson is about

set_cv, the tag list, pixels and distance, empty lists.

Questions 7 marks in all

  1. [1 mark]A program calls apriltags() before it has called set_cv. What does it get?

    1. AAn empty list, because no detector is switched on
    2. BEvery tag the camera can see
    3. CAn error saying the camera is off
    4. DThe tags from the last program that ran
  2. [1 mark]Each entry in apriltags() is [id, cx, cy, distance]. What is tag[3]?

    1. AHow far away the tag is, in cm
    2. BThe number printed on the tag
    3. CHow far across the picture it is, in pixels
    4. DHow far down the picture it is, in pixels
  3. [1 mark]The picture is 320 pixels wide. What cx does a tag straight ahead of the robot have?

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

    tag = [7, 160, 120, 45.0]
    print(f"marker {tag[0]} at {tag[3]} cm")
  5. [1 mark]The robot turns away so no tag is in view, then runs tag = apriltags()[0]. What happens?

    1. AAn error, because there is no first item in an empty list
    2. Btag becomes 0
    3. Ctag becomes an empty list
    4. DIt waits until a tag comes into view
  6. [1 mark]Which of these are true of the list apriltags() gives you?

    Tick every answer that is true.

    1. AThe nearest tag comes first
    2. BThere is one entry for each tag it can read
    3. Ccx is measured in cm
    4. DAn empty list means something has gone wrong
  7. [1 mark]Marker 7 is 45 cm away. The robot drives forward 8 cm towards it. About what distance, in cm, should the next apriltags() report?

The task: find the marker

Switch on the tag detector and print marker 7 at 45.0 cm using the id and distance from the list. Do not drive.

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

print(apriltags())

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

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

Challenges

  1. Print cx and cy as well, in the form marker 7 at 45.0 cm, pixel (160, 120).
  2. Drive forward 5 cm at a time and print the distance until it is under 20.
  3. Keep driving in 1 cm at a time. How close can the robot get and still read the tag? What happens to cx on the way in, and why?