|
ESPectre SDK 2.8.0-280-gac7af68
Wi-Fi CSI motion sensing for ESP32 firmware
|
The default detector: self-calibrating, no training data required. More...
#include <lightweight_detector.h>
Public Member Functions | |
| LightweightDetector (uint16_t window_size=DETECTOR_DEFAULT_WINDOW_SIZE, float threshold=LIGHTWEIGHT_DEFAULT_THRESHOLD, uint16_t autocorr_lag=1U) | |
| ~LightweightDetector () override=default | |
| LightweightDetector (LightweightDetector &&other) noexcept=default | |
| LightweightDetector & | operator= (LightweightDetector &&other) noexcept=default |
| LightweightDetector (const LightweightDetector &)=delete | |
| LightweightDetector & | operator= (const LightweightDetector &)=delete |
| void | process_packet (const int8_t *csi_data, size_t csi_len, const uint8_t *selected_subcarriers=nullptr, uint8_t num_subcarriers=0, int8_t rssi_dbm=INT8_MIN) override |
| Process a CSI packet and update internal state. | |
| void | advance_missing_slots (uint32_t count) override |
| Advance packet-indexed feature rings for absent temporal slots. | |
| void | update_state () override |
| Update state machine (call at publish interval). | |
| void | reset () override |
| Reset detector state. | |
| void | clear_buffer () override |
| Clear turbulence buffer (cold restart). | |
| void | configure_hampel (bool enabled, uint8_t window_size=HAMPEL_TURBULENCE_WINDOW_DEFAULT, float threshold=HAMPEL_TURBULENCE_THRESHOLD_DEFAULT) override |
| Configure Hampel filter. | |
| void | configure_lowpass (bool enabled, float cutoff_hz=LOWPASS_CUTOFF_DEFAULT) override |
| Configure low-pass filter. | |
| bool | is_ready () const override |
| Check if detector is ready (buffer filled). | |
| bool | set_threshold (float threshold) override |
| Set detection threshold. | |
| bool | set_adaptive_threshold (float threshold) override |
| Apply a detector-specific startup-calibrated threshold. | |
| float | get_threshold () const override |
| Get current threshold. | |
| const char * | get_name () const override |
| Get detector name for logging. | |
| float | get_startup_threshold_factor () const override |
| Get the detector-specific automatic startup multiplier. | |
| bool | startup_gate_enabled () const override |
| Whether startup calibration uses the consistency gate (threshold.h). | |
| void | on_startup_calibration_begin () override |
| Hook called immediately before startup calibration begins. | |
| void | on_startup_calibration_complete () override |
| Hook called when startup calibration completes successfully. | |
| float | get_turb_autocorr () const |
| float | get_turb_iqr_over_mean_aggr () const |
| float | get_logit () const |
| Public Member Functions inherited from espectre::BaseDetector | |
| BaseDetector (uint16_t window_size=DETECTOR_DEFAULT_WINDOW_SIZE) | |
| Constructor. | |
| virtual | ~BaseDetector () |
| BaseDetector (BaseDetector &&other) noexcept | |
| BaseDetector & | operator= (BaseDetector &&other) noexcept |
| BaseDetector (const BaseDetector &)=delete | |
| BaseDetector & | operator= (const BaseDetector &)=delete |
| void | set_packet_timestamp_us (uint64_t timestamp_us) |
| Supply the monotonic arrival timestamp consumed by time-binned features. | |
| virtual MotionState | get_state () const |
| Get current motion state. | |
| void | set_minimum_valid_samples (uint16_t count) |
| Set the valid-slot occupancy floor used by is_ready(). | |
| virtual uint32_t | get_total_packets () const |
| Get total packets processed. | |
| float | get_motion_metric () const |
| Get current motion metric value. | |
| const float * | get_turbulence_buffer () const |
| Get turbulence buffer pointer. | |
| uint16_t | get_buffer_count () const |
| Get number of valid samples in buffer. | |
| uint16_t | get_valid_buffer_count () const |
| uint16_t | get_window_size () const |
| Get configured window size. | |
| float | get_last_turbulence () const |
| Get last turbulence value. | |
| bool | is_lowpass_enabled () const |
| Check if low-pass filter is enabled. | |
| bool | is_hampel_enabled () const |
| Check if Hampel filter is enabled. | |
Additional Inherited Members | |
| Protected Member Functions inherited from espectre::BaseDetector | |
| void | clear_evaluation_state_ () |
| Drop the last evaluation result. | |
| void | process_amplitudes (const float *amplitudes, uint8_t count) |
| uint64_t | packet_timestamp_us_or (uint64_t fallback) const |
| void | add_turbulence_to_buffer (float turbulence) |
| Add turbulence value to buffer (with filtering). | |
| const float * | ordered_turbulence (uint16_t &count) const |
| View the turbulence ring in chronological order. | |
| Static Protected Member Functions inherited from espectre::BaseDetector | |
| static float * | alloc_zeroed_floats (uint16_t count) |
| Allocate a zeroed float buffer on the heap. | |
| Protected Attributes inherited from espectre::BaseDetector | |
| float * | turbulence_buffer_ |
| float * | ordered_turbulence_ |
| uint16_t | buffer_index_ |
| uint16_t | buffer_count_ |
| uint16_t | valid_buffer_count_ |
| uint16_t | minimum_valid_samples_ |
| uint16_t | window_size_ |
| MotionState | state_ |
| float | current_metric_ |
| uint32_t | total_packets_ |
| uint32_t | packet_index_ |
| uint64_t | packet_timestamp_us_ |
| bool | has_packet_timestamp_ |
| hampel_filter_state_t | hampel_state_ |
| lowpass_filter_state_t | lowpass_state_ |
The default detector: self-calibrating, no training data required.
Fuses turbulence autocorrelation with robust spread from a five-bin aggregated turbulence stream, and adapts its threshold to the room during startup calibration. After that, a long quiet stretch can still lower the live threshold when the opening was noisier than the rest of the session. The full runtime emits IRuntimeListener::on_threshold_changed() for that drop; a core-only integration must re-read get_threshold() after update_state(). Prefer it unless you have a reason to run HighAccuracyDetector.
Most integrations never construct one: RuntimeConfig::detection_algorithm selects it and the runtime owns the lifecycle. Drive it directly only on the core-only path, where your firmware already captures CSI:
is_ready() is false until the window fills; results before that are not meaningful. See runtime/esp_idf/csi_pipeline.cpp for the reference normalization, cadence, and hit filtering around these calls, and docs/ALGORITHMS.md for the algorithm itself.
Definition at line 83 of file lightweight_detector.h.
| espectre::LightweightDetector::LightweightDetector | ( | uint16_t | window_size = DETECTOR_DEFAULT_WINDOW_SIZE, |
| float | threshold = LIGHTWEIGHT_DEFAULT_THRESHOLD, | ||
| uint16_t | autocorr_lag = 1U ) |
| window_size | Detector window in packets |
| threshold | Motion probability threshold |
| autocorr_lag | Turbulence autocorrelation distance in packets |
Production uses the nominal-rate default. Alternate lags are exposed for replay experiments only: changing the feature offset requires validating the fitted coefficients before deployment. See detector_timing.h.
|
overridedefault |
|
defaultnoexcept |
|
delete |
|
defaultnoexcept |
|
delete |
|
overridevirtual |
Process a CSI packet and update internal state.
Calculates spatial turbulence from CSI data, applies filtering, and stores in circular buffer.
| csi_data | Raw CSI data (I/Q interleaved) |
| csi_len | Length of CSI data |
| selected_subcarriers | Array of subcarrier indices |
| num_subcarriers | Number of selected subcarriers |
| rssi_dbm | Link RSSI for this packet, or INT8_MIN when unknown |
Reimplemented from espectre::BaseDetector.
|
overridevirtual |
Advance packet-indexed feature rings for absent temporal slots.
Reimplemented from espectre::BaseDetector.
|
overridevirtual |
Update state machine (call at publish interval).
Subclasses implement their detection algorithm here.
Implements espectre::BaseDetector.
|
overridevirtual |
Reset detector state.
Resets state machine but preserves buffer ("warm" restart).
Reimplemented from espectre::BaseDetector.
|
overridevirtual |
Clear turbulence buffer (cold restart).
Virtual so detectors with additional state (e.g. L1-Delta profile rings) can extend the cold clear.
Reimplemented from espectre::BaseDetector.
|
overridevirtual |
Configure Hampel filter.
| enabled | Whether to enable the filter |
| window_size | Window size (3-11) |
| threshold | MAD multiplier threshold |
Reimplemented from espectre::BaseDetector.
|
overridevirtual |
Configure low-pass filter.
| enabled | Whether to enable the filter |
| cutoff_hz | Cutoff frequency (5.0-20.0 Hz) |
Reimplemented from espectre::BaseDetector.
|
overridevirtual |
Check if detector is ready (buffer filled).
Reimplemented from espectre::BaseDetector.
|
overridevirtual |
Set detection threshold.
| threshold | New threshold value |
Implements espectre::BaseDetector.
|
overridevirtual |
Apply a detector-specific startup-calibrated threshold.
Reimplemented from espectre::BaseDetector.
|
inlineoverridevirtual |
Get current threshold.
Implements espectre::BaseDetector.
Definition at line 120 of file lightweight_detector.h.
|
inlineoverridevirtual |
Get detector name for logging.
Implements espectre::BaseDetector.
Definition at line 121 of file lightweight_detector.h.
|
inlineoverridevirtual |
Get the detector-specific automatic startup multiplier.
threshold = threshold_metric x factor. Matches the Python runtime's detector STARTUP_THRESHOLD_FACTOR convention, where threshold_metric comes from the shared startup calibrator.
Reimplemented from espectre::BaseDetector.
Definition at line 122 of file lightweight_detector.h.
|
inlineoverridevirtual |
Whether startup calibration uses the consistency gate (threshold.h).
Enabled only for detectors with a tight quiet floor (l1_delta). Matches the Python runtime's detector STARTUP_GATE convention.
Reimplemented from espectre::BaseDetector.
Definition at line 125 of file lightweight_detector.h.
|
overridevirtual |
Hook called immediately before startup calibration begins.
Reimplemented from espectre::BaseDetector.
|
overridevirtual |
Hook called when startup calibration completes successfully.
Detectors can freeze session-specific state here before the runtime performs its warm clear between calibration and steady-state detection.
Reimplemented from espectre::BaseDetector.
|
inline |
Definition at line 129 of file lightweight_detector.h.
|
inline |
Definition at line 130 of file lightweight_detector.h.
|
inline |
Definition at line 131 of file lightweight_detector.h.