Interactive simulatorBeginner

Robot Sensor Simulator for Calibration and Sensor Fusion

Explore noise, bias, drift, quantization, dropouts, filtering, and fusion in a deterministic interactive robot sensor simulator.

Category
Sensors
Time
60–150 min
Platform
Browser · Microcontroller
Robot Sensor Simulator for Calibration and Sensor Fusion technical schematicSAMPLE → FILTER → FUSE

01 / Start here

Introduction

Robots act on measurements that are delayed, biased, noisy, and incomplete. This project makes those limitations visible. Compare truth, raw samples, and filtered estimates; change sampling conditions; and learn how calibration affects downstream control without mistaking an educational model for a specific sensor.

Live lab / Deterministic measurement model

Robot sensor simulator

Compare a known signal with noisy absolute readings and a filtered estimate. Change one error source at a time to see what calibration can—and cannot—fix.

Browser native
This simulator compares truth, absolute samples, and the selected estimate over time. Use the controls below to run it, or read the theory and algorithm after this lab.

The main plot compares solid truth, individual absolute-sensor samples, and the thicker dashed estimate. The lower band shows signed estimation error around zero; gaps mark dropped absolute samples.

Simulation

Paused. Press Start or Step to collect samples.

Measurement
Reliability & filtering
Truth
Absolute
Estimate
Error
RMSE
Dropped
0

Keyboard: focus the plot, then use Space to run/pause, N to step, R to reset, and F for full screen.

Controls

Choose a smooth or stepped truth signal, then adjust sample rate, quantization, random noise, drift, bias, dropouts, and filter memory. Compare raw data with moving-average, low-pass, median, and complementary estimates. Presets make noisy, biased, and unreliable sensor behavior repeatable.

Theory

Every sensor has a measurement range, resolution, accuracy, bandwidth, latency, and failure behavior. Datasheet accuracy describes only part of the system; mounting, temperature, supply noise, electromagnetic interference, and surface properties often dominate real results.

Fusion works when sensors contribute complementary information and their uncertainty is represented honestly. Combining two biased measurements does not automatically create truth. Start with calibration, timestamps, coordinate frames, and data-quality checks.

Time plot comparing a smooth true signal, noisy raw samples scattered around it, and a low-pass filtered estimate. The filtered line rejects most of the noise but visibly lags behind the truth during the fast rise.
A low-pass filter trades noise for lag: it smooths the raw samples toward the truth, but the estimate falls behind whenever the signal changes quickly. Download SVG

Algorithm

  1. Timestamp and range-check every sample at the acquisition boundary.
  2. Convert raw units using calibration scale, offset, and axis alignment.
  3. Reject impossible jumps or mark them invalid instead of inventing data.
  4. Apply the lightest filter that meets the downstream noise requirement.
  5. Transform measurements into a common frame and fuse them using known uncertainty.
  6. Log raw and processed values so failures remain reproducible.

Source code

An exponential low-pass filter is useful when its time constant is chosen deliberately:

class LowPass:
    def __init__(self, alpha):
        self.alpha = alpha
        self.value = None

    def update(self, sample):
        if self.value is None:
            self.value = sample
        else:
            self.value += self.alpha * (sample - self.value)
        return self.value

Record the raw sample beside the filtered result. Otherwise an attractive plot can hide clipping, dropouts, and calibration errors.

Circuit diagram

Confirm bus voltage, pull-up requirements, addresses, and maximum cable length before connecting multiple sensors.

Block diagram of a mixed sensor bus. An analog sensor reaches the controller through an ADC, I²C sensors share SDA and SCL lines, and an SPI sensor uses chip-select, clock, and data lines. The controller writes a timestamped log.
Different sensor buses converge on one controller, which timestamps every sample so raw and processed values stay reproducible. Download SVG

Hardware checklist

Components

  • Microcontroller or single-board computer
  • One or more digital or analog sensors
  • Known calibration references
  • Stable regulated supply and correct logic levels
  • Logging connection for repeatable experiments

Continue building

Download resources

Use these on-page references while working through the project. Downloadable project bundles will be added only after their source and version are published.

Common questions

Frequently asked questions

Is a smoother signal always a better signal?

No. Strong filtering can remove useful motion and introduce delay. Choose a filter from the noise spectrum, required response time, and the decisions that consume the measurement.

What is the difference between bias and noise?

Bias is a repeatable offset from the true value, while noise varies between samples. Calibration can estimate bias; averaging or filtering may reduce random noise but cannot reliably remove an unknown bias.

What is sensor drift, and how is it different from bias?

Bias is a fixed offset you can measure once and subtract. Drift is a slow change in that offset over time, usually with temperature or component aging, so a calibration taken at startup gradually stops matching reality. Drift is why long runs need periodic recalibration or a reference the estimator can correct against.

Which filter should I use: moving average, low-pass, or median?

A moving average and an exponential low-pass both smooth Gaussian-style noise, trading responsiveness for smoothness through their window or time constant. A median filter is better at removing occasional spikes and dropouts because a few bad samples do not move the middle value. Pick the lightest filter that meets the downstream requirement rather than the smoothest-looking one.

How much delay does filtering add?

Every smoothing filter lags the true signal, and more smoothing means more lag: a low-pass filter with a long time constant rejects more noise but falls further behind fast changes. Always plot the filtered estimate against the raw samples and the truth so the lag is visible before you rely on it in a control loop.

What is sensor fusion and when does it actually help?

Fusion combines multiple sensors into one estimate, and it helps only when the sensors contribute complementary information and their uncertainty is represented honestly. Combining two biased measurements does not create truth. A complementary filter, for example, trusts one sensor at high frequencies and another at low frequencies; start with calibration, timestamps, and coordinate frames before fusing.

Why should every sample be timestamped?

Samples rarely arrive at a perfectly fixed interval, and fusion and filtering assume you know when each value was measured. Timestamps let you detect jitter, align data from different sensors, and reject stale readings. Logging raw values beside processed ones keeps failures such as clipping, dropouts, and calibration errors reproducible.

Further reading

References

Authoritative sources for going deeper than this simulator's bounded educational model.