The answersDownload the PDF
Worksheet

U4.7 Project: hold the gap

Noise and filtering · University · about 40 min

BugBotLab
NameClassDate

What this lesson is about

Sit 25 cm from a wall, steadily, on a depth sensor that is 3 cm noisy.

Questions 6 marks in all

  1. [1 mark]The gap controller runs for three ticks with no robot. What does it print?

    TARGET, ALPHA = 25.0, 0.3
    gap = 40.0
    for raw in (37, 34, 31):
        gap = ALPHA * raw + (1 - ALPHA) * gap
        error = gap - TARGET
        if abs(error) < 1.0:
            cmd = 0
        else:
            cmd = max(-45, min(45, 2.2 * error))
        print(round(gap, 2), round(cmd, 1))
  2. [1 mark]With TARGET = 25, a dead band of 1 cm and gain 2.2, what drive command is sent when the filtered gap is 25.6 cm?

  3. [1 mark]The plot of the gap shows a slow sine wave around 25 cm. What does the lesson say to change?

    1. ATurn down the gain or the filter delay
    2. BRaise the gain
    3. CRemove the dead band
    4. DStart the filter at zero
  4. [1 mark]The robot settles at 27 cm and stays there. What is this, and where is the proper fix?

    1. AA steady state error from a dead band; the integral term in U5.4
    2. BSensor bias; more filtering
    3. CFilter delay; a smaller alpha
    4. DNoise; a median filter
  5. [1 mark]The chart holds 25 cm, but a ruler shows the robot is nearer the wall. What does the lesson say is happening?

    1. AThe estimate is biased, and a biased estimate never shows on the chart
    2. BThe dead band is too wide
    3. CThe gain is too low
    4. DThe loop period is too long
  6. [1 mark]Why is a 1 cm dead band not really a cost on this robot?

    1. AThe sensor has 3 cm of noise, so settling within 1 cm is already better than a single reading can resolve
    2. BThe dead band removes the filter delay
    3. CThe dead band makes the steady state error zero
    4. DThe motors cannot move less than 1 cm

The task: hold the gap

Settle 25 cm from the wall and stay there. The checker watches the last part of the run as well as the end, so hunting fails even if the final position is right.

from bugbot import *
connect()

TARGET = 25.0

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

QR code
Do it on the robot
www.bugbotlab.com/learn/u4-7-project-hold-the-gap/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Remove the filter and run it again. Plot both and put the charts side by side.
  2. Set alpha to 0.03 and find the gain at which it oscillates. Compare that with the gain at alpha 0.3.
  3. Hold the gap while the wall is approached from the other side, starting too close. Does the same controller work in both directions?