State estimation · University · about 35 min
Odometry prediction, a tag as the measurement, and a gain that rises as the estimate ages.
[1 mark]The variance for six ticks, with a tag fix on ticks 3 and 6. What does it print?
Q, R_TAG = 0.6, 9.0
p = 4.0
for tick in range(1, 7):
p += Q
if tick % 3 == 0:
k = p / (p + R_TAG)
p = (1 - k) * p
print(tick, round(p, 2))1 4.6 2 5.2 3 3.53 4 4.13 5 4.73 6 3.35
p climbs by 0.6 per tick to 5.8, a fix cuts it to 5.8 x 9 / 14.8 = 3.53, then it climbs again to 5.33 and drops to 3.35. That is the sawtooth.
[1 mark]Using the lesson's range model R_tag = 4.0 + 0.002 * d * d, what is R for a tag 100 cm away?
[1 mark]The gate accepts a fix when (measured - est) squared is less than 9 * (p + R_TAG). With p = 16 and R_TAG = 9, what is the largest innovation magnitude accepted, in cm?
[1 mark]Why is it useful that this gate widens when the filter is unsure?
[1 mark]U3.5 took a fix by replacing the estimate with the tag's value. Which weaknesses does fusing with a gain fix?
Tick every answer that is true.
[1 mark]Between fixes the robot dead reckons. What does the variance plot show?
Drive at least 80 cm towards tag 4, predicting with flow and correcting once a second while the tag is in view. Plot estimate and variance, and print my y:. No position().
from bugbot import *
connect()
DT, TAG_Y = 0.1, 165.0
Q, R_TAG = 0.6, 9.0
set_cv("apriltag")
est, p = 0.0, 4.0The hint students can ask for: Tag 4 is 165 cm up the mat from the start. Predict with flow and grow the variance every tick; when the tag is in view, correct with 165 minus its distance, using R for a tag fix. Watch the variance sawtooth: climbing between fixes, dropping at each one.
from bugbot import *
connect()
DT = 0.1
TAG_Y = 165.0
R_TAG = 9.0
Q = 0.6
set_cv("apriltag")
est, p = 0.0, 4.0
forward(65)
for i in range(90):
est += flow()[1] * DT
p += Q
seen = [t for t in apriltags() if t[0] == 4]
if seen and seen[0][3] < 130:
measured = TAG_Y - seen[0][3]
k = p / (p + R_TAG)
est += k * (measured - est)
p = (1 - k) * p
plot("estimate", est)
plot("variance", p)
if est > 105:
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.