Vision · Robot club · about 15 min
set_cv, the tag list, pixels and distance, empty lists.
[1 mark]A program calls apriltags() before it has called set_cv. What does it get?
set_cv("apriltag").[1 mark]Each entry in apriltags() is [id, cx, cy, distance]. What is tag[3]?
[1 mark]The picture is 320 pixels wide. What cx does a tag straight ahead of the robot have?
cx = 160 is dead centre. Smaller is left, bigger is right.[1 mark]What does this program print?
tag = [7, 160, 120, 45.0]
print(f"marker {tag[0]} at {tag[3]} cm")marker 7 at 45.0 cm
tag[0] is the id and tag[3] is the distance, so this is exactly the line the task asks for.
[1 mark]The robot turns away so no tag is in view, then runs tag = apriltags()[0]. What happens?
tag becomes 0tag becomes an empty list[1 mark]Which of these are true of the list apriltags() gives you?
Tick every answer that is true.
cx is measured in cmcx is in pixels, and an empty list just means no tag is in view.[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?
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())
The hint students can ask for: Switch the camera to the tag detector, read the tag in front of you, and print marker 7 at 45.0 cm (id and distance from the list). Do not drive.
from bugbot import *
connect()
set_cv('apriltag')
tags = apriltags()
tag = tags[0]
print('marker', tag[0], 'at', tag[3], 'cm')
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.