Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/navigation-lab.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Navigation Lab
on:
pull_request:
paths: ['tools/navigation-lab/**', '.github/workflows/navigation-lab.yml']
push:
branches: [main]
paths: ['tools/navigation-lab/**', '.github/workflows/navigation-lab.yml']
permissions:
contents: read
jobs:
simulate:
runs-on: ubuntu-latest
strategy:
matrix:
rust: ['1.75.0', 'stable']
defaults:
run:
working-directory: tools/navigation-lab
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- run: cargo test --locked --offline
- run: cargo run --release --locked --offline -- evaluate > evaluation.json
- uses: actions/upload-artifact@v4
with:
name: navigation-evidence-${{ matrix.rust }}
path: tools/navigation-lab/evaluation.json
62 changes: 62 additions & 0 deletions docs/adr/ADR-175-rust-navigation-lab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# ADR-175: Independently implemented Rust navigation simulation lab

Status: Proposed

## Context

The fleet project needs reproducible evidence for per-vehicle navigation before
adopting a real navigation backend. Its current simulated flight controller
immediately applies positions. Its RRT/APF implementation has an unchecked direct
fallback and does not continuously validate segments. A convincing animation
alone would not resolve these limitations.

The external PX4/ROS 2 navigation project informed feasibility discussions. Its
public documentation was reviewed, so this implementation must not be described
as a strictly isolated clean-room effort. No code from that project is included.

## Decision

Add an isolated, dependency-free crate in `tools/navigation-lab`. It builds with
Rust 1.75 or newer without resolving the fleet crate's optional GPU and git
dependencies. Maintain the root package's runtime and API unchanged in this PR.

Inputs are a typed scenario and a u32 seed. Outputs are a bounded route, a Rust
kinematic trace, terminal outcome, validation counts, and measured search time.
Assumptions are exact localization, known synthetic geometry, one vehicle,
instant fault detection at the next simulation tick, and constant braking ability.

Use deterministic A*, conservative expanded-box segment checks, and rest-to-rest
trapezoidal segments. Bound search at 9,216 expansions. Unknown volumes block
routes. Every failure is explicit, with no unchecked straight-line fallback.
The JavaScript visualizer consumes traces; it never supplies flight commands or
reimplements motion. A local HTTP binary embeds assets and prohibits arbitrary
file access, command execution, cross-origin access, and non-local Host headers.

The initial renderer uses projected 3D geometry on Canvas 2D to work on the ruOS
desktop's software renderer without WebGL, a GPU, downloads, or npm dependencies.

## Acceptance evidence

1. Unit tests cover thin barriers, tangent collision, nonfinite inputs, budget
exhaustion, no-route failure, unknown volumes, deterministic replay, and braking.
2. Twenty seeds across five scenarios must yield 20 arrivals and 80 expected holds,
zero detected collisions/geofence/dynamics violations, and zero terminal speed.
3. The browser must display the Rust trace, allow replay and scenario selection,
and show an explicit unavailable state if the engine cannot be reached.
4. Record release-build planning p50/p95/max with host details. Do not conflate
this with sensor-to-actuator timing, real-time guarantees, or flight readiness.

## Subsequent gates

* Fix the root planner's unchecked fallback and continuously validate its edges;
cover all callers' handling of no-route before changing its contract.
* Introduce a reviewed navigation-provider interface, coordinate frame contracts,
bounded timestamps, mission receipts, and one owner of PX4 setpoint publication.
* Add online occupancy evidence, sensor/pose uncertainty, and dynamic-obstacle
stopping margins. Faults must cover localization failures and actuator lag.
* Validate PX4 SITL, then hardware-in-the-loop and device-specific resource budgets.
* Preserve LatentMesh and forecasting as advisory inputs without arming authority.

Aircraft integration remains a separate reviewed change. Passing this lab's tests
does not validate flight safety or establish equivalence with an upstream system.

3 changes: 3 additions & 0 deletions tools/navigation-lab/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target/
/runs/

