{"record":{"id":"2a1192a6a2441c53","repo":"ruvnet/RuView","slug":"calibration-failed-e","errorCode":null,"errorMessage":"calibration failed: {e}","messagePattern":"calibration failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v2/crates/wifi-densepose-cli/src/calibrate.rs","lineNumber":214,"sourceCode":"        \"no\"\n    };\n    eprintln!(\n        \"[calibrate] {}/{} frames | z_med={:.2} z_max={:.2} | motion: {}\",\n        frames, target, score.amplitude_z_median, score.amplitude_z_max, motion_str\n    );\n}\n\n// ---------------------------------------------------------------------------\n// Finalise + persist\n// ---------------------------------------------------------------------------\n\nfn finalise_and_save(recorder: CalibrationRecorder, output: &str) -> Result<()> {\n    let frames = recorder.frames_recorded();\n    eprintln!(\"[calibrate] finalising baseline from {frames} frames…\");\n\n    let baseline: BaselineCalibration = recorder\n        .finalize()\n        .map_err(|e| anyhow::anyhow!(\"calibration failed: {e}\"))?;\n\n    let bytes = baseline.to_bytes();\n    std::fs::write(output, &bytes)\n        .map_err(|e| anyhow::anyhow!(\"cannot write {output}: {e}\"))?;\n\n    eprintln!(\n        \"[calibrate] baseline saved to {output} ({} bytes)\",\n        bytes.len()\n    );\n    eprintln!(\n        \"[calibrate] summary: frames={} tier={:?} subcarriers={}\",\n        baseline.frame_count,\n        baseline.tier,\n        baseline.subcarriers.len(),\n    );\n    Ok(())\n}\n","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/v2/crates/wifi-densepose-cli/src/calibrate.rs#L196-L232","documentation":"Raised by finalise_and_save when CalibrationRecorder::finalize() returns Err. finalize() (wifi-densepose-signal/src/ruvsense/calibration.rs:532) converts accumulated Welford statistics into a BaselineCalibration and its only failure mode is CalibrationError::InsufficientFrames, returned when fewer than config.min_frames CSI frames were recorded. The {e} payload states the recorded vs required frame counts.","triggerScenarios":"Running the calibrate command with a capture window too short for min_frames; the CSI node streaming nothing or intermittently (wrong UDP port, node down) so frames_recorded() stays below config.min_frames when finalise_and_save is reached.","commonSituations":"Fresh setups where firmware is not yet streaming to the CLI's UDP port; operator shortens the capture duration below what the node frame rate needs; Wi-Fi dropouts mid-capture; min_frames raised in CalibrationConfig without lengthening the capture.","solutions":["Confirm the node streams CSI to the port the CLI listens on and that the log line '[calibrate] finalising baseline from N frames…' shows N at or above min_frames","Extend the capture duration (or raise the node frame rate) so at least min_frames frames accumulate before finalization","Lower CalibrationConfig::min_frames if a shorter baseline is acceptable for your tier","Watch the live deviation output during recording; motion_flagged frames mean the room was not empty — restart the capture"],"exampleFix":"// before\nlet baseline: BaselineCalibration = recorder\n    .finalize()\n    .map_err(|e| anyhow::anyhow!(\"calibration failed: {e}\"))?;\n\n// after\nif (recorder.frames_recorded() as usize) < config.min_frames {\n    eprintln!(\n        \"[calibrate] only {} frames — need {}; capture longer\",\n        recorder.frames_recorded(),\n        config.min_frames\n    );\n}\nlet baseline: BaselineCalibration = recorder\n    .finalize()\n    .map_err(|e| anyhow::anyhow!(\"calibration failed: {e}\"))?;","handlingStrategy":"validation","validationCode":"use wifi_densepose_signal::ruvsense::calibration::{CalibrationConfig, CalibrationRecorder};\n\nfn ready_to_finalize(recorder: &CalibrationRecorder, cfg: &CalibrationConfig) -> bool {\n    (recorder.frames_recorded() as usize) >= cfg.min_frames\n}","typeGuard":null,"tryCatchPattern":"match recorder.finalize() {\n    Ok(baseline) => { /* persist */ }\n    Err(CalibrationError::InsufficientFrames { got, need }) => {\n        eprintln!(\"need {need} frames, recorded {got} — keep the room empty and capture longer\");\n    }\n    Err(e) => return Err(anyhow::anyhow!(\"calibration failed: {e}\")),\n}","preventionTips":["Monitor frames_recorded() during capture and only finalize once it exceeds min_frames","Confirm the CSI node's destination UDP port matches the CLI bind before a long capture","Treat motion_flagged frames during recording as a contaminated baseline — restart the capture"],"tags":["rust","calibration","csi","data-collection"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}