Engineering mission · M-006
The Unreliable Sensor
Two distance sensors disagree, and a third reading looks impossible. Decide what the robot should believe, and how sure it can be.
About 1.5 h · advanced · 6 steps · Uses Lab 03 · Free
The situation
A warehouse robot measures its distance to a shelf before reaching in to pick a box. It has two distance sensors pointing at the same shelf. Sensor A is cheap and noisy: from repeated tests against a known distance, its readings scatter with a standard deviation of σ = 4.0 cm. Sensor B is better: σ = 2.0 cm. Neither has a known offset.
At one moment, Sensor A reads 102.0 cm and Sensor B reads 96.0 cm. The robot needs one number for the distance, and an honest statement of how uncertain it is, because it will only reach in if it is confident it is within 2 cm of the right distance.
Then a moment later a third reading arrives from a spare sensor, Sensor C (σ = 3.0 cm): 130.0 cm.
Your task is to design the robot's rule for combining readings and rejecting bad ones. You will compute the best combined estimate from A and B, decide whether to trust C, and then write a general rule that would work for any readings, not just these. The numbers have exact answers; the rule is a design choice with several good options, and you will be judged on how well yours is reasoned.
You will learn to
- Combine independent measurements with inverse-variance weighting.
- Compute the uncertainty of a combined estimate and explain why it is smaller than either input.
- Use averaging and the σ/√n rule to compare a cheap sensor with a better one.
- Design an outlier-rejection rule and explain its trade-offs.
Constraints
- C1Assume each sensor's errors are independent, random and unbiased, with the σ values given.
- C2The robot reaches in only if the combined σ is at most 2 cm.
- C3Your rejection rule must work for any number of sensors and any readings, not just this example.
- C4Show the arithmetic for every numeric answer.
Background
Why weight readings?
If two sensors are equally good, the sensible estimate is their average. If one is much noisier, it should count for less. Inverse-variance weighting gives each reading a weight w = 1 / σ²: halving a sensor's σ makes its weight four times larger.
estimate = (w1 · z1 + w2 · z2) / (w1 + w2)
σ_estimate = √(1 / (w1 + w2))This assumes the sensors' errors are independent, random and unbiased. Under those assumptions, it gives the most precise combination possible from these two readings.
Worked example (not the mission data)
Two sensors read 40.0 cm (σ = 1.0 cm) and 43.0 cm (σ = 2.0 cm). The weights are 1 / 1² = 1 and 1 / 2² = 0.25.
- Estimate = (1 × 40.0 + 0.25 × 43.0) / 1.25 = (40.0 + 10.75) / 1.25 = 40.6 cm.
- σ = √(1 / 1.25) = √0.8 ≈ 0.89 cm.
The estimate sits much closer to the better sensor, and its uncertainty is smaller than either sensor's alone.
Here is the same idea in Python, checked on two equally good readings:
import math
def fuse(readings):
"""readings: list of (value, sigma). Returns the inverse-variance estimate and its sigma."""
weights = [1 / s ** 2 for _, s in readings]
estimate = sum(w * v for w, (v, _) in zip(weights, readings)) / sum(weights)
return estimate, math.sqrt(1 / sum(weights))
# Worked example from the background (not the mission data)
est, sigma = fuse([(50.0, 3.0), (53.0, 3.0)])
print(f"estimate {est:.2f} cm, sigma {sigma:.2f} cm")estimate 51.50 cm, sigma 2.12 cmFor two equal sensors the estimate is the plain average, and σ falls by a factor of √2: 3.0 / √2 ≈ 2.12 cm.
Averaging repeated readings
Averaging n independent readings from one sensor reduces σ to σ / √n. To halve the noise you need four times as many readings, which costs time.
Spotting a reading that does not belong
Two readings agree reasonably if their difference is small compared with the uncertainty of that difference. For independent readings, the difference has σ = √(σ1² + σ2²). A difference of more than about 3 of these σ is very unlikely from noise alone, so it suggests a fault, a reflection or the sensor seeing a different object. Rejecting readings is a trade-off: too strict and you throw away real changes, too loose and one bad reading corrupts the estimate.
Lab 03 · Sensor fusion
Explorer 03 — Sensor fusion
Two imperfect sensors, one better estimate
- True position
- Camera reading
- Odometry dead-reckoning
- Fused (Kalman)
- ±2σ uncertainty
- Camera dropout
Camera · absolute, drops out
Long-run share of time with no view, in bursts of about 1.2 s (occlusions).
Odometry · relative, drifts
A constant error in measured speed: its position estimate drifts by bias × time.
More controls
The Kalman filter weights each sensor by its stated noise, tracks its own uncertainty, and estimates the odometry bias while the camera can see.
Show
Root-mean-square error vs truth · lower is better
- Camera aloneholds last reading in dropouts7.9 cm
- Odometry alonedead reckoning from start15.1 cm
- Kalman filterfused estimate0.9 cm
- Fused, in dropoutsonly samples with no camera1.1 cm
Camera coverage 60 %. Camera error only over frames it saw: 2.9 cm (≈ its σ).
State
Seed 7. The camera saw the target 60 % of the time in 4 dropouts. Error (RMSE): camera alone 7.9 cm holding its last reading, odometry alone 15.1 cm, kalman filter 0.9 cm (1.1 cm during dropouts). Fusion is 88 % better than the better single sensor. Estimated odometry bias 1.53 cm/s (true 1.50).
Seed 7. The camera saw the target 60 % of the time in 4 dropouts. Error (RMSE): camera alone 7.9 cm holding its last reading, odometry alone 15.1 cm, kalman filter 0.9 cm (1.1 cm during dropouts). Fusion is 88 % better than the better single sensor. Estimated odometry bias 1.53 cm/s (true 1.50).
How to read this
Time runs left to right over 20 seconds. The thin solid line is where the object really is. Crosses are camera readings; hatched columns are dropouts where the camera sees nothing. The dashed line is odometry integrated from the start: smooth, but it wanders away as its bias accumulates. The thick line is the fused estimate, with a shaded ±2σ band showing how uncertain the Kalman filter believes it is. The band widens during each dropout and snaps back when the camera returns.
This mirrors Tactiverge's research question: when vision drops out, can local sensing such as force and joint feedback carry the estimate until it returns?
Assumptions & limitations
- One dimension, a smooth known trajectory and a single object: real tracking is 3-D, with orientation, multiple objects and data association.
- Noise is white Gaussian with the σ you set, and the Kalman filter is told the true σ values. Real filters must be tuned against noise they can only estimate.
- Odometry error is a constant bias plus white noise; real drift also comes from slip, scale-factor error and temperature.
- Dropouts are random bursts, independent of where the object is. Real occlusions often happen exactly when the task gets hard, for example when a gripper covers the object.
- The camera has no latency and runs at the same 20 Hz as odometry; real cameras are slower and delayed, which the filter would have to compensate for.
- Figures are from one seeded run of 401 samples; change the seed to see how much the numbers vary by chance.
How to approach it
- 01
Check the two readings agree
Before combining A and B, check they are consistent. Compute their difference and the σ of that difference, √(4.0² + 2.0²). How many σ apart are they? Is that plausible from noise alone?
- 02
Combine A and B
Compute the weights, the inverse-variance estimate and its σ. Check your answer with the
fusefunction. Can the robot reach in, given the 2 cm requirement? - 03
Compare averaging with a better sensor
How many readings of Sensor A would you need to average to match Sensor B's σ of 2.0 cm? What would that cost the robot in time if each reading takes 50 ms? When might the cheaper sensor plus averaging be the better design, and when not?
- 04
Decide about Sensor C
Compare Sensor C's 130.0 cm reading with your combined A and B estimate, using the σ of the difference. Decide whether to include it. Then think about what physical causes could produce such a reading, and whether the robot should do anything besides ignore it.
- 05
Write a general rule
Write a rule, in steps or pseudocode, that takes any set of readings with their σ values, rejects ones that do not belong and returns an estimate with its σ. Say what it does if only one reading is left, or if two readings disagree with each other and there is no third to break the tie.
- 06
Connect to a moving robot
Open the sensor fusion explorer. The Kalman filter there uses the same weighting idea, but over time. Raise the camera noise and watch how the fused estimate leans more on odometry. Write two sentences connecting what you see to your weighting calculation.
Your work
Everything above is free to read and use. To save drafts, submit versions and get feedback, sign in.
You can also work on paper: the prompts below are what a submission asks for.
- Inverse-variance estimate from Sensors A and B (cm)
- σ of the combined estimate (cm)
- Readings of Sensor A to average to match Sensor B's σ
- Decision about Sensor C
- General combination and rejection rule
- When the method breaks
How it's judged
There is more than one good answer. This rubric describes what strong work looks like.
Combining measurements
- Beginning
- Uses a plain average or an incorrect weighting.
- Developing
- Correct weights but an arithmetic error, or σ of the estimate missing.
- Proficient
- Correct estimate and σ, with the arithmetic shown and the reach-in decision made.
- Exemplary
- As Proficient, plus explains why the combined σ is smaller than either input and what would change if the errors were correlated.
Consistency and outliers
- Beginning
- Sensor C is accepted or rejected without calculation.
- Developing
- A calculation is made but uses the wrong σ for the difference.
- Proficient
- Consistency of A and B and the outlier status of C are both checked with the σ of the difference.
- Exemplary
- As Proficient, plus physical causes of the outlier are considered and the robot's response goes beyond simply ignoring it.
General rule design
- Beginning
- No general rule, or one that only works for these numbers.
- Developing
- A general rule without edge cases or a justified threshold.
- Proficient
- A clear rule with a justified threshold and handling of the one-reading and two-disagreeing cases.
- Exemplary
- As Proficient, plus the rule avoids being dragged by the outlier it is testing, for example by comparing each reading with the others' combination.
Engineering trade-offs
- Beginning
- Averaging versus a better sensor is not discussed.
- Developing
- The number of readings is found but time cost is not considered.
- Proficient
- Time cost is calculated and a reasoned choice made between averaging and a better sensor.
- Exemplary
- As Proficient, plus the student identifies when averaging fails, such as when the target moves or errors are not independent.
Reflect
- Before calculating, where did you expect the combined estimate to land? Why did it land where it did?
- Why is rejecting a reading a design decision and not just a calculation?
- What would make you distrust the σ values you were given?
Go further
Suppose Sensor A actually has an unknown constant offset of a few centimetres. Design a short calibration procedure using a known reference distance, and explain how the offset, if ignored, would bias the combined estimate even though its reported σ looks small.