State estimation · University · about 30 min
The two numbers you actually choose, what they mean, and how to measure them.
[1 mark]Standing still, a depth sensor's readings have a standard deviation of 3 cm. What R should the filter use?
[1 mark]The robot can slip about 0.3 cm in one tick without the model knowing. Using the lesson's rough rule, what is Q?
[1 mark]Q is doubled and R is doubled. What happens to the Kalman gain?
[1 mark]Q is set far too small. How does the filter fail?
[1 mark]The normalised innovation squared for four fixes, with p + R = 25 each time. What does it print?
innovations = [3.0, -6.0, 4.0, -2.0] S = 25.0 nis = [v ** 2 / S for v in innovations] print(nis) print(round(sum(nis) / len(nis), 2))
[0.36, 1.44, 0.64, 0.16] 0.65
The squares 9, 36, 16 and 4, over 25, average 0.65. It should be about 1, so this filter is claiming somewhat more uncertainty than it has and could be tuned tighter.
[1 mark]A filter's running average of the normalised innovation squared is about 4. What does it mean?
[1 mark]Why is Q = 0 always wrong on a real machine?
Standing still, measure R and print it as measured r:. Then run the filter at two or three values of Q and print what each does.
from bugbot import * connect() readings = []
The hint students can ask for: R is measurable: stand still, take a hundred readings, and square the standard deviation. Q is a statement about how much the state can change between ticks that your model does not know about. Print R, then try two or three values of Q and say what each does.
from bugbot import *
connect()
DT = 0.1
readings = []
for i in range(100):
readings.append(distance())
wait(DT)
mean = sum(readings) / len(readings)
R = sum((v - mean) ** 2 for v in readings) / len(readings)
print("measured r:", round(R, 1))
for Q in (0.01, 1.0, 100.0):
est, p = readings[0], 100.0
for v in readings:
p += Q
k = p / (p + R)
est += k * (v - est)
p = (1 - k) * p
print("Q", Q, "settles at gain", round(p / (p + R), 3), "estimate", round(est, 1))
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.