State estimation · University · about 30 min
The shape every filter has: a model that guesses forward, a measurement that pulls it back.
[1 mark]Put one tick of the lesson's fusion loop in order.
Number the lines 1 to 4 to put them in the right order.
measured = START_GAP - distance()est = 0.9 * est + 0.1 * measuredplot("estimate", est)est += flow()[1] * DTest += flow()[1] * DT
measured = START_GAP - distance()
est = 0.9 * est + 0.1 * measured
plot("estimate", est)Predict with the motion measurement, take the measurement, correct towards it, then plot.
[1 mark]Three ticks of predict and correct with made-up sensor values. What does it print?
DT, START_GAP = 0.1, 110.0
est = 0.0
for speed, d in ((20.0, 107.0), (20.0, 103.0), (20.0, 104.0)):
est += speed * DT
measured = START_GAP - d
est = 0.9 * est + 0.1 * measured
print(round(est, 2))2.1 4.39 6.35
Tick 1 predicts 2, measures 3, and blends to 2.1. Tick 2 predicts 4.1, measures 7, blends to 4.39. Tick 3 predicts 6.39, measures 6, blends to 6.35.
[1 mark]What is measured - est called?
[1 mark]The plotted innovation is consistently positive. What does that say?
[1 mark]Why does predict and correct keep up with a moving robot better than a low pass filter on the distance alone?
[1 mark]The correct step is changed to est = 0.98 * est + 0.02 * measured. What is the filter now trusting?
[1 mark]The robot has no velocity sensor. What does the lesson suggest as the model for the predict step?
Drive at least 40 cm towards the wall, running predict and correct, plotting measured and estimate, and print my y:. position() is not allowed.
from bugbot import * connect() DT = 0.1 START_GAP = 110.0 est = 0.0
The hint students can ask for: Predict with the flow sensor: estimate += flow()[1] * dt. Correct with the wall: the robot started 110 cm from the wall's face, so the depth reading says you have travelled 110 - distance(). Blend the two, and plot both so you can see the noisy one and the steady one together.
from bugbot import *
connect()
DT = 0.1
START_GAP = 110.0 # cm from the robot to the wall's face at the start
est = 0.0
forward(60)
for i in range(70):
est += flow()[1] * DT # predict
measured = START_GAP - distance() # the same quantity, measured
est = 0.9 * est + 0.1 * measured # correct
plot("measured", measured)
plot("estimate", est)
if est > 55:
stop()
wait(DT)
stop()
print("my y:", 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.