The answersDownload the PDF
Worksheet

U6.1 Two sources, one state

State estimation · University · about 25 min

BugBotLab
NameClassDate

What this lesson is about

A signal that drifts and a signal that is noisy, and why either alone is worse than both.

Questions 6 marks in all

  1. [1 mark]A complementary filter uses a = 0.98 and dt = 0.1 s. What is its time constant in seconds?

  2. [1 mark]Blending 359 degrees with 1 degree, first naively and then with the wrap. What does it print?

    mine, fused = 359.0, 1.0
    print((mine + fused) / 2)
    f = fused
    while f - mine > 180:
        f -= 360
    while mine - f > 180:
        f += 360
    print(f, ((mine + f) / 2) % 360)
  3. [1 mark]Two ticks of the complementary filter. What does it print?

    A, DT = 0.98, 0.1
    mine = 90.0
    for rate, fused in ((10.0, 95.0), (10.0, 96.0)):
        mine = A * (mine + rate * DT) + (1 - A) * fused
        print(round(mine, 3))
  4. [1 mark]The filter is run with a = 0.7. What goes wrong?

    1. AThe noise on the fused heading comes straight through
    2. BGyro drift is never corrected
    3. CThe heading wraps at 180
    4. DThe filter becomes unstable and diverges
  5. [1 mark]Which statements about the two heading sources are correct?

    Tick every answer that is true.

    1. AThe integrated gyro is smooth but drifts without limit
    2. Bimu()[0] is noisy but does not run away
    3. CThe integrated gyro is noisy but does not drift
    4. Dimu()[0] is smooth but drifts without limit
  6. [1 mark]In frequency terms, what does the complementary filter do to each source?

    1. AHigh pass on the gyro, low pass on the absolute heading, summing to unity gain
    2. BLow pass on the gyro, high pass on the absolute heading
    3. CLow pass on both
    4. DA band pass on the gyro only

The task: a complementary filter

Turn the robot about, running a complementary filter on the heading, plotting gyro, fused and mine, and print my heading: at the end. heading() is the truth and is not allowed, so plot the three headings themselves. They will lie almost on top of each other, which is expected: they differ by a few degrees on a chart that runs to 360.

from bugbot import *
connect()

DT = 0.1
A = 0.98
mine = imu()[0]

Plan your program here, then type it in and press Run.

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

Challenges

  1. Run it at a = 0.7 and a = 0.999 and describe both failures.
  2. Remove the wrapping and turn the robot through north. What happens?
  3. Compare your estimate with heading() afterwards. Which is better, yours or imu()[0] alone?