RuvSense 领域模型¶
RuvSense 是 RuView 的多站 WiFi 感知子系统。它将来自多个 ESP32 传感器的原始无线电信号转化为可追踪的人体姿态、生命体征和空间感知——全程无需摄像头。
本文档使用领域驱动设计(Domain-Driven Design, DDD)来定义该系统:边界上下文(Bounded Context)拥有各自的数据与规则,聚合根(Aggregate Root)强制不变量,值对象(Value Object)承载语义,领域事件(Domain Event)连接一切。目标是使系统的结构与其所模拟的物理世界相匹配——让任何阅读代码的人(或修改代码的 AI 智能体)都能理解每个组件存在的原因,而不仅仅是它做什么。
边界上下文:
| # | 上下文 | 职责 | 关键 ADR | 代码 |
|---|---|---|---|---|
| 1 | 多站感知 | 从多个节点和信道收集并融合 CSI | ADR-029 | signal/src/ruvsense/{multiband,phase_align,multistatic}.rs |
| 2 | 相干性 | 监控信号质量,屏蔽不良数据 | ADR-029 | signal/src/ruvsense/{coherence,coherence_gate}.rs |
| 3 | 姿态追踪 | 将人员追踪为具有重识别(re-ID)能力的持久骨架 | ADR-024, ADR-037 | signal/src/ruvsense/pose_tracker.rs |
| 4 | 场模型 | 学习房间基线,提取人体扰动 | ADR-030 | signal/src/ruvsense/{field_model,tomography}.rs |
| 5 | 纵向监测 | 追踪数天/数周的健康趋势 | ADR-030 | signal/src/ruvsense/longitudinal.rs |
| 6 | 空间身份 | 通过环境指纹进行跨房间追踪 | ADR-030 | signal/src/ruvsense/cross_room.rs |
| 7 | 边缘智能 | 设备端感知(无需服务器) | ADR-039, ADR-040 | firmware/esp32-csi-node/main/edge_processing.c |
除非另有说明,所示所有代码路径均相对于 v2/crates/wifi-densepose-。
领域驱动设计规范¶
通用语言¶
| 术语 | 定义 |
|---|---|
| Sensing Cycle | 一个完整的 TDMA 轮次(所有节点各 TX 一次):约 35ms,即 28.5 Hz(实测) |
| Link | 单个 TX-RX 对;若有 N 个节点,则共有 N×(N-1) 条有向链路 |
| Multi-Band Frame | 一个节点在一个驻留周期内跨多个信道跳频后融合得到的 CSI |
| Fused Sensing Frame | 一个感知周期内来自所有节点的聚合观测,可供推理直接使用 |
| Coherence Score | 0.0-1.0 的指标,用于量化当前 CSI 与参考模板之间的一致性 |
| Coherence Gate | 一种决策规则:接受、放大噪声、拒绝或触发重新校准 |
| Pose Track | 按人随时间持续的 17 关键点轨迹,附带卡尔曼状态 |
| Track Lifecycle | 状态机:Tentative(暂定)→ Active(活跃)→ Lost(丢失)→ Terminated(终止) |
| Re-ID Embedding | 编码身体身份的 128 维 AETHER 对比向量 |
| Edge Tier | ESP32 上的处理层级:0 = 原始透传,1 = 信号清理,2 = 生命体征,3 = WASM 模块 |
| WASM Module | 编译为 WebAssembly 并在 ESP32 上运行的小型程序,用于自定义设备端感知 |
| Node | 在多站网格中同时充当 TX 和 RX 的 ESP32-S3 设备 |
| Aggregator | 从所有节点收集 CSI 并执行融合的中心设备(ESP32/RPi/x86) |
| Sensing Schedule | TDMA 时隙分配:哪个节点在何时发送 |
| Channel Hop | 将 ESP32 无线电切换到不同的 WiFi 信道,以实现多频段感知 |
| Person Cluster | CSI 变化彼此相关的一组链路(归因于同一个人) |
边界上下文¶
1. 多站感知上下文¶
职责: 从多个 ESP32 节点收集、归一化并融合跨多个信道的 CSI,在每个周期内形成一个统一的感知帧。
┌──────────────────────────────────────────────────────────┐
│ Multistatic Sensing Context │
├──────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Link Buffer │ │ Multi-Band │ │
│ │ Collector │ │ Fuser │ │
│ │ (per-link │ │ (per-node │ │
│ │ ring buf) │ │ channel │ │
│ └───────┬───────┘ │ fusion) │ │
│ │ └───────┬───────┘ │
│ │ │ │
│ └────────┬───────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Phase Aligner │ │
│ │ (cross-chan │ │
│ │ correction) │ │
│ └────────┬───────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Multistatic │ │
│ │ Fuser │──▶ FusedSensingFrame │
│ │ (cross-node │ │
│ │ attention) │ │
│ └────────────────┘ │
│ │
└──────────────────────────────────────────────────────────┘
聚合根:
- FusedSensingFrame(聚合根)
值对象:
- MultiBandCsiFrame
- LinkGeometry (tx_pos, rx_pos, distance, angle)
- SensingSchedule
- ChannelHopConfig
领域服务:
- PhaseAlignmentService — 修正信道间由 LO 引起的相位旋转
- MultiBandFusionService — 将每信道 CSI 合并为宽带虚拟帧
- MultistaticFusionService — 基于注意力机制将 N 个节点融合为一个帧
RuVector 集成:
- ruvector-solver → 相位对齐(NeumannSolver)
- ruvector-attention → 跨信道特征加权
- ruvector-attn-mincut → 跨节点频谱图注意力门控
- ruvector-temporal-tensor → 每条链路独立的压缩环形缓冲区
2. 相干性上下文¶
职责: 监控 CSI 观测值的时间一致性,并对下游更新进行门控,以拒绝漂移、瞬态干扰和环境变化。
┌──────────────────────────────────────────────────────────┐
│ Coherence Context │
├──────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Reference │ │ Coherence │ │
│ │ Template │ │ Calculator │ │
│ │ (EMA of │ │ (z-score per │ │
│ │ static CSI) │ │ subcarrier) │ │
│ └───────┬───────┘ └───────┬───────┘ │
│ │ │ │
│ └────────┬───────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Static/Dynamic│ │
│ │ Decomposer │ │
│ │ (separate env │ │
│ │ vs. body) │ │
│ └────────┬───────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Gate Policy │──▶ GateDecision │
│ │ (Accept / │ (Accept / PredictOnly / │
│ │ Reject / │ Reject / Recalibrate) │
│ │ Recalibrate) │ │
│ └────────────────┘ │
│ │
└──────────────────────────────────────────────────────────┘
聚合根:
- CoherenceState(聚合根)— 维护参考模板和门控状态
值对象:
- CoherenceScore (0.0-1.0)
- GateDecision (Accept / PredictOnly / Reject / Recalibrate)
- ReferenceTemplate(静态周期 CSI 的 EMA)
- DriftProfile (Stable / Linear / StepChange)
领域服务:
- CoherenceCalculatorService — 计算每个子载波的 z-score 相干性
- StaticDynamicDecomposerService — 将环境漂移与身体运动分离
- GatePolicyService — 应用基于阈值的门控规则
RuVector 集成:
- ruvector-solver → 相干矩阵分解(静态 vs. 动态)
- ruvector-attn-mincut → 门控哪些子载波参与模板更新
3. 姿态跟踪上下文¶
职责: 将多人作为跨时间持续存在的 17 关键点骨架进行跟踪,具备卡尔曼平滑轨迹、生命周期管理,并通过 re-ID 保持身份。
┌──────────────────────────────────────────────────────────┐
│ Pose Tracking Context │
├──────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Person │ │ Detection │ │
│ │ Separator │ │ -to-Track │ │
│ │ (min-cut on │ │ Assigner │ │
│ │ link corr) │ │ (Hungarian+ │ │
│ └───────┬───────┘ │ embedding) │ │
│ │ └───────┬───────┘ │
│ │ │ │
│ └────────┬───────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Kalman Filter │ │
│ │ (17-keypoint │ │
│ │ 6D state ×17)│ │
│ └────────┬───────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Lifecycle │ │
│ │ Manager │──▶ TrackedPose │
│ │ (Tentative → │ │
│ │ Active → │ │
│ │ Lost) │ │
│ └────────┬───────┘ │
│ │ │
│ ┌────────▼───────┐ │
│ │ Embedding │ │
│ │ Identifier │ │
│ │ (AETHER re-ID)│ │
│ └────────────────┘ │
│ │
└──────────────────────────────────────────────────────────┘
聚合根:
- PoseTrack(聚合根)
实体:
- KeypointState — 每个关键点的卡尔曼状态 (x,y,z,vx,vy,vz),带协方差
值对象:
- TrackedPose — 不可变快照:17 个关键点 + 置信度 + track_id + 生命周期
- PersonCluster — 归属于同一个人的链路子集
- AssignmentCost — 马氏距离与 embedding 距离的组合
- TrackLifecycleState (Tentative / Active / Lost / Terminated)
RuVector 集成:
- ruvector-solver → 骨架相干性投影
- ruvector-attn-mincut → 人员分离 / 身份特征
- ruvector-temporal-tensor → 时间骨架缓冲张量
领域服务:
- PersonSeparationService — 跨链路相关图的最小割划分
- TrackAssignmentService — 检测与现有轨迹之间的二部匹配
- KalmanPredictionService — 28 Hz 预测步(与测量速率解耦)
- KalmanUpdateService — 门控测量更新(受相干门控约束)
- EmbeddingIdentifierService — 用于重识别的 AETHER 余弦相似度
RuVector 集成:
- ruvector-mincut → 人员分离(在相关图上使用 DynamicMinCut)
- ruvector-mincut → 检测到轨迹分配(DynamicPersonMatcher)
- ruvector-attention → 通过 ScaledDotProductAttention 计算嵌入相似度
核心领域实体¶
FusedSensingFrame(值对象)¶
pub struct FusedSensingFrame {
/// Timestamp of this sensing cycle
pub timestamp_us: u64,
/// Fused multi-band spectrogram from all nodes
/// Shape: [n_velocity_bins x n_time_frames]
pub fused_bvp: Vec<f32>,
pub n_velocity_bins: usize,
pub n_time_frames: usize,
/// Per-node multi-band frames (preserved for geometry)
pub node_frames: Vec<MultiBandCsiFrame>,
/// Node positions (from deployment config)
pub node_positions: Vec<[f32; 3]>,
/// Number of active nodes contributing
pub active_nodes: usize,
/// Cross-node coherence (higher = more agreement)
pub cross_node_coherence: f32,
}
PoseTrack(聚合根)¶
pub struct PoseTrack {
/// Unique track identifier
pub id: TrackId,
/// Per-keypoint Kalman state
pub keypoints: [KeypointState; 17],
/// Track lifecycle state
pub lifecycle: TrackLifecycleState,
/// Running-average AETHER embedding for re-ID
pub embedding: Vec<f32>, // [128]
/// Frames since creation
pub age: u64,
/// Frames since last successful measurement update
pub time_since_update: u64,
/// Creation timestamp
pub created_at: u64,
/// Last update timestamp
pub updated_at: u64,
}
KeypointState(实体)¶
pub struct KeypointState {
/// State vector [x, y, z, vx, vy, vz]
pub state: [f32; 6],
/// 6x6 covariance matrix (upper triangle, row-major)
pub covariance: [f32; 21],
/// Confidence (0.0-1.0) from DensePose model
pub confidence: f32,
}
CoherenceState(聚合根)¶
pub struct CoherenceState {
/// Per-subcarrier reference amplitude (EMA)
pub reference: Vec<f32>,
/// Per-subcarrier variance over recent window
pub variance: Vec<f32>,
/// EMA decay rate for reference update
pub decay: f32,
/// Current coherence score
pub score: f32,
/// Frames since last accepted update
pub stale_count: u64,
/// Current drift profile classification
pub drift_profile: DriftProfile,
}
领域事件¶
感知事件¶
pub enum SensingEvent {
/// New fused sensing frame available
FrameFused {
timestamp_us: u64,
active_nodes: usize,
cross_node_coherence: f32,
},
/// Node joined or left the mesh
MeshTopologyChanged {
node_id: u8,
change: TopologyChange, // Joined / Left / Degraded
active_nodes: usize,
},
/// Channel hop completed on a node
ChannelHopCompleted {
node_id: u8,
from_channel: u8,
to_channel: u8,
gap_us: u32,
},
}
相干事件¶
pub enum CoherenceEvent {
/// Coherence dropped below accept threshold
CoherenceLost {
score: f32,
threshold: f32,
timestamp_us: u64,
},
/// Coherence recovered above accept threshold
CoherenceRestored {
score: f32,
stale_duration_ms: u64,
timestamp_us: u64,
},
/// Recalibration triggered (>10s low coherence)
RecalibrationTriggered {
stale_duration_ms: u64,
timestamp_us: u64,
},
/// Recalibration completed via SONA TTT
RecalibrationCompleted {
adaptation_loss: f32,
timestamp_us: u64,
},
/// Environmental drift detected
DriftDetected {
drift_type: DriftProfile,
magnitude: f32,
timestamp_us: u64,
},
}
跟踪事件¶
pub enum TrackingEvent {
/// New person detected (track born)
PersonDetected {
track_id: TrackId,
position: [f32; 3], // centroid
confidence: f32,
timestamp_us: u64,
},
/// Person pose updated
PoseUpdated {
track_id: TrackId,
keypoints: [[f32; 4]; 17], // [x, y, z, conf] per keypoint
jitter_mm: f32, // RMS jitter at torso
timestamp_us: u64,
},
/// Person lost (signal dropout)
PersonLost {
track_id: TrackId,
last_position: [f32; 3],
last_embedding: Vec<f32>,
timestamp_us: u64,
},
/// Person re-identified after loss
PersonReidentified {
track_id: TrackId,
previous_track_id: TrackId,
similarity: f32,
gap_duration_ms: u64,
timestamp_us: u64,
},
/// Track terminated (exceeded max lost duration)
TrackTerminated {
track_id: TrackId,
reason: TerminationReason,
total_duration_ms: u64,
timestamp_us: u64,
},
}
pub enum TerminationReason {
/// Exceeded max_lost_frames without re-acquisition
SignalTimeout,
/// Confidence below minimum for too long
LowConfidence,
/// Determined to be false positive
FalsePositive,
/// System shutdown
SystemShutdown,
}
上下文映射¶
┌──────────────────────────────────────────────────────────────────┐
│ RuvSense System │
├──────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────┐ FusedFrame ┌──────────────────┐ │
│ │ Multistatic │──────────────▶│ Pose Tracking │ │
│ │ Sensing │ │ Context │ │
│ │ Context │ │ │ │
│ └────────┬─────────┘ └────────┬───────────┘ │
│ │ │ │
│ │ Publishes │ Publishes │
│ │ SensingEvent │ TrackingEvent │
│ ▼ ▼ │
│ ┌────────────────────────────────────────────────────┐ │
│ │ Event Bus (Domain Events) │ │
│ └────────────────────┬───────────────────────────────┘ │
│ │ │
│ ┌───────────▼───────────┐ │
│ │ Coherence Context │ │
│ │ (subscribes to │ │
│ │ SensingEvent; │ │
│ │ publishes │ │
│ │ CoherenceEvent; │ │
│ │ gates Tracking │ │
│ │ updates) │ │
│ └───────────────────────┘ │
│ │
├──────────────────────────────────────────────────────────────────┤
│ UPSTREAM (Conformist) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │wifi-densepose│ │wifi-densepose│ │wifi-densepose│ │
│ │ -hardware │ │ -nn │ │ -signal │ │
│ │ (CsiFrame │ │ (DensePose │ │ (SOTA algs │ │
│ │ parser) │ │ model) │ │ per link) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
├──────────────────────────────────────────────────────────────────┤
│ SIBLING (Partnership) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ AETHER │ │ MERIDIAN │ │ MAT │ │
│ │ (ADR-024) │ │ (ADR-027) │ │ (ADR-001) │ │
│ │ embeddings │ │ geometry │ │ triage │ │
│ │ for re-ID │ │ encoding │ │ lifecycle │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└──────────────────────────────────────────────────────────────────┘
关系类型: - 多静态感知 → 位姿跟踪:客户/供应商(感知产生 FusedFrames;跟踪消费) - 相干性 → 多静态感知:订阅者(监控帧质量) - 相干性 → 位姿跟踪:门控/拦截器(控制测量更新) - RuvSense → 上游 crate:顺应者(适配其类型) - RuvSense → AETHER/MERIDIAN/MAT:合作伙伴(共享嵌入/几何/跟踪抽象)
防腐层¶
硬件适配器(多静态感知 → wifi-densepose-hardware)¶
/// Adapts raw ESP32 CsiFrame to RuvSense MultiBandCsiFrame
pub struct MultiBandAdapter {
/// Group frames by (node_id, channel) within time window
window_ms: u32,
/// Hardware normalizer (from MERIDIAN, ADR-027)
normalizer: HardwareNormalizer,
}
impl MultiBandAdapter {
/// Collect raw CsiFrames from one TDMA cycle and produce
/// one MultiBandCsiFrame per node.
pub fn adapt_cycle(
&self,
raw_frames: &[CsiFrame],
) -> Vec<MultiBandCsiFrame>;
}
模型适配器(位姿跟踪 → wifi-densepose-nn)¶
/// Adapts DensePose model output to tracking-compatible detections
pub struct PoseDetectionAdapter;
impl PoseDetectionAdapter {
/// Convert model output (heatmaps + offsets) to detected poses
/// with keypoint positions and AETHER embeddings.
pub fn adapt(
&self,
model_output: &ModelOutput,
fused_frame: &FusedSensingFrame,
) -> Vec<PoseDetection>;
}
pub struct PoseDetection {
pub keypoints: [[f32; 4]; 17], // [x, y, z, confidence]
pub embedding: Vec<f32>, // [128] AETHER embedding
pub person_cluster: PersonCluster,
}
MAT 适配器(位姿跟踪 → wifi-densepose-mat)¶
/// Adapts RuvSense TrackedPose to MAT Survivor entity
/// for disaster response scenarios.
pub struct SurvivorAdapter;
impl SurvivorAdapter {
/// Convert a RuvSense TrackedPose to a MAT Survivor
/// with vital signs extracted from small-motion analysis.
pub fn to_survivor(
&self,
track: &PoseTrack,
vital_signs: Option<&VitalSignsReading>,
) -> Survivor;
}
仓储接口¶
/// Persists and retrieves pose tracks
pub trait PoseTrackRepository {
fn save(&self, track: &PoseTrack);
fn find_by_id(&self, id: &TrackId) -> Option<PoseTrack>;
fn find_active(&self) -> Vec<PoseTrack>;
fn find_lost(&self) -> Vec<PoseTrack>;
fn remove(&self, id: &TrackId);
}
/// Persists coherence state for long-term analysis
pub trait CoherenceRepository {
fn save_snapshot(&self, state: &CoherenceState, timestamp_us: u64);
fn load_latest(&self) -> Option<CoherenceState>;
fn load_history(&self, duration_ms: u64) -> Vec<(u64, f32)>;
}
/// Persists mesh topology and node health
pub trait MeshRepository {
fn save_node(&self, node_id: u8, position: [f32; 3], health: NodeHealth);
fn load_topology(&self) -> Vec<(u8, [f32; 3], NodeHealth)>;
fn save_schedule(&self, schedule: &SensingSchedule);
fn load_schedule(&self) -> Option<SensingSchedule>;
}
不变量¶
多静态感知¶
- 多静态融合至少需要 2 个节点处于活动状态(否则回退到单节点模式)
- 信道跳变序列必须至少包含 1 个不重叠信道
- 为输出 28 Hz,TDMA 周期必须 ≤50ms
- 保护间隔必须 ≥2× 时钟漂移预算(50ms 周期时 ≥1ms)
相干性¶
- 参考模板必须在静默期间每 10 分钟重新计算一次
- 门控阈值必须按环境进行校准(初始默认值:accept=0.85,drift=0.5)
- 陈旧计数不得超过 max_stale(200 帧 = 10 秒),否则必须触发重新校准
- 静态/动态分解必须保持能量守恒:||S|| + ||D|| ≈ ||C||
位姿跟踪¶
- 每个输出帧恰好执行一次卡尔曼预测步骤(20 Hz,无论测量是否可用)
- 出生门控:在连续 2 次测量更新之前,航迹不会提升为 Active
- 丢失阈值:连续 5 次测量缺失后,航迹标记为 Lost
- 重识别窗口:Lost 航迹在 5 秒内可重新识别
- 嵌入 EMA 衰减:0.95(缓慢适应可在环境变化中保持身份)
- 联合分配代价必须同时使用位置(60%)和嵌入(40%)项
第二部分:持久场模型限界上下文(ADR-030)¶
通用语言(扩展)¶
| 术语 | 定义 |
|---|---|
| 场正常模式 | 房间的电磁本征结构——无人时的稳定传播基线 |
| 人体扰动 | 去除环境漂移后,由人引起的场的结构化变化 |
| 环境模式 | 由温度、湿度、时间引起的基线变化的主成分 |
| 个人基线 | 按人划分的生物物理代理指标在数天/数周内的滚动统计画像 |
| 漂移事件 | 相对于个人基线的统计显著偏差(>2sigma 持续 >3 天) |
| 漂移报告 | 可追溯证据包:z-score、方向、窗口、支持嵌入 |
| 风险信号 | 关于生物物理变化的可操作观察——不是诊断 |
| 意图先导信号 | 在可见运动前 200-500ms 检测到的运动前动力学(倾斜、重心转移) |
| 占用体积 | 来自 RF 层析成像的低分辨率 3D 概率密度场 |
| 房间指纹 | 使用 HNSW 索引的嵌入,表征房间的电磁身份 |
| 转移事件 | 一个人离开一个房间并进入另一个房间,通过嵌入相似度匹配 |
4. 场模型上下文¶
职责: 学习并维护房间的电磁基线。将所有 CSI 观测分解为环境漂移、人体扰动和异常。为所有下游特殊能力提供基础。
┌──────────────────────────────────────────────────────────┐
│ Field Model Context │
├──────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Calibration │ │ Mode │ │
│ │ Collector │ │ Extractor │ │
│ │ (empty-room │ │ (SVD on │ │
│ │ CSI frames) │ │ baseline) │ │
│ └───────┬───────┘ └───────┬───────┘ │
│ │ │ │
│ └────────┬───────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Perturbation │ │
│ │ Extractor │ │
│ │ (subtract │ │
│ │ baseline + │──▶ BodyPerturbation │
│ │ project out │ │
│ │ env modes) │ │
│ └────────┬───────┘ │
│ │ │
│ ┌────────▼───────┐ │
│ │ RF Tomographer│ │
│ │ (sparse 3D │──▶ OccupancyVolume │
│ │ inversion) │ │
│ └────────────────┘ │
│ │
└──────────────────────────────────────────────────────────┘
聚合根:
- FieldNormalMode(聚合根)
值对象:
- BodyPerturbation — 移除基线 + 环境模式后每个链路的 CSI 残差
- EnvironmentalMode — 基线变化的一个主成分
- OccupancyVolume — 估计质量密度的 3D 体素网格
- CalibrationStatus — Fresh / Stale / Expired(基于距上次空房间的时间)
领域服务:
- CalibrationService — 检测空房间时间窗口,收集校准数据
- ModeExtractionService — 用于环境模式的 SVD 计算
- PerturbationService — 基线减除 + 模式投影
- TomographyService — 用于占用体积的稀疏 L1 反演
RuVector 集成:
- ruvector-solver → 用于模式提取的 SVD;用于断层反演的 L1
- ruvector-temporal-tensor → 基线历史压缩
- ruvector-attn-mincut → 模式-子载波分配划分
5. 纵向监测上下文¶
职责: 在数天/数周内维护每个人的生物物理基线。检测有意义的漂移。生成可追溯的证据报告。坚持“信号而非诊断”的边界。
┌──────────────────────────────────────────────────────────┐
│ Longitudinal Monitoring Context │
├──────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Metric │ │ Baseline │ │
│ │ Extractor │ │ Updater │ │
│ │ (pose → gait,│ │ (Welford │ │
│ │ stability, │ │ online │ │
│ │ breathing) │ │ statistics) │ │
│ └───────┬───────┘ └───────┬───────┘ │
│ │ │ │
│ └────────┬───────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Drift Detector│ │
│ │ (z-score vs │ │
│ │ personal │ │
│ │ baseline) │ │
│ └────────┬───────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Evidence │ │
│ │ Assembler │──▶ DriftReport │
│ │ (embeddings + │ │
│ │ timestamps + │ │
│ │ graph links) │ │
│ └────────────────┘ │
│ │
└──────────────────────────────────────────────────────────┘
聚合根:
- PersonalBaseline(聚合根)
实体:
- DailyMetricSummary — 每人一天的压缩指标统计
值对象:
- DriftReport — 包含 z 分数、方向、窗口、嵌入的证据包
- DriftMetric — GaitSymmetry / StabilityIndex / BreathingRegularity / MicroTremor / ActivityLevel
- DriftDirection — Increasing / Decreasing
- MonitoringLevel — Physiological(级别 1)/ Drift(级别 2)/ RiskCorrelation(级别 3)
- WelfordStats — 在线均值/方差累加器(count、mean、M2)
领域服务:
- MetricExtractionService — 从姿态轨迹中提取生物力学代理指标
- BaselineUpdateService — 使用每日观测更新 Welford 统计
- DriftDetectionService — 计算 z 分数,识别显著偏差
- EvidenceAssemblyService — 打包支持性嵌入和图约束
RuVector 集成:
- ruvector-temporal-tensor → 压缩每日摘要存储
- ruvector-attention → 在漂移分数中加权指标显著性
- ruvector-mincut → 指标序列中的时间变点检测
- HNSW → 跨纵向嵌入记录的相似性搜索
不变量: - 基线需要 7 天以上的观测天数后,漂移检测才会激活 - 漂移警报要求 >2sigma 偏差持续 >3 天 - 证据链必须包含界定漂移窗口起止的嵌入 - 系统从不输出诊断性语言 — 仅输出指标值和偏差 - 个人基线衰减:Welford 统计使用完整历史(无窗口化)以保证稳定性
6. 空间身份上下文¶
职责: 通过环境指纹和转移图维护跨房间的身份连续性。在不存储图像的情况下跟踪谁在哪个空间。
┌──────────────────────────────────────────────────────────┐
│ Spatial Identity Context │
├──────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Room │ │ Transition │ │
│ │ Fingerprint │ │ Detector │ │
│ │ Index (HNSW) │ │ (exit/entry │ │
│ └───────┬───────┘ │ events) │ │
│ │ └───────┬───────┘ │
│ │ │ │
│ └────────┬───────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Cross-Room │ │
│ │ Matcher │ │
│ │ (exit embed ↔ │──▶ TransitionEvent │
│ │ entry embed) │ │
│ └────────┬───────┘ │
│ │ │
│ ┌────────▼───────┐ │
│ │ Transition │ │
│ │ Graph │ │
│ │ (rooms, │ │
│ │ persons, │ │
│ │ timestamps) │ │
│ └────────────────┘ │
│ │
└──────────────────────────────────────────────────────────┘
聚合:
- SpatialIdentityGraph(聚合根)
实体:
- RoomProfile — 房间的 HNSW 索引电磁指纹
- PersonSpatialRecord — 某人按顺序访问过的房间
值对象:
- TransitionEvent — 人员、from_room、to_room、时间戳、嵌入相似度
- RoomFingerprint — 房间 CSI 配置的 128 维 AETHER 嵌入
- SpatialContinuity — 跨房间身份链的置信度分数
领域服务:
- RoomFingerprintService — 计算并索引房间电磁配置
- TransitionDetectionService — 检测离开(边界附近丢失跟踪)和进入(新跟踪)
- CrossRoomMatchingService — 退出与进入嵌入之间的 HNSW 相似度
- TransitionGraphService — 构建和查询房间-人员-时间图
RuVector 集成:
- HNSW → 房间和人员指纹相似性搜索
- ruvector-mincut → 用于占用分析的转移图划分
不变量: - 跨房间匹配要求 >0.80 余弦相似度且 <60s 时间间隔 - 如果网格拓扑发生变化,必须重新计算房间指纹 - 转移图边一旦创建即不可变(仅追加审计轨迹) - 不存储图像数据 — 仅存储 128 维嵌入和结构化事件
领域事件(扩展)¶
场模型事件¶
pub enum FieldModelEvent {
/// Baseline calibration completed (empty room detected and measured)
BaselineCalibrated {
room_id: RoomId,
n_modes: usize,
variance_explained: f32, // fraction of total variance captured
timestamp_us: u64,
},
/// Environmental drift detected (baseline shift without body cause)
EnvironmentalDriftDetected {
room_id: RoomId,
magnitude: f32,
drift_type: DriftProfile,
timestamp_us: u64,
},
/// Anomalous perturbation detected (does not match body or environment)
AnomalousPerturbation {
room_id: RoomId,
anomaly_score: f32,
affected_links: Vec<usize>,
timestamp_us: u64,
},
/// Occupancy volume updated
OccupancyUpdated {
room_id: RoomId,
occupied_voxels: usize,
total_voxels: usize,
timestamp_us: u64,
},
}
纵向监测事件¶
pub enum LongitudinalEvent {
/// Personal baseline established (7-day calibration complete)
BaselineEstablished {
person_id: PersonId,
observation_days: u32,
metrics_tracked: Vec<DriftMetric>,
timestamp_us: u64,
},
/// Drift detected — biophysical metric significantly changed
DriftDetected {
person_id: PersonId,
report: DriftReport,
timestamp_us: u64,
},
/// Drift resolved — metric returned to baseline range
DriftResolved {
person_id: PersonId,
metric: DriftMetric,
resolution_days: u32,
timestamp_us: u64,
},
/// Daily summary computed for a person
DailySummaryComputed {
person_id: PersonId,
date: u64, // day timestamp
metrics: Vec<(DriftMetric, f32)>, // metric, today's value
timestamp_us: u64,
},
}
空间身份事件¶
pub enum SpatialEvent {
/// New room fingerprinted
RoomFingerprinted {
room_id: RoomId,
fingerprint_dims: usize,
timestamp_us: u64,
},
/// Person transitioned between rooms
PersonTransitioned {
person_id: PersonId,
from_room: RoomId,
to_room: RoomId,
similarity: f32,
gap_duration_ms: u64,
timestamp_us: u64,
},
/// Cross-room match failed (new person in destination room)
CrossRoomMatchFailed {
entry_room: RoomId,
entry_embedding: Vec<f32>,
candidates_checked: usize,
best_similarity: f32,
timestamp_us: u64,
},
}
扩展上下文映射¶
┌──────────────────────────────────────────────────────────────────────┐
│ RuvSense Full System (ADR-029 + ADR-030) │
├──────────────────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ FusedFrame ┌──────────────┐ │
│ │ Multistatic │────────────▶│ Pose Tracking │ │
│ │ Sensing │ │ Context │ │
│ └───────┬───────┘ └───────┬───────┘ │
│ │ │ │
│ │ │ TrackedPose │
│ │ │ │
│ ▼ ┌───────▼───────┐ │
│ ┌───────────────┐ │ Longitudinal │ │
│ │ Coherence │ │ Monitoring │ │
│ │ Context │ │ Context │ │
│ └───────┬───────┘ └───────┬───────┘ │
│ │ Gates │ DriftReport │
│ │ │ │
│ ▼ ▼ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Field Model │ │ Spatial │ │
│ │ Context │ │ Identity │ │
│ │ (baseline, │ │ Context │ │
│ │ modes, │ │ (cross-room, │ │
│ │ tomography) │ │ transitions)│ │
│ └───────────────┘ └───────────────┘ │
│ │
│ ──────────────── Event Bus ────────────────── │
│ SensingEvent | CoherenceEvent | TrackingEvent | │
│ FieldModelEvent | LongitudinalEvent | SpatialEvent │
│ │
├──────────────────────────────────────────────────────────────────────┤
│ UPSTREAM: wifi-densepose-{hardware, nn, signal} │
│ SIBLINGS: AETHER (embeddings) | MERIDIAN (geometry) | MAT (triage) │
└──────────────────────────────────────────────────────────────────────┘
新关系类型: - 多静态感知 → 场模型:合作伙伴关系(感知提供原始 CSI;场模型提供扰动提取) - 姿态跟踪 → 纵向监测:客户/供应商(跟踪提供每日姿态指标;监测构建基线) - 姿态跟踪 → 空间身份:客户/供应商(跟踪提供轨迹退出/进入事件;空间身份维护转移图) - 相干性 → 场模型:订阅者(相干性事件用于基线重新校准) - 纵向监测 → 空间身份:合作伙伴关系(共享人员档案用于跨房间匹配)
扩展仓库接口¶
/// Persists field normal modes and calibration history
pub trait FieldModelRepository {
fn save_baseline(&self, room_id: RoomId, mode: &FieldNormalMode);
fn load_baseline(&self, room_id: RoomId) -> Option<FieldNormalMode>;
fn list_rooms(&self) -> Vec<RoomId>;
fn save_occupancy_snapshot(&self, room_id: RoomId, volume: &OccupancyVolume, timestamp_us: u64);
}
/// Persists personal baselines and drift history
pub trait LongitudinalRepository {
fn save_baseline(&self, baseline: &PersonalBaseline);
fn load_baseline(&self, person_id: &PersonId) -> Option<PersonalBaseline>;
fn save_daily_summary(&self, person_id: &PersonId, summary: &DailyMetricSummary);
fn load_summaries(&self, person_id: &PersonId, days: u32) -> Vec<DailyMetricSummary>;
fn save_drift_report(&self, report: &DriftReport);
fn load_drift_history(&self, person_id: &PersonId) -> Vec<DriftReport>;
}
/// Persists room fingerprints and transition graphs
pub trait SpatialIdentityRepository {
fn save_room_fingerprint(&self, room_id: RoomId, fingerprint: &RoomFingerprint);
fn load_room_fingerprint(&self, room_id: RoomId) -> Option<RoomFingerprint>;
fn save_transition(&self, transition: &TransitionEvent);
fn load_transitions(&self, person_id: &PersonId, window_ms: u64) -> Vec<TransitionEvent>;
fn load_room_occupancy(&self, room_id: RoomId) -> Vec<PersonId>;
}
扩展不变量¶
场模型¶
- 基线校准需要 ≥10 分钟的空房间 CSI(28 Hz 下 ≥12,000 帧)
- 环境模式上限为 K=5(更多模式会过拟合噪声)
- 断层反演仅在 ≥8 条链路时有效(最少 4 个节点)
- 如果未在静默期刷新,基线将在 24 小时后过期
- 扰动能量必须非负(由幅度计算强制)
纵向监测¶
- 个人基线需要 ≥7 个观测日,之后漂移检测才会激活
- 漂移警报要求 >2sigma 偏差持续 ≥3 天
- 证据链必须包含包围漂移窗口的嵌入对
- 输出永远不得使用诊断性语言——仅使用指标值和统计偏差
- 每日摘要存储 ≥90 天(滚动保留策略)
- Welford 统计使用完整历史(无窗口化)以获得最大稳定性
空间身份¶
- 跨房间匹配要求 >0.80 余弦相似度且 <60s 时间间隔
- 当网格拓扑变化时(节点添加/移除/移动)重新计算房间指纹
- 转移图仅追加(不可变审计跟踪)
- 不存储图像数据——仅存储 128 维嵌入和结构事件
- 每次部署最多索引 100 个房间(HNSW 扩展约束)
第三部分:边缘智能限界上下文(ADR-039、ADR-040、ADR-041)¶
7. 边缘智能上下文¶
职责: 直接在 ESP32-S3 上运行信号处理和感知算法,无需服务器。节点检测存在、测量呼吸和心率、跌倒告警,并运行自定义 WASM 模块——全部本地执行,即时响应。
这是唯一运行在微控制器而非聚合器上的限界上下文。它独立运行:服务器仅用于可视化时可选,但 ESP32 自行处理实时感知。
┌──────────────────────────────────────────────────────────┐
│ Edge Intelligence Context │
│ (runs on ESP32-S3, Core 1) │
├──────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────┐ ┌───────────────┐ │
│ │ Phase │ │ Welford │ │
│ │ Extractor │ │ Variance │ │
│ │ (I/Q → φ, │ │ Tracker │ │
│ │ unwrap) │ │ (per-subk) │ │
│ └───────┬───────┘ └───────┬───────┘ │
│ │ │ │
│ └────────┬───────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Top-K Select │ │
│ │ + Bandpass │ │
│ │ (breathing: │ │
│ │ 0.1-0.5 Hz, │ │
│ │ HR: 0.8-2 Hz) │ │
│ └────────┬───────┘ │
│ ▼ │
│ ┌─────────────┼─────────────┐ │
│ ▼ ▼ ▼ │
│ ┌────────┐ ┌──────────┐ ┌──────────┐ │
│ │Presence│ │ Vitals │ │ Fall │ │
│ │Detector│ │ (BPM via │ │ Detector │ │
│ │(motion │ │ zero- │ │ (phase │ │
│ │ energy)│ │ crossing)│ │ accel) │ │
│ └────┬───┘ └────┬─────┘ └────┬─────┘ │
│ └───────────┼──────────────┘ │
│ ▼ │
│ ┌────────────────┐ │
│ │ Vitals Packet │──▶ UDP 32-byte (0xC5110002) │
│ │ Assembler │ at 1 Hz to aggregator │
│ └────────┬───────┘ │
│ │ │
│ ┌────────▼───────┐ │
│ │ WASM3 Runtime │ │
│ │ (Tier 3: hot- │──▶ Custom module outputs │
│ │ loadable │ │
│ │ modules) │ │
│ └────────────────┘ │
│ │
└──────────────────────────────────────────────────────────┘
聚合:
- EdgeProcessingState(聚合根)— 保存所有子载波级状态、滤波器历史和检测标志
值对象:
- VitalsPacket — 32 字节 UDP 数据包:存在状态、运动、呼吸 BPM、心率 BPM、置信度、跌倒标志、占用状态
- EdgeTier — Off (0) / BasicSignal (1) / FullVitals (2) / WasmExtended (3)
- PresenceState — Empty / Present / Moving
- BandpassOutput — 呼吸或心率频带中的滤波信号
- FallAlert — 相位加速度超过可配置阈值
实体:
- WasmModule — 已加载的 WASM 二进制文件,拥有独立的内存区域(160 KB)、帧预算(10 ms)和定时器间隔
领域服务:
- PhaseExtractionService — 将每个子载波的原始 I/Q 转换为解卷绕相位
- VarianceTrackingService — 用于子载波选择的 Welford 在线统计
- TopKSelectionService — 选择方差最高的子载波用于下游分析
- BandpassFilterService — 用于呼吸(0.1-0.5 Hz)和心率(0.8-2.0 Hz)的二阶 IIR 滤波器
- PresenceDetectionService — 自适应阈值校准(1200 帧窗口上的 3-sigma)
- VitalSignService — 从滤波后的相位信号进行零交叉 BPM 估计
- FallDetectionService — 相位加速度超过阈值时触发警报
- WasmRuntimeService — WASM3 解释器:加载、执行并沙箱化自定义模块
NVS 配置(运行时,无需重新烧录):
| 键 | 类型 | 默认值 | 用途 |
|---|---|---|---|
edge_tier |
u8 | 0 | 处理层级(0/1/2/3) |
pres_thresh |
u16 | 0 | 存在阈值(0 = 自动校准) |
fall_thresh |
u16 | 2000 | 跌倒检测阈值(rad/s^2 x 1000) |
vital_win |
u16 | 256 | 相位历史窗口(帧) |
vital_int |
u16 | 1000 | 生命体征数据包间隔(ms) |
subk_count |
u8 | 8 | Top-K 子载波数量 |
wasm_max |
u8 | 4 | 最大并发 WASM 模块数 |
wasm_verify |
u8 | 0 | 要求上传具有 Ed25519 签名 |
实现文件:
- firmware/esp32-csi-node/main/edge_processing.c — DSP 流水线(约 750 行)
- firmware/esp32-csi-node/main/edge_processing.h — 类型和 API
- firmware/esp32-csi-node/main/nvs_config.c — NVS 键读取器(20 个键)
- firmware/esp32-csi-node/provision.py — CLI 配置工具
不变量: - 边缘处理运行在 Core 1 上;WiFi 和 CSI 回调运行在 Core 0 上(无争用) - CSI 数据通过无锁 SPSC 环形缓冲区从 Core 0 流向 Core 1 - UDP 发送被限速至 50 Hz,以防止 lwIP 缓冲区耗尽(问题 #127) - 如果 lwIP 耗尽数据包缓冲区,ENOMEM 退避会抑制发送 100 ms - WASM 模块被沙箱化:160 KB 内存区域、10 ms 帧预算、无直接硬件访问 - 通过 NVS 更改层级将在下次重启时生效 — DSP 流水线不支持热重配置 - 跌倒检测阈值应根据部署环境调整(默认值 2000 在静态环境中会导致误报)
领域事件:
pub enum EdgeEvent {
/// Presence state changed
PresenceChanged {
node_id: u8,
state: PresenceState, // Empty / Present / Moving
motion_energy: f32,
timestamp_ms: u32,
},
/// Fall detected on-device
FallDetected {
node_id: u8,
acceleration: f32, // rad/s^2
timestamp_ms: u32,
},
/// Vitals packet emitted
VitalsEmitted {
node_id: u8,
breathing_bpm: f32,
heart_rate_bpm: f32,
confidence: f32,
timestamp_ms: u32,
},
/// WASM module loaded or failed
WasmModuleLoaded {
slot: u8,
module_name: String,
success: bool,
timestamp_ms: u32,
},
}
与其他上下文的关系: - Edge Intelligence → Multistatic Sensing: 替代(边缘在设备上运行;多静态在聚合器上运行 — 相同物理原理,不同计算位置) - Edge Intelligence → Pose Tracking: 上游(边缘提供存在/生命体征;如果边缘已确认占用,聚合器可跳过检测) - Edge Intelligence → Coherence: 简化(边缘使用简单方差阈值,而不是完整相干门控)
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 wi/RuView