7 changes: 7 additions & 0 deletions tools/navigation-lab/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions tools/navigation-lab/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "ruv-navigation-lab"
version = "0.1.0"
edition = "2021"
rust-version = "1.75"
license = "Apache-2.0"
publish = false
description = "Bounded civilian navigation simulation and trace visualizer; no flight authority"

# Deliberately isolated from optional fleet/GPU dependencies. Builds offline.
[workspace]

[profile.release]
opt-level = 3
lto = "thin"
codegen-units = 1

81 changes: 81 additions & 0 deletions tools/navigation-lab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Rust Navigation Lab

A dependency-free Rust navigation simulator with an interactive browser visualizer.
This is a civilian research prototype, not an aircraft controller or an equivalent
replacement for a PX4/ROS 2 stack. It has no flight authority.

## Run on the ruOS development desktop

```sh
cd tools/navigation-lab
cargo test --locked --offline
cargo run --release --locked --offline -- serve
```

Open <http://127.0.0.1:8777> on that desktop. Select a scenario and seed, generate
the trace, drag to orbit, scroll to zoom, scrub the timeline, or download JSON.
The viewer renders Rust-produced positions and velocities. It does not implement
a second planner in JavaScript. The route is drawn as an x-ray overlay so it
remains visible behind structures. Rendering is capped at 30 Hz and pixel ratio
1.5 for software-rendered remote desktops, and pauses when the tab is hidden.

On Linux, `bash launch.sh` builds and starts the server if needed, then opens the
browser. `bash launch.sh --server-only` skips the browser. The launcher requires
Cargo, curl, and xdg-open; no npm installation is needed.

The server accepts only loopback connections, validates Host and Origin, limits
headers and read time, serves an exact embedded file allowlist, and exposes only
read-only simulation endpoints. No external CDN, credentials, file browsing,
shell execution, autopilot commands, or CORS access. This tiny development HTTP
server is not suitable for public deployment. One slow local client can briefly
delay others; request timeouts bound that delay.

## What is implemented

* A deterministic six-connected 3D A* search over 9,216 bounded cells.
* Continuous segment/AABB clearance checks with a 0.35 m vehicle radius and
0.40 m extra margin, including endpoint and shortcut validation.
* Explicit no-route, invalid-endpoint, and search-budget failures. No unvalidated
direct-route fallback. Unknown volumes are excluded from traversable space.
* Analytic trapezoidal motion, at most 3 m/s and 2 m/s². The vehicle stops at each
route corner. Sensor expiry and link failure trigger bounded braking on the
validated segment followed by a hold.
* Five seeded scenarios: inspection, blocked volume, stale evidence, command link
loss, and unknown volume. Geometry varies with the seed.
* JSON traces, repeatable replay, 100-scenario evaluation, security unit tests,
and measured planning latency. Wall-clock timings are not deterministic.

## Reproduce evidence

```sh
cargo run --release --locked --offline -- evaluate > evaluation.json
cargo run --release --locked --offline -- run inspection 42 > inspection-42.json
cargo run --release --locked --offline -- run stale 42 > stale-42.json
```

The 100 scenarios comprise 20 seeds times five scenarios. Expected outcomes are
20 arrivals and 80 safety holds, not 100 completed missions. Acceptance checks
each swept motion segment, geofence containment, velocity, acceleration, terminal
velocity, and the expected outcome. Fixed fault injection begins at 3 seconds;
sensor expiry is 600 ms, with up to one 50 ms tick of detection quantization.

The planner's p95 is measured on the host running the binary and is not a control
loop or sensor-to-actuator latency. Run optimized builds for performance evidence.
Both no-route and successful searches contribute to the aggregate percentile.

## Scope and provenance

Authored independently using standard A*, closed-slab collision intersection,
and trapezoidal velocity profiles. No upstream navigation source was copied.
The author reviewed upstream public documentation during feasibility assessment,
so this is **not represented as a legally isolated clean-room implementation**.

