Odometry and drift · University · about 25 min
The odometry update, one step at a time, and what the step size costs you.
[1 mark]Speeds in cm/s are read every 0.1 s as the robot speeds up. This integrates them two ways. What does it print?
speeds = [0.0, 8.0, 14.0, 18.0, 20.0, 20.0]
DT = 0.1
euler = 0.0
trap = 0.0
for i in range(1, len(speeds)):
euler += speeds[i] * DT
trap += 0.5 * (speeds[i] + speeds[i - 1]) * DT
print("euler:", round(euler, 2))
print("trapezium:", round(trap, 2))[1 mark]Which integration method takes the speed read at one instant and uses it as if it were the average over the whole step?
[1 mark]When do the trapezium rule and Euler integration give the same answer?
[1 mark]A loop multiplies by DT = 0.1, but its real period is 0.11 s. The robot drives at a steady 20 cm/s for 50 passes. By how many centimetres does the integral fall short of the true distance?
[1 mark]Why does assuming the loop period, rather than measuring it with clock(), cause an error that grows through the run?
[1 mark]A straight-line integral of flow() is close to the truth but not exact. Which of these are reasons the lesson gives?
Tick every answer that is true.
Drive at least 50 cm in a straight line, integrating flow() as you go, and print your own answer as my y: 54.3. It is marked against where the robot really ended up.
from bugbot import * connect() DT = 0.1 y = 0.0 forward(70)
Plan your program here, then type it in and press Run.
clock() and use that instead of the constant. How much does it change?DT = 0.5. Where does the error come from now?