No description
- Python 76.2%
- JavaScript 15.8%
- CSS 4.2%
- HTML 3.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
- Switch ranging noise from uniform to Gaussian (sigma parameter) - Add sigma field to RangeEstimate for measurement uncertainty - Add outlier rejection to multilateration solver (3-sigma threshold, iteratively removes worst residual and re-solves) - Add KalmanFilter class: 6D constant-velocity filter in ENU frame with anisotropic process noise (separate horizontal/vertical) - Integrate Kalman filter into Client.estimate_position() (use_filter=True) - Add filtered_velocity() to Client for motion estimation from filter - Pass dt through Simulation.run_round() and World.advance() for filter prediction - Add matrix helpers: _mat_mul, _mat_transpose, _mat_add, _mat_sub, _identity, _solve_linear - Fix Motion.bearing_uncertainty type to float | None - Update tests for Gaussian noise statistics - Add tests for outlier rejection and Kalman filter behavior Horizontal RMS error improved 16-25% with filtering enabled. |
||
| src/tofdr | ||
| tests | ||
| .gitignore | ||
| pyproject.toml | ||
| README.md | ||
| requirements.txt | ||
tofdr
Beacon ranging simulation with a web UI. A client moves at a set speed and bearing while fixed beacons measure their distance to it with uniform noise. The client periodically multilaterates its position from the latest range estimates (least-squares Gauss-Newton, minimum 4 beacons) and reports a 1-sigma position uncertainty. The web app shows the real and estimated client, track histories, and an uncertainty bubble on a top-down map.
Setup
Requires Python 3.10+.
source .venv/bin/activate
pip install -e ".[dev]"
Running the web app
python -m tofdr.webapp
Then open http://localhost:8000 (served on 127.0.0.1 only). The simulation runs server-side; the browser steps it at ~10 Hz and redraws the map.
Using the UI
Simulation panel (each change restarts the world):
| Control | Meaning | Default |
|---|---|---|
| beacon estimate rate | how often each beacon produces a range estimate (Hz, fractional) | 2 |
| client report rate | how often the client computes a position fix (Hz; may exceed the beacon rate) | 5 |
| client speed | real client speed (m/s) | 1.5 |
| client direction | bearing in degrees clockwise from north | 90 |
| ranging noise | uniform noise added to each beacon's distance (± m) | 5 |
Beacons panel:
- Number of beacons (1-32); new beacons are placed on a ring of radius 200 m around the start point. Position estimation needs at least 4 beacons — otherwise a warning is shown and no estimate is drawn.
- Each beacon's x (east), y (north), and altitude (meters above ground) can be edited in the table, or the beacon can be dragged directly on the map. Altitude spread matters: a couple of high beacons give the solver vertical information.
Map and readout:
- Green dot: real client; gray line: true track.
- Orange dot: estimated client; dashed orange line: estimate track; filled bubble: 2-sigma horizontal uncertainty, outline: 1-sigma.
- Blue squares: beacons (labeled
b1,b2, ...). - Readout above the map shows the current horizontal error, sigma horizontal, sigma vertical, and the rate configuration.
- The view auto-fits and only expands; it recenters on the next config change.
- Pause/Resume freezes the simulation; Reset restarts with the current settings.
HTTP API
The UI is a static page over a small JSON API:
GET /api/state— current world state (beacons, true/estimated position, tracks, error, config).POST /api/config— replace the world. Body:{"beacons": [{"x", "y", "alt"}, ...], "beacon_rate", "report_rate", "speed", "bearing", "noise"}; omittingbeaconsusesn_beaconson the default ring. Invalid values fall back to defaults.POST /api/step— advance the world by{"dt": seconds}(capped at 5 s) and return the new state.
Tests
pytest