All geometry is synthetic and known at startup. Unknown space is represented as
an excluded box; there is no online occupancy mapping, lidar model, localization,
wind, attitude dynamics, moving obstacle model, ROS 2 bridge, PX4 SITL connection,
multi-vehicle separation, or physical aircraft validation. Sensor age and command
link failures are simulated events, not real telemetry. This lab is isolated from
the root fleet crate; it does not repair or replace the root RRT/APF planner.

See [the architecture decision](../../docs/adr/ADR-175-rust-navigation-lab.md)
for the integration and validation gates before any aircraft-facing adapter.
52 changes: 52 additions & 0 deletions tools/navigation-lab/VALIDATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Initial validation record

Source tested: `77a65171e4198fe8aba8aeb50c174ec697c7c9d7`.

## ruOS deployment

Observed on the dedicated "ruv-drone Rust Navigation Lab" desktop on
2026-09-16 at approximately 16:03 UTC. Four exposed CPU cores, 7.8 GiB RAM,
Rust/Cargo 1.75.0, release build. Graphics reported Mesa llvmpipe software
rendering; the viewer uses Canvas 2D projected 3D geometry.

| Check | Observed result |
| --- | --- |
| Unit tests on ruOS | 12 passed |
| Seeded scenarios | 100 of 100 expected outcomes |
| Completed inspection missions | 20 |
| Expected safety holds | 80 |
| Detected collisions | 0 |
| Geofence violations | 0 |
| Dynamics violations | 0 |
| Planning p50 | 393 microseconds |
| Planning p95 | 552 microseconds |
| Planning maximum | 655 microseconds |

These are one release-build evaluation's timings, not repeated benchmark trials
or real-time guarantees. Geometry has only seven or eight boxes in a fixed
32 × 24 × 12 m volume. Results do not generalize to dense point clouds, sensor
pipelines, urban-scale maps, moving obstacles, or physical aircraft.

Browser inspection on the ruOS desktop confirmed the inspection arrival,
blocked-corridor stationary hold, and stale-sensor braking followed by hold.
The stale scenario displayed zero terminal speed and the expired evidence age.
Scenario selection produced visibly different geometry/traces and terminal
states. Orbit/top, replay, timeline, and trace download controls are supplied;
only controls explicitly exercised should be represented as manually verified.

## Additional development checks

* Unit suite passed on local Rust 1.75.0 and stable 1.98.1.
* Clippy with all targets and warnings denied passed on stable.
* JavaScript syntax check passed.
* HTTP integration exercised all five scenarios and rejected cross-origin,
invalid Host, traversal, non-GET, and invalid-seed requests.
* The separate cloud browser could not reach the local development preview;
visual inspection was performed through the requested ruOS connector.

Full machine-produced evaluation is retained on the development desktop in
`tools/navigation-lab/runs/ruos-evaluation.json`. CI regenerates and uploads its
own evaluation on Rust 1.75.0 and stable. Wall-clock timing fields vary, while
the seeded routes, positions, velocities, and outcomes are deterministic.

No flight readiness, upstream equivalence, or strict clean-room claim is made.
19 changes: 19 additions & 0 deletions tools/navigation-lab/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Local desktop launcher. No network binding beyond the Rust loopback listener.
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
if ! curl --silent --fail --max-time 2 http://127.0.0.1:8777/health >/dev/null; then
cargo build --release --locked --offline
mkdir -p runs
nohup ./target/release/ruv-navigation-lab serve >runs/server.log 2>&1 &
server_pid=$!
printf '%s\n' "$server_pid" >runs/server.pid
ready=false
for attempt in {1..40}; do
if curl --silent --fail --max-time 1 http://127.0.0.1:8777/health >/dev/null; then ready=true; break; fi
kill -0 "$server_pid" 2>/dev/null || { cat runs/server.log >&2; exit 1; }
sleep 0.1
done
"$ready" || { printf 'Server did not become ready; see runs/server.log\n' >&2; exit 1; }
fi
if [[ "${1:-}" != "--server-only" ]]; then xdg-open http://127.0.0.1:8777; fi
Loading
Loading