Odometry and drift · University · about 30 min
Dead reckoning between landmarks, and a reset whenever something known comes into view.
[1 mark]Tag 7 is 165 cm up the mat from the start, and the robot, facing it, reads it at 40 cm. What y does the fix give, in cm?
[1 mark]The estimate is y = 120 and three fixes in a row all say 130. The estimate is blended as in the lesson. What does this print?
y = 120.0
for fixed in (130.0, 130.0, 130.0):
y = 0.8 * y + 0.2 * fixed
print(round(y, 2))122.0 123.6 124.88
Each blend moves y a fifth of the way to the fix: 120 to 122, then 123.6, then 124.88. The gap shrinks by a factor of 0.8 each time instead of vanishing at once.
[1 mark]Dead reckoning with a fix every so often. What does a plot of the position error against time look like?
[1 mark]When is replacing the estimate with the fix, rather than blending, the right choice?
[1 mark]Which of these are reasons in the lesson to distrust a fix?
Tick every answer that is true.
[1 mark]Watching the printout, each fix makes a bigger jump in the estimate than the last. What does that tell you?
Tag 7 is on the far wall, 165 cm up the mat from the start. Drive at least a metre towards it, dead reckoning as you go, take a fix when the tag is close enough to be worth having, and print my y: at the end.
from bugbot import *
connect()
set_cv("apriltag")
TAG_Y = 165.0The hint students can ask for: Tag 7 sits on the far wall, 165 cm up the mat from where the robot starts. Dead reckon towards it, and when the camera reads it, the fourth number in the tag is how far away it is. That gives you your y directly, so replace the estimate rather than adding to it.
from bugbot import *
connect()
DT = 0.1
TAG_Y = 165.0 # how far up the mat the tag is, from where the robot starts
set_cv("apriltag")
y = 0.0
forward(75)
for i in range(85):
y += flow()[1] * DT
seen = [t for t in apriltags() if t[0] == 7]
if seen and seen[0][3] < 120:
y = TAG_Y - seen[0][3] # a fix: replace the estimate, do not add to it
wait(DT)
stop()
print("my y:", round(y, 1))
print("truth", position())
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.