研究文档 10:RF 拓扑感知 — 系统架构与原型¶
日期: 2026-03-08 状态: 草稿 作者: 研究代理 范围: 使用 ESP32 网状网络实现 RF 拓扑感知的端到端架构
目录¶
1. 端到端架构¶
1.1 核心概念¶
RF 拓扑感知将 ESP32 节点组成的网状网络视为“无线电神经系统”。 每个发射机-接收机对定义一条图边。在每条边上测量的信道状态信息 (CSI)编码了这两个节点之间的无线电环境如何受到扰动——由墙壁、家具,以及最重要的是,由人体造成。当一个人站在两个节点之间时,该链路上的 CSI 相干性下降。所有这些下降的集合定义了图中的一个割,勾勒出人体的物理边界。
该系统不直接估计姿态。相反,它回答一个更根本的问题:已占用空间与未占用空间之间的边界在哪里? 姿态估计、活动识别和房间分割都是这一边界信息的下游消费者。
1.2 数据流摘要¶
ESP32 Node A ──CSI──> Edge (A,B) ──weight──> Graph G ──mincut──> Boundaries ──render──> UI
ESP32 Node B ──CSI──> Edge (B,C) ──weight──> | | |
ESP32 Node C ──CSI──> Edge (A,C) ──weight──> | | |
... ... v v v
ESP32 Node N Edge (i,j) RfGraph CutBoundary WebSocket
1.3 流水线图¶
+============================================================================+
| RF TOPOLOGICAL SENSING PIPELINE |
+============================================================================+
STAGE 1: CSI EXTRACTION STAGE 2: EDGE WEIGHT
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
+-------------+ +-------------+ +-----------------+
| ESP32 Node | | ESP32 Node | | Edge Weight |
| (TX) |--->| (RX) |--[ raw CSI ]->| Computation |
| ch_hop() | | extract() | | |
+-------------+ +-------------+ | - phase_align() |
| | | - coherence() |
| TDM slot | 52-subcarrier | - amplitude() |
| assignment | CSI frame | - temporal_avg |
v v +---------+-------+
+-------------+ +-------------+ |
| TDM | | CSI Frame | weight: f64
| Scheduler | | Buffer | [0.0 .. 1.0]
| (hardware) | | (ring buf) | |
+-------------+ +-------------+ v
STAGE 3: GRAPH CONSTRUCTION STAGE 4: DYNAMIC MINCUT
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
+-----------------+ +------------------+
| RfGraph | | Mincut Solver |
| |<----[ edge weights ]---------| |
| - add_edge() | | - stoer_wagner() |
| - update_wt() | | or |
| - prune_stale() | | - karger() |
| - adjacency mat |----[ graph snapshot ]------->| - push_relabel() |
| | | |
+-----------------+ +--------+---------+
|
CutBoundary {
cut_edges,
cut_value,
partitions
}
|
v
STAGE 5: BOUNDARY VISUALIZATION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+------------------+ +-------------------+ +----------------+
| Boundary | | Sensing Server | | Browser UI |
| Interpolation |------>| (Axum WebSocket) |------>| (Canvas/WebGL) |
| | | | | |
| - contour_from() | | - ws_broadcast() | | - draw_room() |
| - smooth() | | - /api/topology | | - draw_cuts() |
| - to_polygon() | | - /api/stream | | - animate() |
+------------------+ +-------------------+ +----------------+
1.4 各阶段数据结构¶
Stage 1 Output: CsiFrame { tx_id, rx_id, subcarriers: [Complex<f32>; 52], timestamp_us }
Stage 2 Output: EdgeWeight { tx_id, rx_id, weight: f64, confidence: f64, updated_at }
Stage 3 Output: RfGraph { nodes: Vec<NodeId>, edges: HashMap<(NodeId,NodeId), EdgeWeight> }
Stage 4 Output: CutBoundary { cut_edges: Vec<(NodeId,NodeId)>, partitions: (Vec<NodeId>, Vec<NodeId>) }
Stage 5 Output: BoundaryPolygon { vertices: Vec<(f64,f64)>, confidence: f64 }
1.5 通信协议¶
节点使用 ADR-028 中定义的 TDM(时分复用)进行通信。每个节点被分配一个发送时隙。在其时隙期间,节点在已知的子载波模式上发送。所有其他节点同时接收并提取 CSI。对于 N 个节点,这产生 N*(N-1)/2 条唯一边。
Time -->
Slot 0 Slot 1 Slot 2 Slot 3 Slot 0 Slot 1 ...
[Node A] [Node B] [Node C] [Node D] [Node A] [Node B]
TX TX TX TX TX TX
B,C,D RX A,C,D RX A,B,D RX A,B,C RX B,C,D RX A,C,D RX
One full cycle = N slots = one complete graph snapshot
At 1ms slots, 4-node cycle = 4ms, 16-node cycle = 16ms
2. 现有 Crate 集成¶
2.1 集成映射¶
+---------------------------+ +-----------------------------+
| wifi-densepose-hardware | | wifi-densepose-signal |
| (ESP32 TDM, CSI extract) | | (ruvsense modules) |
+------------+--------------+ +-------------+---------------+
| |
| CsiFrame | coherence, phase
v v
+------------------------------------------------------------------+
| rf_topology (NEW MODULE) |
| RfGraph, EdgeWeight, CutBoundary, TopologyEvent |
+------------------------------------------------------------------+
| |
| graph memory | boundary data
v v
+-----------------------------+ +-----------------------------+
| wifi-densepose-ruvector | | wifi-densepose-sensing- |
| (graph memory, attention) | | server (UI, WebSocket) |
+-----------------------------+ +-----------------------------+
2.2 wifi-densepose-signal / ruvsense¶
signal crate 包含 RuvSense 模块,为边权计算提供数学基础。
coherence.rs — 带 DriftProfile 的 Z-score 一致性评分。该模块已经计算 CSI 帧之间的一致性指标。对于 RF 拓扑,我们将一致性用作主要边权:高一致性表示链路无遮挡,低一致性表示路径上有物体(人)。
Usage in rf_topology:
- coherence::ZScoreCoherence::score(baseline_csi, current_csi) -> f64
- coherence::DriftProfile tracks long-term drift per edge
- coherence_gate::CoherenceGate decides if a measurement is reliable
phase_align.rs — 使用圆均值进行迭代 LO 相位偏移估计。ESP32 本地振荡器会漂移,这会破坏相位测量。相位对齐是有意义一致性计算的前提。
Usage in rf_topology:
- phase_align::align_frames(tx_csi, rx_csi) -> AlignedCsiPair
- Must be called BEFORE coherence scoring
- Runs per-edge, per-frame
multiband.rs — 多频段 CSI 帧融合。当节点在多个 WiFi 信道上工作时(通过信道跳变),该模块将测量值融合为单一一致视图。
Usage in rf_topology:
- multiband::fuse_channels(ch1_csi, ch5_csi, ch11_csi) -> FusedCsiFrame
- Increases spatial resolution of edge weights
- Optional: single-channel operation is sufficient for prototype
multistatic.rs — 带几何多样性的注意力加权融合。该模块已经执行多链路融合,这在概念上接近 rf_topology 所需。关键区别在于 multistatic.rs 为姿态估计进行融合,而 rf_topology 为边界检测进行融合。
Usage in rf_topology:
- multistatic::GeometricDiversity provides link quality weighting
- Reuse attention weights for graph edge confidence scoring
adversarial.rs — 物理上不可能信号检测。该模块检测 CSI 测量违反物理约束的情况(例如,当人遮挡路径时信号强度反而增加)。对于过滤图中的坏边至关重要。
Usage in rf_topology:
- adversarial::PhysicsChecker::validate(edge_measurement) -> Result<(), Violation>
- Edges that fail validation are marked low-confidence
2.3 wifi-densepose-ruvector¶
ruvector crate 提供基于图的数据结构和注意力机制,可重新用于 RF 拓扑。
viewpoint/attention.rs — 带 GeometricBias 和 softmax 的 CrossViewpointAttention。注意力机制计算多个视点之间的重要性权重。在 RF 拓扑中,每个 TX-RX 对是一个“视点”,注意力机制可以优先处理信息量最大的边。
Usage in rf_topology:
- CrossViewpointAttention can weight edges by geometric diversity
- GeometricBias accounts for node placement geometry
- Softmax normalization produces valid probability distribution over edges
viewpoint/geometry.rs — GeometricDiversityIndex 和 Cramer-Rao 界。该模块量化一组链路提供多少几何信息。RF 拓扑使用它来判断当前节点布置能否在给定位置分辨边界。
Usage in rf_topology:
- GeometricDiversityIndex tells us if we have enough angular coverage
- Cramer-Rao bound gives theoretical position error lower bound
- Fisher Information matrix guides optimal node placement
viewpoint/coherence.rs — 带滞回门控的相位相量一致性。已经为一致性测量提供门控机制。RF 拓扑复用该机制,以防止噪声测量导致边界闪烁。
Usage in rf_topology:
- Hysteresis gate prevents rapid edge weight oscillation
- Smooths boundary detection over time
viewpoint/fusion.rs — 带领域事件的 MultistaticArray 聚合根。这是一个 DDD 聚合根,管理一组多静态链路。RF 拓扑可以扩展该模式,用于图级聚合管理。
Usage in rf_topology:
- MultistaticArray pattern informs RfGraph aggregate design
- Domain events (LinkAdded, LinkDropped) map to TopologyEvent
2.4 wifi-densepose-hardware¶
hardware crate 管理 ESP32 设备和 TDM 协议。
esp32/tdm.rs — 时分复用调度器。为节点分配发送时隙,确保无冲突的 CSI 提取。
Usage in rf_topology:
- TdmScheduler provides the frame timing that drives the pipeline
- Each TDM cycle produces one complete graph snapshot
- Cycle period = N_nodes * slot_duration
esp32/channel_hop.rs — 信道跳变固件控制。允许节点在多个 WiFi 信道上测量 CSI,以提升空间分辨率。
Usage in rf_topology:
- Channel diversity increases edge weight accuracy
- Feeds into multiband.rs fusion
esp32/csi_extract.rs — 从 ESP32 硬件寄存器中提取原始 CSI。生成 CsiFrame 结构体,作为整个流水线的输入。
Usage in rf_topology:
- CsiFrame is the fundamental input type
- 52 subcarriers per frame on 20MHz channels
- Timestamp synchronization via NTP or TDM slot timing
2.5 wifi-densepose-sensing-server¶
感知服务器提供 Web UI 和 WebSocket 流式传输。
Usage in rf_topology:
- WebSocket endpoint broadcasts CutBoundary updates to browser
- REST endpoint /api/topology returns current graph state
- Static file serving for visualization JavaScript
- Axum router integrates new topology endpoints
2.6 集成摘要表¶
| 现有模块 | 它提供什么 | rf_topology 如何使用它 |
|---|---|---|
| signal/ruvsense/coherence | Z-score 一致性评分 | 主要边权指标 |
| signal/ruvsense/phase_align | LO 相位偏移校正 | 一致性预处理 |
| signal/ruvsense/multiband | 多通道融合 | 提升边分辨率 |
| signal/ruvsense/multistatic | 几何多样性加权 | 边置信度评分 |
| signal/ruvsense/adversarial | 物理违规检测 | 不良边过滤 |
| signal/ruvsense/coherence_gate | 滞回门控 | 边界闪烁抑制 |
| ruvector/viewpoint/attention | 跨视点注意力 | 边重要性加权 |
| ruvector/viewpoint/geometry | 几何多样性指数 | 分辨率分析 |
| ruvector/viewpoint/fusion | DDD 聚合根模式 | RfGraph 聚合设计 |
| hardware/esp32/tdm | TDM 时隙调度 | 帧定时、周期控制 |
| hardware/esp32/csi_extract | 原始 CSI 提取 | 流水线输入 |
| sensing-server | Axum WebSocket + REST | 可视化交付 |
3. 新模块设计¶
3.1 模块位置¶
v2/crates/wifi-densepose-signal/src/ruvsense/
rf_topology.rs <-- New module (primary)
rf_topology/
graph.rs <-- RfGraph aggregate root
edge_weight.rs <-- EdgeWeight computation
mincut.rs <-- Dynamic mincut solver
boundary.rs <-- CutBoundary -> spatial polygon
events.rs <-- TopologyEvent domain events
mod.rs <-- Module re-exports
或者,rf_topology 可以作为一个独立 crate:
v2/crates/wifi-densepose-topology/
src/
lib.rs
graph.rs
edge_weight.rs
mincut.rs
boundary.rs
events.rs
Cargo.toml
优先采用独立 crate 方案,因为 RF 拓扑具有明确的限界上下文语义,并且拥有自己的聚合根(RfGraph)。它依赖 wifi-densepose-signal 进行一致性计算,并依赖 wifi-densepose-core 获取共享类型。
3.2 关键类型¶
RfGraph — 聚合根¶
RfGraph 是核心聚合根。它拥有完整的图状态:节点、边、权重和元数据。所有变更都通过 RfGraph 方法执行,这些方法会发出 TopologyEvents 供下游消费者使用。
RfGraph {
id: GraphId,
nodes: HashMap<NodeId, NodeInfo>,
edges: HashMap<EdgeId, EdgeState>,
adjacency: AdjacencyMatrix,
epoch: u64, // incremented on each full TDM cycle
last_updated: Instant,
config: TopologyConfig,
}
RfGraph 强制执行的不变量: - 无自环(tx_id != rx_id) - 边权位于 [0.0, 1.0] 范围内 - 过期边(N 个周期内无更新)会被修剪 - 图始终保持连通(出现不连通的子图会触发告警)
EdgeWeight — 值对象¶
EdgeWeight {
tx_id: NodeId,
rx_id: NodeId,
weight: f64, // 0.0 = fully obstructed, 1.0 = clear
raw_coherence: f64, // pre-normalization coherence
confidence: f64, // measurement quality [0.0, 1.0]
sample_count: u32, // number of CSI frames averaged
baseline_deviation: f64, // how far from calibrated baseline
updated_at: Instant,
}
EdgeWeight 是值对象:创建后不可变。每个 TDM 周期会为每条边生成一个新的 EdgeWeight,并替换 RfGraph 中的前一个值。
CutBoundary — 值对象¶
CutBoundary {
cut_edges: Vec<EdgeId>, // edges that cross the boundary
cut_value: f64, // total weight of cut edges
partition_a: Vec<NodeId>, // nodes on one side
partition_b: Vec<NodeId>, // nodes on the other side
spatial_boundary: Option<Polygon>, // interpolated physical boundary
confidence: f64, // based on edge confidences
detected_at: Instant,
}
CutBoundary 表示最小割求解器的输出。当检测到多人时,可以同时存在多个 CutBoundary。
TopologyEvent — 领域事件¶
TopologyEvent {
id: EventId,
timestamp: Instant,
kind: TopologyEventKind,
}
enum TopologyEventKind {
NodeJoined { node_id: NodeId, position: (f64, f64) },
NodeLeft { node_id: NodeId, reason: LeaveReason },
EdgeWeightChanged { edge_id: EdgeId, old: f64, new: f64 },
BoundaryDetected { boundary: CutBoundary },
BoundaryMoved { boundary_id: BoundaryId, displacement: (f64, f64) },
BoundaryLost { boundary_id: BoundaryId },
GraphPartitioned { components: Vec<Vec<NodeId>> },
CalibrationRequired { reason: String },
}
事件会发布到事件总线。感知服务器订阅并通过 WebSocket 将相关事件转发到浏览器 UI。
3.3 DDD 聚合根设计¶
+-------------------------------------------------------------------+
| RfGraph (Aggregate Root) |
| |
| +------------------+ +-----------------+ +---------------+ |
| | NodeRegistry | | EdgeRegistry | | CutSolver | |
| | | | | | | |
| | - register() | | - update_wt() | | - solve() | |
| | - deregister() | | - prune_stale() | | - track() | |
| | - get_position() | | - get_weight() | | - boundaries | |
| +------------------+ +-----------------+ +---------------+ |
| |
| Command Interface: |
| fn ingest_csi_frame(&mut self, frame: CsiFrame) -> Vec<Event> |
| fn tick(&mut self) -> Vec<Event> |
| fn calibrate(&mut self, baseline: &Baseline) -> Vec<Event> |
| fn add_node(&mut self, node: NodeInfo) -> Vec<Event> |
| fn remove_node(&mut self, node_id: NodeId) -> Vec<Event> |
| |
| Query Interface: |
| fn current_boundaries(&self) -> &[CutBoundary] |
| fn edge_weight(&self, a: NodeId, b: NodeId) -> Option<f64> |
| fn graph_snapshot(&self) -> GraphSnapshot |
| fn node_count(&self) -> usize |
| fn is_connected(&self) -> bool |
+-------------------------------------------------------------------+
|
| emits
v
Vec<TopologyEvent>
|
v
+---------------------+
| Event Bus |
| (tokio broadcast) |
+---------------------+
| |
v v
Sensing Server Pose Tracker
(WebSocket) (ruvsense)
3.4 模块职责¶
| 文件 | 职责 | 行数估算 |
|---|---|---|
| graph.rs | RfGraph 聚合,节点/边注册表 | ~200 |
| edge_weight.rs | 基于 CSI 相干性的权重计算 | ~120 |
| mincut.rs | Stoer-Wagner 和增量最小割 | ~180 |
| boundary.rs | 割集到多边形的插值 | ~150 |
| events.rs | TopologyEvent 类型和总线 | ~80 |
| mod.rs | 公共 API 重新导出 | ~30 |
| 总计 | ~760 |
所有文件都保持在 500 行限制以内,必要时可拆分 graph.rs。
4. 实时流水线¶
4.1 延迟预算¶
系统必须在 CSI 帧到达后的 100ms 内生成更新后的边界估计。这能够支持响应迅速的实时可视化,并足以跟踪人类速度的移动。
+============================================================================+
| LATENCY BUDGET: 100ms TOTAL |
+============================================================================+
Stage Budget Actual Target Notes
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
1. CSI Extraction 5 ms 3-5 ms ESP32 hardware, fixed
2. Phase Alignment 3 ms 1-2 ms Per-edge, parallelizable
3. Edge Weight Comp 10 ms 5-8 ms Coherence + normalization
4. Graph Update 2 ms 0.5-1 ms HashMap insert/update
5. Mincut Solver 5 ms 2-5 ms Stoer-Wagner on N<64
6. Boundary Interp 5 ms 2-3 ms Polygon from cut edges
7. Serialization 2 ms 0.5-1 ms serde_json or bincode
8. WebSocket TX 3 ms 1-2 ms Local network
9. Browser Render 20 ms 10-16 ms Canvas 2D at 60fps
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~
TOTAL 55 ms 26-43 ms ~50ms headroom
Margin for safety: 45 ms Absorbs GC, jitter, WiFi
4.2 阶段详情¶
阶段 1:CSI 提取(5ms 预算)¶
ESP32 会从每个接收到的数据包中提取 CSI。这发生在固件中,并受 WiFi 硬件限制。输出是一个 52 维复数向量,以及元数据(RSSI、噪声底、时间戳)。
Input: WiFi packet on air
Output: CsiFrame { subcarriers: [Complex<f32>; 52], rssi: i8, ... }
Cost: Fixed by hardware. ~3ms on ESP32-S3, ~5ms on ESP32.
阶段 2:相位对齐(3ms 预算)¶
相位对齐用于校正 TX 节点和 RX 节点之间的本地振荡器漂移。使用 ruvsense/phase_align.rs 中的圆形均值算法。每条边每帧运行一次。
Input: CsiFrame pair (TX reference, RX measurement)
Output: AlignedCsiPair with corrected phase
Cost: ~50us per edge. For 16 nodes (120 edges): 6ms sequential, <1ms parallel
Note: Embarrassingly parallel across edges. Use rayon par_iter.
阶段 3:边权重计算(10ms 预算)¶
计算当前 CSI 与基线 CSI 之间的相干性。应用时间平均(对最近 K 帧进行指数移动平均)。归一化到 [0.0, 1.0] 范围。应用对抗性物理检查。
Input: AlignedCsiPair + baseline reference
Output: EdgeWeight { weight, confidence, ... }
Cost: ~80us per edge. For 120 edges: 9.6ms sequential, <2ms parallel
Pipeline:
1. coherence::ZScoreCoherence::score() ~30us
2. temporal_average() ~10us
3. adversarial::PhysicsChecker::validate() ~20us
4. normalize_and_gate() ~20us
阶段 4:图更新(2ms 预算)¶
将新的边权重插入 RfGraph。修剪过期边。检查连通性。 这是一个简单的 HashMap 操作。
Input: Vec<EdgeWeight> from current TDM cycle
Output: Updated RfGraph, list of changed edges
Cost: O(E) where E = number of edges. <1ms for E < 500.
阶段 5:最小割求解器(5ms 预算)¶
在加权图上运行 Stoer-Wagner 最小割。对于小型图(N < 64), Stoer-Wagner 的运行复杂度为 O(V * E + V^2 * log V),完全在预算之内。
Input: RfGraph adjacency matrix with weights
Output: CutBoundary (minimum cut edges + partitions)
Cost: 4-node: ~0.1ms
16-node: ~2ms
64-node: ~15ms (exceeds budget -- use incremental solver)
对于超过约 40 个节点的图,使用增量最小割:仅重新计算 变化边邻域内的割。无论总图规模如何,这都能将成本保持在 5ms 以下。
阶段 6:边界插值(5ms 预算)¶
通过插值割两侧节点的已知位置,将割边转换为空间多边形。
Input: CutBoundary + node positions
Output: BoundaryPolygon { vertices: Vec<(f64, f64)> }
Cost: Convex hull + smoothing. <3ms for typical boundaries.
阶段 7-9:序列化、传输、渲染(25ms 预算)¶
将边界多边形序列化为 JSON,通过 WebSocket 发送,并在浏览器中渲染。
Serialization: serde_json::to_string(&boundary) -- <1ms
WebSocket TX: axum tungstenite broadcast -- <2ms local
Browser render: Canvas 2D path drawing -- 10-16ms at 60fps
4.3 时序图¶
Time (ms) 0 5 10 15 20 25 30 35 40 45 50
| | | | | | | | | | |
[CSI ]
[Phs][ Edge Weight ]
[GU][Cut ]
[Bnd][Ser][WS]
[Render....]
|<-- ESP32 firmware --|<------ Rust pipeline -------->|<-- Browser ->|
| 5ms | ~25ms | ~16ms |
|<---------------------- Total: ~46ms ------------------------------>|
4.4 并行策略¶
+-- rayon thread pool (4 threads on server, 1 on ESP32) --+
| |
| Edge 0: [phase_align] -> [coherence] -> [weight] |
| Edge 1: [phase_align] -> [coherence] -> [weight] |
| Edge 2: [phase_align] -> [coherence] -> [weight] |
| ... |
| Edge N: [phase_align] -> [coherence] -> [weight] |
| |
+-- barrier: all edges complete --------+ |
| |
[graph_update] (single thread) |
[mincut_solve] (single thread) |
[boundary_interp] (single thread) |
[serialize + broadcast] |
+----------------------------------------------------------+
边权重计算是高度可并行的,并且主导了流水线成本。 使用 rayon 可将其从 O(E * cost_per_edge) 降低到 O(E * cost_per_edge / num_threads)。
5. 原型阶段¶
5.1 阶段 1:4 节点概念验证¶
目标:检测单个人员进入由 4 个 ESP32 节点围成的方形区域。
Node A ─────────── Node B
| \ / |
| \ / |
| \ / |
| [X] | X = person standing here
| / \ |
| / \ |
| / \ |
Node D ─────────── Node C
Edges: A-B, A-C, A-D, B-C, B-D, C-D (6 total)
Room size: 3m x 3m
设置: - 4 块 ESP32-S3 DevKitC 开发板 - 节点位于 3m x 3m 房间的角落 - 单个 WiFi 信道(信道 6,2.437 GHz) - TDM 使用 1ms 时隙 = 4ms 周期 = 250 Hz 更新率
成功标准: - 在人员进入房间后 500ms 内检测到人员存在 - 正确识别人员所在的象限 - 房间为空时没有误报(超过 10 分钟的测试) - 最小割正确地将人员与至少一个节点分开
交付物: - 在 4 块 ESP32 开发板上可运行的 TDM 固件 - 实时处理 CSI 的 Rust 流水线 - 显示带有高亮割边的图的 Web UI - 已记录的校准流程
时间线:4 周
Week 1: TDM firmware bring-up, CSI extraction verified
Week 2: Edge weight pipeline, baseline calibration
Week 3: Mincut integration, boundary detection logic
Week 4: Web UI, end-to-end test, benchmark
5.2 阶段 2:16 节点房间规模¶
目标:跟踪 1-3 名人员在房间内移动时的空间边界。
A ── B ── C ── D
| \ | /\ | /\ |
E ── F ── G ── H
| / | \/ | \/ |
I ── J ── K ── L
| \ | /\ | /\ |
M ── N ── O ── P
16 nodes, 4x4 grid, 1.5m spacing
Edges: up to 120 (each node connects to all others within range)
Room size: 4.5m x 4.5m
新增能力: - 通过多路最小割(k-cut)实现多人检测 - 跨帧边界跟踪(时间关联) - 自适应基线重新校准(家具变化) - 信道跳频以提高分辨率
成功标准: - 同时跟踪 1-3 名人员 - 边界位置误差 < 50cm(与真值比较) - 更新率 >= 30 Hz(每周期 33ms) - 处理人员进入/退出而不产生错误边界 - 从节点故障中恢复(16 个节点中有 1 个离线)
交付物: - 可扩展的 16 节点 TDM 调度器 - 带时间跟踪的多割求解器 - 带 ID 分配的边界跟踪 - 显示延迟分解的性能仪表板 - 与摄像头真值的比较
时间线:8 周
Week 1-2: Scale TDM to 16 nodes, test reliability
Week 3-4: Multi-cut solver, k-way partitioning
Week 5-6: Temporal tracking, boundary ID persistence
Week 7: Channel hopping, multi-band fusion
Week 8: Benchmark suite, ground truth comparison
5.3 阶段 3:多房间网格¶
目标:扩展到具有分层图结构的多房间部署。
+------------------+ +------------------+
| Room A (16 nodes)| | Room B (16 nodes)|
| | | |
| Local RfGraph | | Local RfGraph |
| | | |
+--------+---------+ +--------+---------+
| |
| gateway edges | gateway edges
| |
+--------+-------------------------+--------+
| Hallway (8 nodes) |
| Corridor RfGraph |
+--------+-------------------------+--------+
| |
+--------+---------+ +--------+---------+
| Room C (16 nodes)| | Room D (16 nodes)|
| | | |
+------------------+ +------------------+
Total: 72 nodes across 5 zones
Hierarchical mincut: local cuts + cross-zone cuts
新增能力: - 分层图:房间级图,带有跨房间网关边 - 跨房间人员跟踪(在局部图之间进行交接) - 分布式处理:每个房间运行自己的最小割,全局协调器 合并边界 - 环境指纹识别(复用 ruvsense/cross_room.rs) - 容错:如果网关故障,房间可独立运行
成功标准: - 跟踪跨越房间过渡的人员 - 即使有 72 个节点,延迟也 < 100ms(通过分层分解) - 优雅处理节点故障(降级,不崩溃) - 房间内边界精度 < 50cm,跨过渡 < 1m
时间线:16 周
5.4 阶段总结¶
Phase Nodes Edges People Accuracy Update Rate Duration
~~~~~~ ~~~~~~ ~~~~~~ ~~~~~~~ ~~~~~~~~~ ~~~~~~~~~~~ ~~~~~~~~
1 4 6 1 Quadrant 250 Hz 4 weeks
2 16 120 1-3 < 50cm 30 Hz 8 weeks
3 72 ~500 5-10 < 50cm 30 Hz 16 weeks
6. 基准测试¶
6.1 主要基准测试:人员穿过房间¶
场景:一名人员沿着已知路径穿过 16 节点房间 (阶段 2 设置)。真值由头顶摄像头采集,人员肩部带有 ArUco 标记。
A ── B ── C ── D
| | | |
E ── F ── G ── H
| | | | Person path: start at (+), walk to (*),
I ── J ── K ── L then to (#), then exit
| | | |
M ── N ── O ── P
Path: (+) near F
|
v
(*) near K
|
v
(#) near O
|
v
exit past P
6.2 设置¶
硬件: - 16 个 ESP32-S3 DevKitC,安装在支架上,高度 1.2m - 网格间距:1.5m - 房间尺寸:4.5m x 4.5m,为基线清空家具 - 1 个头顶 USB 摄像头,30fps,用于真值 - 人员身上 4 个 ArUco 标记(肩部、髋部)
软件: - TDM 周期:16ms(16 个节点 x 1ms 时隙) - 更新速率:62.5 Hz - 最小割求解器:Stoer-Wagner - 边权重:指数移动平均,alpha = 0.3 - 基线:60 秒空房间校准
环境: - 标准办公室房间,混凝土墙 - WiFi 信道 6(2.437 GHz),同一信道上没有其他 AP - 温度:20-25C(稳定) - 测试时长:每次运行 5 分钟,共 10 次
6.3 指标¶
| 指标 | 定义 | 目标 |
|---|---|---|
| 边界位置误差 | 检测边界质心到真值位置的距离 | < 50cm |
| 检测延迟 | 人员进入房间到首次边界检测的时间 | < 500ms |
| 跟踪连续性 | 人员在场时检测到边界的帧百分比 | > 95% |
| 误报率 | 房间为空时每分钟检测到的边界数 | < 0.1/min |
| 流水线延迟(P95) | CSI 到边界时间的第 95 百分位 | < 100ms |
| 流水线延迟(P50) | CSI 到边界时间的中位数 | < 50ms |
| 更新吞吐量 | 每秒交付到 UI 的边界更新数 | > 30/s |
| 节点故障恢复 | 1 个节点离线后恢复稳定运行的时间 | < 5s |
6.4 成功标准¶
如果在 10 次运行中以下所有条件均成立,则基准测试通过:
- 平均边界位置误差 < 50cm
- 第 95 百分位边界位置误差 < 75cm
- 9/10 次运行中检测延迟 < 500ms
- 9/10 次运行中跟踪连续性 > 95%
- 空房间中零误报(10 分钟测试)
- 所有运行中流水线延迟 P95 < 100ms
- 任何运行期间无崩溃或挂起
6.5 数据收集¶
Output files per run:
benchmark_run_{N}/
csi_raw/ # Raw CSI frames, timestamped
edge_weights/ # Computed weights per edge per frame
boundaries/ # Detected boundaries with timestamps
ground_truth/ # Camera-derived positions with timestamps
latency_log.csv # Per-frame pipeline timing breakdown
summary.json # Aggregate metrics for this run
6.6 分析¶
基准测试后的分析计算:
- 误差分布:边界位置误差直方图
- 误差与位置:整个房间误差热图(角落与中心)
- 延迟分解:流水线阶段堆叠柱状图
- 时间稳定性:边界位置随时间变化与真值对比
- 边权重可视化:行走期间边权重动画
预期失效模式: - 靠近房间边缘时误差更高(周围节点更少) - 快速移动期间短暂检测间隙 - 当人员恰好位于两个节点之间时误差增加(模糊割)
7. ADR-044 草案¶
ADR-044:RF 拓扑感知¶
状态:提议
日期:2026-03-08
背景¶
wifi-densepose 系统当前通过神经网络模型(wifi-densepose-nn)处理 CSI 数据来估计人体姿态。该方法需要训练数据、GPU 推理以及对神经模型进行逐环境校准。RuvSense 多静态感知模式(ADR-029)通过多链路融合提高了鲁棒性,但在融合前仍将每条链路独立处理。
一种根本不同的方法是可能的:将整个 ESP32 网格视为图,其中 TX-RX 对是边,CSI 相干性决定边权重。该图的最小割揭示了物理边界——无线电传播被人体干扰的位置。这就是“RF 拓扑感知”。
关键动机: - 无需训练数据:最小割是纯图算法,而非学习模型。基线校准后即可开箱即用。 - 基于物理原理:该方法直接利用人体衰减和散射无线电波这一物理事实。 - 优雅降级:如果节点失效,图只是边更少。最小割仍然有效,但分辨率降低。 - 与神经方法互补:拓扑边界可以为神经姿态估计器提供空间先验,提高精度。
决策¶
我们将在工作区中实现 RF 拓扑感知作为新模块。该模块将:
-
定义 RfGraph 聚合根,维护网格中所有 TX-RX 链路的加权图。
-
使用现有 ruvsense 模块(coherence.rs、phase_align.rs)从 CSI 相干性计算边权重。
-
运行动态最小割以实时检测物理边界。
-
通过感知服务器 WebSocket 暴露边界用于可视化。
-
发布 TopologyEvents,供下游模块(pose_tracker、intention)消费以获取空间先验。
实现将分三个阶段进行: - 阶段 1:4 节点概念验证(检测人员存在) - 阶段 2:16 节点房间级(以 < 50cm 误差跟踪边界) - 阶段 3:多房间网格,采用分层图分解
影响¶
正面: - 支持无需神经网络推理或训练数据的 WiFi 感知 - 提供与姿态估计互补的空间边界信息 - 复用现有 ruvsense 模块进行相干性和相位对齐 - 遵循 ruvector/viewpoint/fusion.rs 中建立的 DDD 模式 - 在节点失效时优雅降级 - 低于 100ms 的延迟支持实时应用
负面: - 至少需要 4 个 ESP32 节点(硬件成本高于单链路) - 最小割提供边界而非姿态——姿态仍需要神经推理或额外的几何推理 - Stoer-Wagner 复杂度 O(V*E + V^2 log V) 在没有增量求解器时限制了超过约 40 个节点的可扩展性 - 跨许多节点进行 TDM 同步会增加固件复杂度 - 图算法需要新的测试基础设施
中性: - 不替代现有神经姿态估计;而是对其进行补充 - 阶段 1 可在投入完整实现前验证该方法 - 可能为未来关于分布式感知架构的 ADR 提供参考
参考资料¶
- ADR-029:RuvSense 多静态感知模式
- ADR-028:ESP32 能力审计
- ADR-014:SOTA 信号处理
- 研究文档 10:本文档
8. Rust 特征定义¶
8.1 核心特征¶
/// Unique identifier for a node in the RF mesh.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct NodeId(pub u16);
/// Unique identifier for an edge (ordered pair of nodes).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct EdgeId {
pub tx: NodeId,
pub rx: NodeId,
}
impl EdgeId {
/// Create a canonical edge ID where tx < rx to avoid duplicates.
pub fn canonical(a: NodeId, b: NodeId) -> Self {
if a.0 <= b.0 {
Self { tx: a, rx: b }
} else {
Self { tx: b, rx: a }
}
}
}
/// Physical position of a node in 2D space (meters).
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct Position2D {
pub x: f64,
pub y: f64,
}
/// Information about a node in the mesh.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct NodeInfo {
pub id: NodeId,
pub position: Position2D,
pub mac_address: [u8; 6],
pub tdm_slot: u8,
pub joined_at: u64, // unix timestamp ms
}
8.2 边权重特征¶
/// Trait for computing edge weights from CSI measurements.
pub trait EdgeWeightComputer: Send + Sync {
/// Compute the weight for an edge given current and baseline CSI.
fn compute(
&self,
current: &CsiFrame,
baseline: &CsiFrame,
config: &EdgeWeightConfig,
) -> Result<EdgeWeight, TopologyError>;
/// Update the temporal average for an edge.
fn update_average(
&self,
previous: &EdgeWeight,
new_sample: &EdgeWeight,
alpha: f64,
) -> EdgeWeight;
}
/// Configuration for edge weight computation.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EdgeWeightConfig {
/// Exponential moving average smoothing factor.
pub ema_alpha: f64,
/// Minimum confidence to accept a measurement.
pub min_confidence: f64,
/// Number of subcarriers to use (0 = all).
pub subcarrier_count: usize,
/// Enable adversarial physics check.
pub physics_check: bool,
}
impl Default for EdgeWeightConfig {
fn default() -> Self {
Self {
ema_alpha: 0.3,
min_confidence: 0.5,
subcarrier_count: 0,
physics_check: true,
}
}
}
8.3 图特征¶
/// Trait for the RF topology graph.
pub trait TopologyGraph: Send + Sync {
/// Add a node to the graph.
fn add_node(&mut self, node: NodeInfo) -> Result<Vec<TopologyEvent>, TopologyError>;
/// Remove a node and all its edges.
fn remove_node(&mut self, id: NodeId) -> Result<Vec<TopologyEvent>, TopologyError>;
/// Update the weight of an edge. Creates the edge if it doesn't exist.
fn update_edge(
&mut self,
edge: EdgeId,
weight: EdgeWeight,
) -> Result<Vec<TopologyEvent>, TopologyError>;
/// Remove edges that haven't been updated in `max_age` duration.
fn prune_stale(&mut self, max_age: std::time::Duration) -> Vec<TopologyEvent>;
/// Get the current weight of an edge.
fn edge_weight(&self, edge: EdgeId) -> Option<&EdgeWeight>;
/// Get all edges as (EdgeId, weight) pairs.
fn edges(&self) -> Vec<(EdgeId, f64)>;
/// Get the number of nodes.
fn node_count(&self) -> usize;
/// Get the number of edges.
fn edge_count(&self) -> usize;
/// Check if the graph is connected.
fn is_connected(&self) -> bool;
/// Get a snapshot of the adjacency matrix for mincut computation.
fn adjacency_matrix(&self) -> AdjacencyMatrix;
}
8.4 最小割求解器 Trait¶
/// Result of a minimum cut computation.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MinCutResult {
/// Edges that form the minimum cut.
pub cut_edges: Vec<EdgeId>,
/// Total weight of the cut.
pub cut_value: f64,
/// Nodes in partition A.
pub partition_a: Vec<NodeId>,
/// Nodes in partition B.
pub partition_b: Vec<NodeId>,
}
/// Trait for minimum cut solvers.
pub trait MinCutSolver: Send + Sync {
/// Compute the global minimum cut of the graph.
fn min_cut(&self, graph: &AdjacencyMatrix) -> Result<MinCutResult, TopologyError>;
/// Compute a k-way minimum cut (for multi-person detection).
fn k_cut(
&self,
graph: &AdjacencyMatrix,
k: usize,
) -> Result<Vec<MinCutResult>, TopologyError>;
/// Incrementally update the cut after edge weight changes.
/// Returns None if the cut topology hasn't changed.
fn incremental_update(
&self,
previous_cut: &MinCutResult,
changed_edges: &[(EdgeId, f64, f64)], // (edge, old_weight, new_weight)
graph: &AdjacencyMatrix,
) -> Result<Option<MinCutResult>, TopologyError>;
}
/// Stoer-Wagner implementation of MinCutSolver.
pub struct StoerWagnerSolver {
/// Cache the last contraction order for incremental updates.
last_contraction: Option<Vec<(NodeId, NodeId)>>,
}
impl MinCutSolver for StoerWagnerSolver {
fn min_cut(&self, graph: &AdjacencyMatrix) -> Result<MinCutResult, TopologyError> {
// Stoer-Wagner algorithm:
// 1. Start with arbitrary node
// 2. Repeatedly add "most tightly connected" node
// 3. Last two nodes define a cut candidate
// 4. Merge last two nodes, repeat
// 5. Return minimum cut found across all phases
todo!("Implement Stoer-Wagner")
}
fn k_cut(
&self,
graph: &AdjacencyMatrix,
k: usize,
) -> Result<Vec<MinCutResult>, TopologyError> {
// Recursive approach:
// 1. Find global mincut -> 2 partitions
// 2. Recursively find mincut in larger partition
// 3. Repeat until k partitions
todo!("Implement recursive k-cut")
}
fn incremental_update(
&self,
previous_cut: &MinCutResult,
changed_edges: &[(EdgeId, f64, f64)],
graph: &AdjacencyMatrix,
) -> Result<Option<MinCutResult>, TopologyError> {
// Heuristic: if no changed edge crosses the previous cut,
// and no weight changed by more than threshold, keep previous cut.
let cut_edge_set: std::collections::HashSet<_> =
previous_cut.cut_edges.iter().collect();
let significant_change = changed_edges.iter().any(|(edge, old, new)| {
let delta = (new - old).abs();
cut_edge_set.contains(edge) && delta > 0.1
});
if !significant_change {
return Ok(None); // Cut unchanged
}
// Recompute full mincut
self.min_cut(graph).map(Some)
}
}
8.5 边界插值 Trait¶
/// A polygon representing a physical boundary in 2D space.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BoundaryPolygon {
/// Vertices of the boundary polygon (meters, room coordinates).
pub vertices: Vec<Position2D>,
/// Confidence of this boundary (0.0 to 1.0).
pub confidence: f64,
/// Unique ID for tracking across frames.
pub boundary_id: u64,
/// Timestamp of detection.
pub detected_at_ms: u64,
}
/// Trait for converting graph cuts into spatial boundaries.
pub trait BoundaryInterpolator: Send + Sync {
/// Convert a minimum cut result into a spatial boundary polygon.
fn interpolate(
&self,
cut: &MinCutResult,
node_positions: &std::collections::HashMap<NodeId, Position2D>,
) -> Result<BoundaryPolygon, TopologyError>;
/// Smooth a boundary using previous frame's boundary (temporal filtering).
fn smooth(
&self,
current: &BoundaryPolygon,
previous: &BoundaryPolygon,
alpha: f64,
) -> BoundaryPolygon;
}
/// Midpoint interpolation: boundary passes through midpoints of cut edges.
pub struct MidpointInterpolator;
impl BoundaryInterpolator for MidpointInterpolator {
fn interpolate(
&self,
cut: &MinCutResult,
node_positions: &std::collections::HashMap<NodeId, Position2D>,
) -> Result<BoundaryPolygon, TopologyError> {
let mut midpoints: Vec<Position2D> = Vec::new();
for edge in &cut.cut_edges {
let pos_a = node_positions
.get(&edge.tx)
.ok_or(TopologyError::NodeNotFound(edge.tx))?;
let pos_b = node_positions
.get(&edge.rx)
.ok_or(TopologyError::NodeNotFound(edge.rx))?;
midpoints.push(Position2D {
x: (pos_a.x + pos_b.x) / 2.0,
y: (pos_a.y + pos_b.y) / 2.0,
});
}
// Order midpoints to form a non-self-intersecting polygon
// using angular sort around centroid
let cx: f64 = midpoints.iter().map(|p| p.x).sum::<f64>() / midpoints.len() as f64;
let cy: f64 = midpoints.iter().map(|p| p.y).sum::<f64>() / midpoints.len() as f64;
midpoints.sort_by(|a, b| {
let angle_a = (a.y - cy).atan2(a.x - cx);
let angle_b = (b.y - cy).atan2(b.x - cx);
angle_a.partial_cmp(&angle_b).unwrap()
});
Ok(BoundaryPolygon {
vertices: midpoints,
confidence: 1.0 - cut.cut_value, // lower cut value = more confident
boundary_id: 0, // assigned by tracker
detected_at_ms: 0, // set by caller
})
}
fn smooth(
&self,
current: &BoundaryPolygon,
previous: &BoundaryPolygon,
alpha: f64,
) -> BoundaryPolygon {
// Simple vertex-wise EMA when vertex counts match
if current.vertices.len() != previous.vertices.len() {
return current.clone();
}
let smoothed: Vec<Position2D> = current
.vertices
.iter()
.zip(previous.vertices.iter())
.map(|(c, p)| Position2D {
x: alpha * c.x + (1.0 - alpha) * p.x,
y: alpha * c.y + (1.0 - alpha) * p.y,
})
.collect();
BoundaryPolygon {
vertices: smoothed,
confidence: alpha * current.confidence + (1.0 - alpha) * previous.confidence,
boundary_id: current.boundary_id,
detected_at_ms: current.detected_at_ms,
}
}
}
8.6 管道编排器¶
/// The main pipeline that ties all stages together.
pub struct TopologyPipeline {
graph: Box<dyn TopologyGraph>,
weight_computer: Box<dyn EdgeWeightComputer>,
mincut_solver: Box<dyn MinCutSolver>,
boundary_interpolator: Box<dyn BoundaryInterpolator>,
event_tx: tokio::sync::broadcast::Sender<TopologyEvent>,
config: PipelineConfig,
baselines: std::collections::HashMap<EdgeId, CsiFrame>,
last_cut: Option<MinCutResult>,
last_boundary: Option<BoundaryPolygon>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PipelineConfig {
/// Maximum age before an edge is pruned.
pub stale_edge_timeout_ms: u64,
/// Edge weight computation config.
pub edge_weight: EdgeWeightConfig,
/// Minimum cut value change to trigger boundary update.
pub cut_change_threshold: f64,
/// Temporal smoothing factor for boundary polygon.
pub boundary_smoothing_alpha: f64,
/// Maximum number of simultaneous boundaries to track.
pub max_boundaries: usize,
}
impl TopologyPipeline {
/// Process a batch of CSI frames from one TDM cycle.
///
/// This is the main entry point, called once per TDM cycle.
/// Returns all topology events generated during processing.
pub async fn process_cycle(
&mut self,
frames: Vec<CsiFrame>,
) -> Result<Vec<TopologyEvent>, TopologyError> {
let mut all_events = Vec::new();
// Stage 2-3: Compute edge weights and update graph (parallel)
let weights: Vec<(EdgeId, EdgeWeight)> = frames
.par_iter()
.filter_map(|frame| {
let edge = EdgeId::canonical(
NodeId(frame.tx_id),
NodeId(frame.rx_id),
);
let baseline = self.baselines.get(&edge)?;
let weight = self.weight_computer
.compute(frame, baseline, &self.config.edge_weight)
.ok()?;
Some((edge, weight))
})
.collect();
// Stage 3: Update graph
let mut changed_edges = Vec::new();
for (edge_id, weight) in &weights {
let old_weight = self.graph
.edge_weight(*edge_id)
.map(|w| w.weight)
.unwrap_or(1.0);
let events = self.graph.update_edge(*edge_id, weight.clone())?;
changed_edges.push((*edge_id, old_weight, weight.weight));
all_events.extend(events);
}
// Prune stale edges
let stale_timeout =
std::time::Duration::from_millis(self.config.stale_edge_timeout_ms);
let prune_events = self.graph.prune_stale(stale_timeout);
all_events.extend(prune_events);
// Stage 4: Mincut
let adjacency = self.graph.adjacency_matrix();
let cut_result = if let Some(ref prev_cut) = self.last_cut {
self.mincut_solver
.incremental_update(prev_cut, &changed_edges, &adjacency)?
.unwrap_or_else(|| prev_cut.clone())
} else {
self.mincut_solver.min_cut(&adjacency)?
};
self.last_cut = Some(cut_result.clone());
// Stage 5: Boundary interpolation
let node_positions = self.node_position_map();
let mut boundary = self
.boundary_interpolator
.interpolate(&cut_result, &node_positions)?;
// Temporal smoothing
if let Some(ref prev_boundary) = self.last_boundary {
boundary = self.boundary_interpolator.smooth(
&boundary,
prev_boundary,
self.config.boundary_smoothing_alpha,
);
}
self.last_boundary = Some(boundary.clone());
// Emit boundary event
all_events.push(TopologyEvent {
id: EventId::new(),
timestamp: std::time::Instant::now(),
kind: TopologyEventKind::BoundaryDetected {
boundary: CutBoundary {
cut_edges: cut_result.cut_edges,
cut_value: cut_result.cut_value,
partition_a: cut_result.partition_a,
partition_b: cut_result.partition_b,
spatial_boundary: Some(boundary),
confidence: cut_result.cut_value,
detected_at: std::time::Instant::now(),
},
},
});
// Broadcast events
for event in &all_events {
let _ = self.event_tx.send(event.clone());
}
Ok(all_events)
}
fn node_position_map(&self) -> std::collections::HashMap<NodeId, Position2D> {
// Build from graph's node registry
todo!("Extract node positions from graph")
}
}
8.7 错误类型¶
/// Errors that can occur in the topology pipeline.
#[derive(Debug, thiserror::Error)]
pub enum TopologyError {
#[error("Node not found: {0:?}")]
NodeNotFound(NodeId),
#[error("Edge not found: {0:?} -> {1:?}")]
EdgeNotFound(NodeId, NodeId),
#[error("Graph is disconnected: {0} components")]
GraphDisconnected(usize),
#[error("Insufficient nodes for mincut: need >= 2, have {0}")]
InsufficientNodes(usize),
#[error("Baseline not available for edge {0:?}")]
NoBaseline(EdgeId),
#[error("CSI frame invalid: {0}")]
InvalidCsiFrame(String),
#[error("Mincut solver failed: {0}")]
SolverError(String),
#[error("Calibration required: {0}")]
CalibrationRequired(String),
}
8.8 邻接矩阵¶
/// Dense adjacency matrix for mincut computation.
///
/// Uses a flat Vec<f64> for cache-friendly access. Indexed as
/// matrix[row * dimension + col].
#[derive(Debug, Clone)]
pub struct AdjacencyMatrix {
/// Node IDs in index order.
pub nodes: Vec<NodeId>,
/// Flat weight matrix (dimension x dimension).
pub weights: Vec<f64>,
/// Matrix dimension (= nodes.len()).
pub dimension: usize,
}
impl AdjacencyMatrix {
pub fn new(nodes: Vec<NodeId>) -> Self {
let dim = nodes.len();
Self {
nodes,
weights: vec![0.0; dim * dim],
dimension: dim,
}
}
pub fn get(&self, row: usize, col: usize) -> f64 {
self.weights[row * self.dimension + col]
}
pub fn set(&mut self, row: usize, col: usize, value: f64) {
self.weights[row * self.dimension + col] = value;
self.weights[col * self.dimension + row] = value; // symmetric
}
/// Find the index of a node, or None if not present.
pub fn node_index(&self, id: NodeId) -> Option<usize> {
self.nodes.iter().position(|n| *n == id)
}
}
附录 A:术语表¶
| 术语 | 定义 |
|---|---|
| CSI | 信道状态信息 -- 每子载波复振幅 |
| TDM | 时分复用 -- 无冲突 TX 调度 |
| Mincut | 最小割 -- 使总边权最小的图划分 |
| Stoer-Wagner | 确定性 O(VE + V^2 log V) 最小割算法 |
| 边权 | TX-RX 链路上的相干性度量;低 = 受阻 |
| 边界 | 最小割边与物理空间相交的空间区域 |
| 聚合根 | DDD 模式 -- 一致性边界的单一入口 |
| EMA | 指数移动平均 -- 时间平滑滤波器 |
附录 B:相关 ADR¶
| ADR | 标题 | 相关性 |
|---|---|---|
| 014 | SOTA 信号处理 | 相干性和相位算法 |
| 028 | ESP32 能力审计 | 硬件约束和 TDM |
| 029 | RuvSense 多静态感知 | 多链路融合架构 |
| 030 | RuvSense 持久场模型 | 基线校准方法 |
| 031 | RuView 感知优先 RF 模式 | UI 集成模式 |
| 044 | RF 拓扑感知(本文档) | 架构决策 |
附录 C:开放问题¶
-
Stoer-Wagner 与 Push-Relabel:哪种最小割算法更适合增量更新?Push-relabel 可能允许从先前流解进行热启动。
-
多人消歧:当 k-cut 找到多个边界时,我们如何跨帧关联边界?空间坐标中的最近邻?边界质心上的匈牙利算法?
-
3D 扩展:当前设计是 2D(节点位于固定高度)。我们能否通过将节点放置在多个高度来扩展到 3D?这如何影响最小割解释?
-
家具与人员:两者都会衰减 CSI。基线校准处理静态家具,但移动的椅子怎么办?具有慢漂移跟踪的自适应基线(ruvsense/longitudinal.rs)可能有帮助。
-
最优节点放置:给定房间几何形状,N 个节点应放置在哪里以最大化边界分辨率?这与传感器放置优化以及来自 ruvector/viewpoint/geometry.rs 的费雪信息相关。
-
规模化延迟:100ms 预算假设本地处理。如果图数据必须通过网络传输(多房间、阶段 3),我们如何维持延迟?当前提案是分层分解,每个房间进行本地最小割。
研究文档 10 结束
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 wi/RuView