The worksheetDownload the PDF
Answers

U7.3 Moving the cloud

Localisation · University · about 30 min

BugBotLab

What this lesson is about

The motion update: every particle drives, and every particle's own error goes with it.

Questions 6 marks in all

  1. [1 mark]A motion update moves every particle by the measured motion with no random term. What goes wrong?

    1. AThe cloud keeps its shape for ever, so the filter claims to be as certain after ten metres as at the start
    2. BThe cloud spreads without limit and the estimate becomes vague
    3. CThe particles drift away from the robot's true motion
    4. DThe weights stop summing to one
    Answer: A. The random part is the filter's honest statement that dead reckoning is losing accuracy. Without it the spread never grows.
  2. [1 mark]The noise added per step is much smaller than the robot's real motion error. What is the likely result?

    1. AAn over-confident cloud that shrinks onto a wrong answer and refuses to be corrected
    2. BA vague estimate because the cloud spreads faster than readings can pull it in
    3. CExactly the same estimate, since the measurement update corrects it every tick
    4. DThe effective sample size rises towards N
    Answer: A. Too little noise gives over-confidence; too much gives vagueness. The check is whether the truth stays inside the cloud.
  3. [1 mark]Each particle gets independent noise with standard deviation 0.35 cm per step. After 40 steps, what spread (standard deviation) should the cloud have, in cm to two decimal places?

    Answer: 2.21 (accept within 0.01). Independent errors add in variance, so the spread is 0.35 x sqrt(40) = 0.35 x 6.32 = 2.21 cm, the random walk from U3.3.
  4. [1 mark]You double the per-step noise standard deviation. What happens to the spread of the cloud after 5 seconds?

    1. AIt doubles
    2. BIt quadruples
    3. CIt grows by a factor of sqrt(2)
    4. DIt stays the same, because it depends only on the number of steps
    Answer: A. The spread after n steps is sigma x sqrt(n), which is proportional to sigma. The variance quadruples, the standard deviation doubles.
  5. [1 mark]A Kalman filter for the same robot would use a process noise Q of 0.16 cm squared per step. What standard deviation, in cm, is a reasonable starting point for the per-particle motion noise?

    Answer: 0.4 (accept within 0.001). Q is a variance; particle noise is drawn with a standard deviation, so take sqrt(0.16) = 0.4 cm.
  6. [1 mark]Which of these belong in the motion update of a particle filter?

    Tick every answer that is true.

    1. ASpeed proportional to the command, with a dead band
    2. BMore error when turning than when driving straight
    3. CRemoving any particle that would pass through a wall
    4. DWeighting each particle by how well it predicts the distance reading
    Answer: A, B, C. Anything known about how the robot moves goes in the motion update, and killing impossible particles costs one line. Weighting against a reading is the measurement update.

The task: move the cloud

Start every particle at zero, move them with the flow sensor plus their own noise as the robot drives at least 40 cm, plot mean y and spread y, and print both at the end.

from bugbot import *
import random
connect()

DT, N = 0.1, 300
ys = [0.0] * N

The hint students can ask for: Start every particle at zero. Each tick, move every one of them by the measured flow, plus a small random amount of its own. The cloud tracks the robot and slowly spreads, which is dead reckoning uncertainty made visible.

A solution

from bugbot import *
import random
connect()

DT = 0.1
N = 300
ys = [0.0] * N

forward(70)
for i in range(60):
    v = flow()[1]
    ys = [y + v * DT + random.gauss(0, 0.35) for y in ys]
    mean = sum(ys) / N
    spread = (sum((y - mean) ** 2 for y in ys) / N) ** 0.5
    plot("mean y", mean)
    plot("spread y", spread)
    wait(DT)
stop()
mean = sum(ys) / N
spread = (sum((y - mean) ** 2 for y in ys) / N) ** 0.5
print("mean y:", round(mean, 1))
print("spread y:", round(spread, 2))

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.