The answersDownload the PDF
Worksheet

4.5 Searching

Vision · Robot club · about 20 min

BugBotLab
NameClassDate

What this lesson is about

Spin until it is in view; find and approach as functions; list comprehensions.

Questions 7 marks in all

  1. [1 mark]What does while not apriltags(): mean?

    1. AKeep looping while no tag is in view
    2. BKeep looping while a tag is in view
    3. CLoop once, then stop
    4. DLoop until the tag detector is switched off
  2. [1 mark]What does this program print?

    tags = [[2, 60, 120, 35.0], [5, 210, 118, 60.0], [8, 300, 125, 90.0]]
    mine = [t for t in tags if t[0] == 5]
    print(mine)
    print(len(mine))
  3. [1 mark]The spin loop ends the moment a tag appears. Why do stop() and wait(0.3) come next?

    1. AThe robot coasts, so the tag may slide to the edge of the view or out of it
    2. BThe camera switches off when a tag is found
    3. Capriltags() only works when the robot is still
    4. DTo give the list time to sort itself
  4. [1 mark]What is a heuristic search?

    1. AA search that uses a clue, like where the thing was last seen
    2. BA search that always spins right
    3. CA search that gives up after one second
    4. DA search that uses the blob detector
  5. [1 mark]The camera sees 120 degrees. How many degrees of the full circle around the robot are out of view?

  6. [1 mark]In approach, what happens if the tag goes out of view on the way in?

    1. AIt turns slowly with turn_right(30) until the tag is back
    2. BIt stops and the program ends
    3. CIt drives forward at full speed
    4. DIt goes back to the start
  7. [1 mark]Put the hide and seek program in order.

    Number the lines 1 to 4 to put them in the right order.

    1. `print("found 5")`
    2. `set_cv("apriltag")`
    3. `find(5)`
    4. `approach(5, 14)`

The task: hide and seek

Find marker 5, print found 5, then drive up and stop about 14 cm in front of it.

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

# camera: the tag detector
set_cv("apriltag")
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-5-searching/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Search left instead of right. Which is quicker for this marker?
  2. Print how many degrees the search turned through.
  3. Make find give up and return False after a full turn with nothing seen, and print a message instead of spinning forever.