CrackRobotics

Step 1

Bayes filter

Find the rover in a corridor from a noisy floor sensor: predict with each move, correct with each reading, and watch a many-peaked belief settle on one.

What it computes

A Bayes filter tracks a belief: a probability for every place the robot could be. Here the corridor is cut into N=23N = 23 cells of 5 cm, so the belief is 23 numbers that sum to 1. Each step has two parts.

Predict with the motion. Told to move mm cells, the rover really moves m−1m-1, mm or m+1m+1 with the probabilities in KERNEL, so

bˉ(j)=∑ip(j∣i,m) b(i).\bar b(j) = \sum_i p(j \mid i, m)\, b(i).

The end walls stop it: probability that would leave the corridor stays in the end cell.

Update with the reading zz. The floor sensor says "marker" with probability phitp_{hit} over a marker and pfalsep_{false} elsewhere. Weigh each cell by how likely zz is there, then normalise:

b(j)=p(z∣j) bˉ(j)∑kp(z∣k) bˉ(k)b(j) = \frac{p(z \mid j)\, \bar b(j)}{\sum_k p(z \mid k)\, \bar b(k)}
# predict
new = zeros(N)
for i in range(N):
    for d, p in zip((-1, 0, 1), KERNEL):
        j = clamp(i + move + d, 0, N - 1)      # the walls stop the rover
        new[j] += p * belief[i]
# update
for j in range(N):
    if saw_marker: like[j] = P_HIT if MARKS[j] else P_FALSE
    else:          like[j] = 1 - P_HIT if MARKS[j] else 1 - P_FALSE
belief = like * new / sum(like * new)

Why it works

The start is unknown, so the belief starts flat. The first "marker" raises every marker cell at once: the belief is multimodal, one bump per place that fits. Predict slides and blurs the bumps; update shrinks those whose readings don't fit. The blue strips are 10, 15, 5 and 20 cm long, so soon only one fits.

Every filter in this set is this loop. The Kalman filter runs it on a Gaussian belief (always one bump), the particle filter on a belief made of samples.

The program

It senses, then drives 14 cells forward and 14 back, one wheel-measured cell at a time: predict after each move, update after each reading. The belief is drawn above the corridor and in the Images tab.

Your task

Implement predict(belief, move) and update(belief, saw_marker); each returns the new belief. The grader tests both on fixed beliefs, including next to the walls. Live, the peak must end within one cell of the rover with at least half the probability there.

Goals

  • Program runs without errors
  • predict(belief, move) shifts and blurs the belief like the reference (14 fixed cases, including next to both walls)
  • update(belief, saw_marker) weighs each cell by the sensor likelihood and normalises (10 fixed cases)
  • By the end of the drive, the belief's peak is within one cell (5 cm) of the rover, with at least 50 % of the probability within one cell of it
Loading physics…
Loading 3D view…
0.0 / 0.0 s

Python is loading. It takes a few seconds the first time.