The robot as a system · University · about 25 min
position() is the lab's overhead camera. odometry() is what the robot has, and it drifts.
[1 mark]Why is using position() as the input to a controller treated as cheating?
[1 mark]A gyro reads 0.4 degrees per second too high. Integrated for 90 seconds, how many degrees of heading error does that bias alone produce?
[1 mark]How do the two kinds of sensor error grow when dead reckoning integrates them?
[1 mark]Driving a square, the heading error gets a little bigger at every corner. Why does that matter more than a position error of the same size?
[1 mark]Driving the same square with set_noise(0), odometry() and position() agree exactly, yet the robot still has not come back to where it started. What does that show?
[1 mark]At the end of a run, odometry() gives (12.0, 118.5) and position() gives (15.0, 114.5). What does this print?
import math
ox, oy = 12.0, 118.5
tx, ty = 15.0, 114.5
print("error:", round(math.hypot(ox - tx, oy - ty), 1))error: 5.0
The gaps are 3 cm in x and 4 cm in y, and the distance is the square root of 3² + 4², which is 5.0 cm.
Drive at least 120 cm, with at least one turn in it. At the end, print how far odometry() is from position(), as error: 4.3.
from bugbot import * connect() forward(70, distance=50)
The hint students can ask for: Drive at least a metre and a bit, with a turn or two in it. At the end read both odometry() and position() and work out the distance between the two points.
from bugbot import *
connect()
for leg in range(3):
forward(70, distance=50)
turn_right(40, angle=90)
stop()
ox, oy, oh = odometry()
tx, ty = position()
gap = ((ox - tx) ** 2 + (oy - ty) ** 2) ** 0.5
print("odometry", ox, oy, "truth", tx, ty)
print("error:", round(gap, 1))
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.