The worksheetDownload the PDF
Answers

U3.4 Calibration

Odometry and drift · University · about 30 min

BugBotLab

What this lesson is about

Measuring the gyro bias and the flow scale, and taking both out of the estimate.

Questions 6 marks in all

  1. [1 mark]A robot is driven exactly 100 cm, and its integrated flow says 96 cm. What scale factor should multiply future readings? Give three decimal places.

    Answer: 1.042 (accept within 0.001). scale = true distance / integrated distance = 100 / 96 = 1.042.
  2. [1 mark]A gyro with a bias of 0.3 deg/s is integrated over five 0.1 s ticks, once raw and once with the bias subtracted. What does this print?

    DT = 0.1
    bias = 0.3
    rates = [0.3, 0.3, 30.3, 30.3, 0.3]
    raw = cal = 0.0
    for r in rates:
        raw += r * DT
        cal += (r - bias) * DT
    print(round(raw, 2), round(cal, 2))
    Answer:
    6.15 6.0

    The robot really turned 30 deg/s for 0.2 s, which is 6 degrees. Raw integration adds 0.3 × 0.5 = 0.15 degrees of bias to give 6.15; the calibrated sum is exactly 6.0.

  3. [1 mark]Why calibrate the gyro before the flow scale?

    1. ACalibrating the scale means driving, and steering with an uncalibrated gyro curves the path and corrupts the distance being measured
    2. BCalibrating the gyro needs the robot to move, so it has to come first while the path is known
    3. CThe order does not matter, because the two errors are independent
    4. DThe flow scale depends on the heading, so it changes after every turn
    Answer: A. Fix the heading, then the distance. The gyro calibration is done standing still, so it needs nothing else to be right first.
  4. [1 mark]What is the name for recalibrating an inertial sensor at every moment the vehicle is known to be still, as a shoe-mounted pedestrian tracker does once per step?

    Answer: zero velocity update. A zero velocity update treats each known stationary moment as a free calibration, which keeps the bias estimate fresh.
  5. [1 mark]Which of these can calibration not fix?

    Tick every answer that is true.

    1. AA gyro bias that drifts with temperature and time
    2. BSlip between the drive and the mat
    3. CErrors the model has no name for
    4. DA constant gyro bias
    5. EA constant flow scale error
    Answer: A, B, C. Calibration subtracts or divides out errors that are constant and modelled. A bias that wanders, slip, and anything unmodelled are left, which is why calibration buys time but does not bound the error.
  6. [1 mark]Why can the flow scale not be calibrated using only the robot's own sensors?

    1. AIt needs a true distance from outside, such as a tape measure, a wall at a known place or a landmark
    2. BThe flow sensor cannot be read while the robot is moving
    3. CThe gyro has to be recalibrated at the same time
    4. DIntegrating flow() twice would give the scale directly
    Answer: A. The robot's own measurement of distance is the thing in doubt, so something else has to say what the true distance was. Calibration always costs an external reference.

The task: a calibrated lap

Calibrate the gyro, then dead reckon at least 120 cm with turns in it. Print bias:, my x: and my y:. The position tolerance is tighter than the uncalibrated task, so the calibration has to be real.

from bugbot import *
import math
connect()

DT = 0.1
# stand still first and learn the bias

The hint students can ask for: Stand still for a few seconds first and average the gyro. Subtract that bias from every turn rate afterwards. The tolerance here is tighter than the uncalibrated task, so the calibration has to be doing real work.

A solution

from bugbot import *
import math
connect()

DT = 0.1

# stand still and learn the gyro's bias
rates = []
for i in range(40):
    rates.append(imu()[1])
    wait(DT)
bias = sum(rates) / len(rates)

x = y = h = 0.0

def step(n=1):
    global x, y, h
    for i in range(n):
        vx, vy = flow()
        rate = imu()[1] - bias
        a = math.radians(h + 0.5 * rate * DT)
        x += (vx * math.cos(a) + vy * math.sin(a)) * DT
        y += (-vx * math.sin(a) + vy * math.cos(a)) * DT
        h += rate * DT
        wait(DT)

forward(75)
step(45)
stop()
step(4)

drive(0, 0, 55)
while h < 88:
    step()
stop()
step(4)

forward(75)
step(45)
stop()
step(4)

print("bias:", round(bias, 2))
print("my x:", round(x, 1))
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.