Vision · Robot club · about 15 min
Pixels to degrees, and a controller that turns to face a tag.
[1 mark]Using bearing = (cx - 160) * 120 / 320, what is the bearing in degrees of a tag at cx = 240?
[1 mark]Using bearing = (cx - 160) * 120 / 320, where is a tag at cx = 100?
[1 mark]What does this program print?
def bearing_of(cx):
return (cx - 160) * 120 / 320
for cx in [0, 160, 320]:
print(bearing_of(cx))[1 mark]The loop runs drive(0, 0, bearing_of(cx) * 3) and the tag is at cx = 220. What does the robot do?
[1 mark]A student writes error = (160 - cx) * 120 / 320 and uses drive(0, 0, error * 3). What happens?
[1 mark]Once the error is under 1.5 degrees, the program stops, waits 0.3 s and checks again. Why check again?
Turn until marker 3 is in the middle of the picture, then print centred. Do not drive.
# 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.
math.degrees(math.atan((cx - 160) / 92.4)) (after import math). What does it give for marker 3? Compare the two formulas at cx 160, 200, 240, 280 and 320: where is the difference biggest?