Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1192de9

Browse files
committed
feat: ADR-021 vital sign detection + RVF container format (closes ruvnet#45)
Implement WiFi CSI-based vital sign detection and RVF model container: - Pure-Rust radix-2 DIT FFT with Hann windowing and parabolic interpolation - FIR bandpass filter (windowed-sinc, Hamming) for breathing (0.1-0.5 Hz) and heartbeat (0.8-2.0 Hz) band isolation - VitalSignDetector with rolling buffers (30s breathing, 15s heartbeat) - RVF binary container with 64-byte SegmentHeader, CRC32 integrity, 6 segment types (Vec, Manifest, Quant, Meta, Witness, Profile) - RvfBuilder/RvfReader with file I/O and VitalSignConfig support - Server integration: --benchmark, --load-rvf, --save-rvf CLI flags - REST endpoint /api/v1/vital-signs and WebSocket vital_signs field - 98 tests (32 unit + 16 RVF integration + 18 vital signs integration) - Benchmark: 7,313 frames/sec (136μs/frame), 365x real-time at 20 Hz Co-Authored-By: claude-flow <[email protected]>
1 parent fd8dec5 commit 1192de9

10 files changed

Lines changed: 3227 additions & 2 deletions

File tree

README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,121 @@ cargo build --release --package wifi-densepose-mat
194194
cargo test --package wifi-densepose-mat
195195
```
196196

197+
## 💓 Vital Sign Detection (ADR-021)
198+
199+
Contactless breathing and heart rate monitoring extracted from WiFi CSI signals using the rvdna (RuVector DNA) signal processing pipeline. All processing runs locally on-device with no raw data leaving the host.
200+
201+
| Capability | Range | Method |
202+
|------------|-------|--------|
203+
| **Breathing Rate** | 6-30 BPM (0.1-0.5 Hz band) | Bandpass filter + FFT peak detection |
204+
| **Heart Rate** | 40-120 BPM (0.8-2.0 Hz band) | Bandpass filter + FFT peak detection |
205+
| **Sampling Rate** | 20 Hz (ESP32 CSI frames) | Real-time streaming |
206+
| **Confidence Score** | 0.0-1.0 per vital sign | Spectral coherence + signal quality |
207+
208+
### API Endpoints
209+
210+
| Endpoint | Method | Description |
211+
|----------|--------|-------------|
212+
| `/api/v1/vital-signs` | GET | Latest breathing rate, heart rate, and confidence scores |
213+
| `/ws/sensing` | WebSocket | Real-time stream with `vital_signs` field in each frame |
214+
215+
### Quick Start (Vital Signs)
216+
217+
```bash
218+
cd rust-port/wifi-densepose-rs
219+
cargo build --release -p wifi-densepose-sensing-server
220+
./target/release/sensing-server --source simulate --ui-path ../../ui
221+
222+
# Check vital signs
223+
curl http://localhost:8080/api/v1/vital-signs
224+
225+
# Save model state as RVF container
226+
./target/release/sensing-server --source simulate --save-rvf model.rvf
227+
```
228+
229+
See [ADR-021](docs/adr/ADR-021-vital-sign-detection-rvdna-pipeline.md) for the full signal processing pipeline design.
230+
231+
## 📡 WiFi Scan Domain Layer (ADR-022)
232+
233+
**wifi-densepose-wifiscan**: Multi-BSSID WiFi scanning domain layer for enhanced Windows WiFi sensing (ADR-022). Features an 8-stage pure-Rust signal intelligence pipeline: predictive gating, attention weighting, spatial correlation, motion estimation, breathing extraction, quality gating, fingerprint matching, and orchestration. Transforms multi-AP RSSI data into presence, motion, breathing rate, and posture estimates.
234+
235+
| Stage | Purpose |
236+
|-------|---------|
237+
| **Predictive Gating** | Pre-filter scan results using temporal prediction |
238+
| **Attention Weighting** | Weight BSSIDs by signal relevance |
239+
| **Spatial Correlation** | Cross-AP spatial signal correlation |
240+
| **Motion Estimation** | Detect movement from RSSI variance |
241+
| **Breathing Extraction** | Extract respiratory rate from sub-Hz RSSI oscillations |
242+
| **Quality Gating** | Reject low-confidence estimates |
243+
| **Fingerprint Matching** | Location and posture classification via RF fingerprints |
244+
| **Orchestration** | Fuse all stages into unified sensing output |
245+
246+
**Build & Test:**
247+
```bash
248+
cd rust-port/wifi-densepose-rs
249+
cargo test -p wifi-densepose-wifiscan
250+
```
251+
252+
See [ADR-022](docs/adr/ADR-022-windows-wifi-enhanced-fidelity-ruvector.md) for the full pipeline design.
253+
254+
## 📦 RVF Model Container Format
255+
256+
The RuVector Format (RVF) packages model weights, HNSW index, metadata, and WASM runtime into a single `.rvf` file for portable, single-file deployment.
257+
258+
| Property | Detail |
259+
|----------|--------|
260+
| **Format** | Segment-based binary (magic `0x52564653`) with 64-byte segment headers |
261+
| **Progressive Loading** | Layer A in <5ms (entry points), Layer B in 100ms-1s (hot adjacency), Layer C (full graph) |
262+
| **Signing** | Ed25519-signed training proofs for verifiable provenance |
263+
| **Quantization** | Temperature-tiered (f32/f16/u8) via `rvf-quant` with SIMD distance |
264+
| **CLI Flags** | `--save-rvf <path>` and `--load-rvf <path>` for model persistence |
265+
266+
An RVF container is a self-contained artifact: no external model files, no Python runtime, no pip dependencies. Load it on any host with the Rust binary.
267+
268+
See [ADR-023](docs/adr/ADR-023-trained-densepose-model-ruvector-pipeline.md) for the full trained DensePose pipeline.
269+
270+
## 🧬 Training and Fine-Tuning
271+
272+
The DensePose model uses a three-tier data strategy:
273+
274+
1. **Pre-train** on public datasets (MM-Fi, Wi-Pose) for cross-environment generalization. These provide paired WiFi CSI + camera pose labels across diverse environments and subjects.
275+
2. **Fine-tune** with self-collected ESP32 data using a camera-based teacher model to generate pseudo-labels. Environment-specific multipath patterns are learned at this stage.
276+
3. **SONA runtime adaptation** via micro-LoRA + EWC++ for continuous on-device learning. The model adapts to furniture changes, new occupants, and seasonal RF propagation shifts without retraining from scratch.
277+
278+
```bash
279+
# Pre-train on MM-Fi dataset
280+
cargo run -p wifi-densepose-train -- \
281+
--dataset mmfi --epochs 100 --lr 1e-3
282+
283+
# Fine-tune with local ESP32 captures
284+
cargo run -p wifi-densepose-train -- \
285+
--dataset local --fine-tune --base-model pretrained.rvf \
286+
--epochs 20 --lr 1e-4 --save-rvf finetuned.rvf
287+
288+
# Enable SONA runtime adaptation (in sensing server)
289+
./target/release/sensing-server --source esp32 --load-rvf finetuned.rvf --sona-adapt
290+
```
291+
292+
## 🔩 RuVector Crates
293+
294+
Eleven RuVector crates from `vendor/ruvector/` power the signal intelligence and neural network layers:
295+
296+
| Crate | Description | Used For |
297+
|-------|-------------|----------|
298+
| `ruvector-core` | VectorDB, HNSW index, SIMD distance, quantization | Waveform template matching, RVF container I/O |
299+
| `ruvector-attention` | Scaled dot-product, MoE, PDE, sparse attention | Subcarrier weighting, spatial decoder |
300+
| `ruvector-gnn` | Graph neural network, graph attention, EWC training | Body-graph reasoning, subcarrier correlation |
301+
| `ruvector-nervous-system` | PredictiveLayer, OscillatoryRouter, EventBus, Hopfield | CSI preprocessing, frequency band isolation |
302+
| `ruvector-coherence` | Spectral coherence, HNSW health, Fiedler value | Signal quality scoring, breathing/heartbeat isolation |
303+
| `ruvector-temporal-tensor` | Tiered temporal compression (8/7/5/3-bit) | CSI frame buffering, vital sign storage |
304+
| `ruvector-mincut` | Subpolynomial dynamic min-cut | Multi-person assignment |
305+
| `ruvector-attn-mincut` | Attention-gated min-cut | Noise-suppressed spectrogram |
306+
| `ruvector-solver` | Sparse Neumann solver O(sqrt(n)) | Subcarrier resampling, Fresnel geometry |
307+
| `ruvector-graph-transformer` | Proof-gated graph transformer | CSI-to-pose cross-attention |
308+
| `ruvector-sparse-inference` | PowerInfer-style sparse execution | Edge deployment, low-latency inference |
309+
310+
See `vendor/ruvector/` for the full crate source and documentation.
311+
197312
## 📋 Table of Contents
198313

199314
<table>
@@ -204,6 +319,11 @@ cargo test --package wifi-densepose-mat
204319
- [Key Features](#-key-features)
205320
- [Rust Implementation (v2)](#-rust-implementation-v2)
206321
- [WiFi-Mat Disaster Response](#-wifi-mat-disaster-response-module)
322+
- [Vital Sign Detection](#-vital-sign-detection-adr-021)
323+
- [WiFi Scan Domain Layer](#-wifi-scan-domain-layer-adr-022)
324+
- [RVF Model Container](#-rvf-model-container-format)
325+
- [Training and Fine-Tuning](#-training-and-fine-tuning)
326+
- [RuVector Crates](#-ruvector-crates)
207327
- [System Architecture](#️-system-architecture)
208328
- [Installation](#-installation)
209329
- [Guided Installer (Recommended)](#guided-installer-recommended)
@@ -1020,6 +1140,9 @@ For development without WiFi CSI hardware, use the deterministic reference signa
10201140

10211141
# Run Rust tests (all use real signal processing, no mocks)
10221142
cd rust-port/wifi-densepose-rs && cargo test --workspace
1143+
1144+
# Test wifiscan crate
1145+
cargo test -p wifi-densepose-wifiscan
10231146
```
10241147

10251148
### Continuous Integration
@@ -1435,6 +1558,8 @@ SOFTWARE.
14351558
- **WiFi-Mat disaster response** — Ensemble classifier with START triage, scan zone management, API endpoints (ADR-001) — 139 tests
14361559
- **ESP32 CSI hardware parser** — Real binary frame parsing with I/Q extraction, amplitude/phase conversion, stream resync (ADR-012) — 28 tests
14371560
- **313 total Rust tests** — All passing, zero mocks
1561+
- **WiFi scan domain layer (ADR-022)** — Multi-BSSID WiFi scanning with 8-stage pure-Rust signal intelligence pipeline for enhanced Windows WiFi sensing: predictive gating, attention weighting, spatial correlation, motion estimation, breathing extraction, quality gating, fingerprint matching, and orchestration
1562+
- **Vital sign detection pipeline (ADR-021)** — Contactless breathing and heart rate monitoring via rvdna signal processing
14381563

14391564
### v2.1.0 — 2026-02-28
14401565

rust-port/wifi-densepose-rs/Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust-port/wifi-densepose-rs/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ members = [
1313
"crates/wifi-densepose-mat",
1414
"crates/wifi-densepose-train",
1515
"crates/wifi-densepose-sensing-server",
16+
"crates/wifi-densepose-wifiscan",
1617
]
1718

1819
[workspace.package]
@@ -107,6 +108,7 @@ ruvector-temporal-tensor = "2.0.4"
107108
ruvector-solver = "2.0.4"
108109
ruvector-attention = "2.0.4"
109110

111+
110112
# Internal crates
111113
wifi-densepose-core = { path = "crates/wifi-densepose-core" }
112114
wifi-densepose-signal = { path = "crates/wifi-densepose-signal" }

rust-port/wifi-densepose-rs/crates/wifi-densepose-sensing-server/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ edition.workspace = true
55
description = "Lightweight Axum server for WiFi sensing UI with RuVector signal processing"
66
license.workspace = true
77

8+
[lib]
9+
name = "wifi_densepose_sensing_server"
10+
path = "src/lib.rs"
11+
812
[[bin]]
913
name = "sensing-server"
1014
path = "src/main.rs"
@@ -29,3 +33,6 @@ chrono = { version = "0.4", features = ["serde"] }
2933

3034
# CLI
3135
clap = { workspace = true }
36+
37+
[dev-dependencies]
38+
tempfile = "3.10"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! WiFi-DensePose Sensing Server library.
2+
//!
3+
//! This crate provides:
4+
//! - Vital sign detection from WiFi CSI amplitude data
5+
//! - RVF (RuVector Format) binary container for model weights
6+
7+
pub mod vital_signs;
8+
pub mod rvf_container;

0 commit comments

Comments
 (0)