Skip to content

fix: make v1 Python API runnable on WSL2 with real WiFi sensing#150

Open
SabaPivot wants to merge 1 commit intoruvnet:mainfrom
SabaPivot:fix/v1-api-runnable-wsl2
Open

fix: make v1 Python API runnable on WSL2 with real WiFi sensing#150
SabaPivot wants to merge 1 commit intoruvnet:mainfrom
SabaPivot:fix/v1-api-runnable-wsl2

Conversation

@SabaPivot
Copy link

Summary

The v1 Python API had several issues that prevented it from starting and serving real-time data. This PR fixes all of them and adds WSL2 WiFi sensing support so the Live Demo and Sensing tabs work end-to-end with real WiFi signals.

Bug Fixes

  • datetime serialization — 4 places in pose_service.py put raw datetime objects into dicts broadcast via WebSocket, causing TypeError: Object of type datetime is not JSON serializable. Fixed with .isoformat().
  • Zone confidence averaging — formula (0 + confidence) / 2 always halved the first person's confidence, causing values to fall below the stream filter threshold. Replaced with proper incremental mean.
  • CORS/allowed_hosts parsingSettings declared cors_origins and allowed_hosts as List[str], but .env provides plain strings. Added _list properties that accept both JSON arrays and comma-separated strings.
  • Health endpoint 503request.app.state.hardware_service was never set because the orchestrator stored services only on self. Added service bridge in lifespan.
  • Module import paths — 5 sensing files used from v1.src.sensing.* which fails when running from inside v1/. Fixed to from src.sensing.*.
  • PyTorch hard dependencypose_service.py imported torch at module level, crashing the API if PyTorch wasn't installed. Made it lazy-import on demand.

Features

  • WSL2 WiFi supportWindowsWifiCollector auto-detects WSL2 and uses netsh.exe; parses Korean-locale output fields (신호, 수신 속도, 전송 속도); captures throughput rates as additional metrics.
  • RSSI ditheringnetsh reports integer dBm, producing variance=0 and collapsing all spectral features. Added Gaussian dithering (σ=0.3 dBm) to overcome quantization, a standard signal processing technique for quantized ADCs.
  • Signal-derived pose streampose_stream.py connects to the sensing WebSocket (ws://localhost:8765) and converts presence/motion classification into COCO 17-keypoint pose data, so the Live Demo shows real WiFi-based detection.
  • WebSocket proxy/ws/sensing endpoint in app.py bridges the UI to the sensing server, eliminating cross-origin WebSocket issues.
  • Static UI serving — UI served at /app/ so everything runs from a single uvicorn process.
  • Live source recognition — UI sensing service now recognizes windows_wifi, linux_wifi, and macos_wifi as live data sources.

Test Plan

  • All imports resolve correctly (from src.sensing.*)
  • Settings parsing works with both JSON arrays and comma-separated strings
  • _sensing_to_pose() returns valid 17-keypoint data when present, None when absent
  • Confidence incremental mean produces correct averages
  • WindowsWifiCollector initializes with dithering on WSL2
  • Sensing tab shows live RSSI with non-zero features
  • Live Demo receives pose frames and renders on canvas
  • Health endpoint returns all services healthy

Fixes multiple issues that prevented the v1 API from starting and
serving real-time pose/sensing data end-to-end:

Bug fixes:
- Fix datetime serialization in pose_service (4 locations) — raw
  datetime objects in dicts caused TypeError on WebSocket send_json
- Fix zone confidence averaging — use incremental mean instead of
  broken (0 + value) / 2 formula that always halved confidence
- Fix CORS/allowed_hosts parsing — settings expected List[str] but
  .env provides strings; add flexible parsing via _list properties
- Bridge orchestrator services to app.state so health endpoint works
- Fix sensing module imports: v1.src.sensing → src.sensing (5 files)
- Lazy-import torch in pose_service so API starts without PyTorch

Features:
- WSL2 support: WindowsWifiCollector auto-detects WSL2 and uses
  netsh.exe; parses Korean-locale output (신호, 수신 속도, etc.)
- RSSI dithering (σ=0.3 dBm) overcomes integer-dBm quantization
  from netsh, enabling meaningful feature extraction from flat signals
- Signal-derived pose stream: pose_stream.py connects to sensing
  WebSocket and converts presence/motion classification into COCO
  17-keypoint pose data for the Live Demo canvas
- WebSocket proxy /ws/sensing in app.py bridges UI to sensing server
- Static file serving for UI at /app/ path
- Sensing UI recognizes windows_wifi/linux_wifi/macos_wifi as live
  data sources with "REAL WIFI DATA" banner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant