The answersDownload the PDF
Worksheet

U3.1 Integrating velocity

Odometry and drift · University · about 25 min

BugBotLab
NameClassDate

What this lesson is about

The odometry update, one step at a time, and what the step size costs you.

Questions 6 marks in all

  1. [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))
  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?

  3. [1 mark]When do the trapezium rule and Euler integration give the same answer?

    1. AOnce the speed is steady
    2. BWhile the robot is speeding up
    3. COnly when the step is very small
    4. DNever, because the trapezium rule always averages two readings
  4. [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?

  5. [1 mark]Why does assuming the loop period, rather than measuring it with clock(), cause an error that grows through the run?

    1. AThe real period is always at least the wait, so every step is short the same way and the errors add up
    2. BAssumed periods are noisy, and noise adds up as a random walk
    3. Cclock() drifts less than wait(), so it is only needed on long runs
    4. DThe flow sensor's scale changes if the period is not exact
  6. [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.

    1. AThe reading is one instant, used as the average over the step
    2. BThe flow reading has noise and a scale a few percent off
    3. CThe loop period is not exactly the 0.1 s it is multiplied by
    4. DThe deadman stops the robot between readings
    5. Eposition() is only accurate to a few centimetres

The task: integrate a velocity

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.

QR code
Do it on the robot
www.bugbotlab.com/learn/u3-1-integrating-velocity/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Do the same run with the trapezium rule and compare the two estimates against the truth.
  2. Measure the real loop period with clock() and use that instead of the constant. How much does it change?
  3. Integrate with DT = 0.5. Where does the error come from now?