Skip to content

fix(sensing-server): person count hysteresis to stop flickering#295

Merged
ruvnet merged 1 commit intomainfrom
fix/person-count-hysteresis
Mar 24, 2026
Merged

fix(sensing-server): person count hysteresis to stop flickering#295
ruvnet merged 1 commit intomainfrom
fix/person-count-hysteresis

Conversation

@ruvnet
Copy link
Owner

@ruvnet ruvnet commented Mar 24, 2026

Summary

  • Raised person-count thresholds: 1→2 at 0.65 (was 0.50), 2→3 at 0.85 (was 0.80) — multipath in small rooms was easily triggering false 2-person detection
  • Added real hysteresis: asymmetric down-thresholds (2→1 at 0.45, 3→2 at 0.70) with prev_person_count state tracking — prevents oscillation at boundaries
  • Increased EMA smoothing: α reduced from 0.15 to 0.10 (~2s time constant at 20 Hz)
  • All 4 sensing pipelines updated: ESP32 UDP, Windows WiFi, multi-BSSID, and simulated

Fixes #292 #280 #237

What was wrong

The score_to_person_count function had no state — despite comments claiming "asymmetric thresholds," it was just flat threshold checks. With the 0.50 threshold for 2 persons, multipath reflections in rooms <10 m² routinely exceeded this, causing the person count to flicker between 1 and 2+. This was the #1 reported issue across multiple users with different hardware setups.

Test plan

  • cargo check -p wifi-densepose-sensing-server --no-default-features — compiles clean
  • Verify with ESP32 hardware: 1 person in room should show stable count=1 (no flickering to 2)
  • Verify 2+ persons: count should transition to 2 only with sustained high-variance signal
  • Verify count drops back to 1 only when score falls below 0.45 (not immediately at 0.65)

🤖 Generated with claude-flow

The person-count heuristic was causing widespread flickering (#237, #249,
#280, #292) because:

1. Threshold 0.50 for 2-persons was too low — multipath reflections in
   small rooms easily exceeded it
2. No actual hysteresis despite the comment claiming asymmetric thresholds
3. EMA smoothing (α=0.15) was too responsive to transient spikes

Changes:
- Raise up-thresholds: 1→2 persons at 0.65 (was 0.50), 2→3 at 0.85 (was 0.80)
- Add true hysteresis with asymmetric down-thresholds: 2→1 at 0.45, 3→2 at 0.70
- Track prev_person_count in SensingState for state-aware transitions
- Increase EMA smoothing to α=0.10 (~2s time constant at 20 Hz)
- Update all 4 call sites (ESP32, Windows WiFi, multi-BSSID, simulated)

Fixes #292, #280, #237

Co-Authored-By: claude-flow <ruv@ruv.net>
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.

ESP32-S3 nodes unstable detection (flickering persons, no stable tracking)

1 participant