Formerly BlackBox_CSV_Render.
This is an experimental RUST program, mostly created via A.I., to read Betaflight/EmuFlight Blackbox BBL, BFL, or CSV logs and produce meaningful graphs.
- Rust installation page
- Optional:
.BBL/.BFLfiles are read directly. Multi-flight files can produce one report per eligible flight; low-value flights are skipped unless-F/--force-exportis used. Manual blackbox_decode preprocessing to CSV is only needed for its selective-extraction flags (--save-headers,--index <num>,--limits).
cargo build --releaseNotice: Default output is core plots only. Use
--extendedfor all plots.
Analyze Betaflight/EmuFlight Blackbox logs (BBL, BFL, or CSV); render plots and a report.
Usage: ./blackbox_analyzer <input1> [<input2> ...] [OPTIONS]
--- INPUT/OUTPUT OPTIONS ---
<inputX>: CSV, BBL, or BFL files, directories, or wildcards (*.csv, *.bbl, *.bfl). Header
files auto-excluded. A multi-flight .bbl/.bfl can produce one report per eligible flight.
An input with the same bytes as an earlier one is skipped; a different log with the
same file name gets a `_2` suffix. Output names never get a folder prefix.
-O, --output-dir <directory>: Output directory (default: source folder).
-R, --recursive: Recursively find CSV/BBL/BFL files in subdirectories.
-F, --force-export: Export .bbl/.bfl flights bbl_parser would otherwise skip as
low-value (very short / low data density / minimal gyro activity).
-K, --keep: Keep the exported .csv/.headers.csv files (source folder, or
-O/--output-dir). A later --keep run uses an existing export (CSV and
.headers.csv) instead of decoding; -F/--force-export re-extracts.
--- PLOT TYPE SELECTION ---
--core [default] Step Response, Gyro Spectrums, D-term Spectrums,
Setpoint vs Gyro, Gyro vs Unfiltered, Motor Spectrums,
RC Command Activity.
--extended All plots except Bode — adds PIDsum/Error, PID Activity,
Setpoint Derivative, Gyro PSD, D-term PSD, heatmaps, and
Motor vs eRPM (requires bidirectional DShot telemetry).
--step Step response only.
--bode Bode only (requires chirp/sweep system-id test flight).
--desync Motor vs eRPM plot only (needs eRPM telemetry). Desync
detection itself (Fallback tier) still runs without it.
--- ANALYSIS OPTIONS ---
--butterworth Show Butterworth PT1 cutoffs on gyro/D-term spectrum plots.
--dps <value> Deg/s threshold for detailed step response plots (positive number).
--estimate-optimal-p [EXPERIMENTAL] Optimal P estimation from throttle-punch
dynamics; needs 5+ punches (one log or pooled group).
Requires header metadata (.headers.csv or embedded); skips if absent.
Its Td target always profiles the full file, ignoring
--start/--end; only its Td measurement is trimmed.
--- TIME WINDOW ---
--start <seconds> Trim analysis to this offset onward, relative to the
start of the log. Omit to start at the log start.
--end <seconds> Trim analysis up to this offset, relative to the
start of the log. Omit to end at the log end.
Independent — use either or both. Applies before every
analysis and plot (step response may skip if the
trimmed window is too short).
--- GENERAL ---
--debug Show detailed metadata during processing.
-h, --help Show this help message and exit.
-V, --version Show version information.Arguments can be in any order. Wildcards (e.g., *.csv) are shell-expanded and work with mixed file/directory patterns.
A command-line argument that is not valid Unicode is reported on stderr and skipped, the remaining inputs are still processed, and the exit status is 1. If the invalid argument is the value of --dps, --output-dir/-O, --start or --end, the run stops with exit status 1 before processing. A filename with invalid UTF-8 bytes found by a directory scan is skipped with a warning.
For a valid invocation, a failure on one input never stops the remaining inputs, so bulk and recursive runs finish and write all outputs they can; the exit status then reports whether anything failed.
0: every log that was read succeeded. Warnings do not change it: flights skipped by the low-value filter (with--estimate-optimal-p, filtering that leaves no input prints a notice and also exits0, provided no input, decode or export failure occurred), header CSVs, unsupported files, and unreadable entries found while scanning a directory (for example a dangling symlink).1: invalid arguments, no input files found, or at least one input failed: a path you named does not exist or cannot be processed, a command-line argument is not valid Unicode, a log cannot be parsed or has no data rows, a.bbl/.bfldecode or flight export failure, or a--start/--endwindow that is out of range for a log. The reason is printed to stderr, and if discovery produced at least one input the run ends withSome files could not be processed successfully.
./target/release/blackbox_analyzer path/to/BTFL_Log.csv./target/release/blackbox_analyzer path/to/EMUF_Log.BBL./target/release/blackbox_analyzer path/to/*LOG*.csv --dps 500 --butterworth./target/release/blackbox_analyzer path1/to/BTFL_*.csv path2/to/EMUF_*.csv --output-dir ./plots --butterworth./target/release/blackbox_analyzer path/to/ -R --step --output-dir ./step-only./target/release/blackbox_analyzer path/to/ --extended --output-dir ./all-plots./target/release/blackbox_analyzer path/to/BTFL_Log.csv --step --estimate-optimal-p./target/release/blackbox_analyzer path/to/BTFL_Log.csv --start 40 --desync--start/--end are seconds relative to the start of the log (0s = log start). Trimming drops
every row outside the window before any plot or analysis runs, so it affects every Phase 2
analysis and plot — except --estimate-optimal-p's Phase 1 aircraft profiling, which always
re-reads the full file regardless of --start/--end, and Motor Desync Detection's baseline
statistics, which are always computed from the full log even when a window is applied (see both
caveats below).
General workflow:
- Run the full log first (no
--start/--end). A run printsNote: Log spans absolute time Xs-Ys (duration Ds)whenever the log has a positive duration (both a first and last timestamp, with the last one later) — that line is informational only, for cross-referencing against OSD/video overlays that also show raw flight-controller uptime. A one-row log, or one where every row shares the same timestamp, has no duration and omits this line —--start/--endaren't meaningful there either. Every plot, and every report table timestamp (e.g. thePossible/De Facto/Fallback"Times (s)" column in the Motor Desync Detection report), reads on the same0s-at-log-start timeline as--start/--end— pass the event's timestamp straight to--start/--endwith margin, no subtraction needed (e.g. event at9.85s→--startaround9.0or earlier for margin). - Trim with real margin before that timestamp — don't cut the window right up against the event. Re-run and compare the plot to the full-log version.
- If a report table's flag depends on a statistic computed only from the trimmed window itself
(e.g. an axis's percentile-based classification), confirm the flag still appears after
trimming. If it disappeared, move
--startearlier (more margin) and re-check — the boundary between "flag holds" and "flag disappears" isn't a fixed number of seconds and can flip on trim values close together. Motor Desync Detection is exempt from this: see below.
Motor Desync Detection specifically: its baseline statistics always use the full, untrimmed
log, regardless of --start/--end — only which flagged events get reported is restricted to
the trimmed window. A tight trim can therefore make the Motor_vs_eRPM plot readable without
losing the table flag. --estimate-optimal-p similarly still splits across trim and no-trim — see
the Phase 1/Phase 2 note above. See OVERVIEW.md for the exact
per-tier baseline mechanics.
Core (default):
*_Step_Response_stacked_plot_*.png— Step response analysis with P:D recommendations; axes with non-zero parsed F-term samples are titled "Invalid due to Feed-Forward"*_SetpointVsGyro_stacked.png— Setpoint vs. filtered gyro comparison*_GyroVsUnfilt_stacked.png— Filtered vs. unfiltered gyro comparison with delay estimates*_Gyro_Spectrums_comparative.png— Frequency-domain gyro amplitude spectrums*_D_Term_Spectrums_comparative.png— Frequency-domain D-term amplitude spectrums*_Motor_Spectrums_stacked.png— Motor output frequency analysis (supports any motor count; colors wrap every 8 motors)*_RC_Command_Activity_stacked.png— Setpoint vs. RC Command overlay per axis; visualizes blocky/unfiltered stick input against the flight controller's response
Extended (--extended adds these to the core set):
*_PIDsum_PIDerror_Setpoint_stacked.png— PIDsum, PID error, and setpoint traces*_PID_Activity_stacked.png— P, I, D term activity over time*_SetpointDerivative_stacked.png— Setpoint rate-of-change / feed-forward proxy*_Gyro_PSD_comparative.png— Gyro power spectral density (dB scale)*_D_Term_PSD_comparative.png— D-term power spectral density (dB scale)*_D_Term_Heatmap_comparative.png— D-term throttle/frequency heatmap*_Gyro_PSD_Spectrogram_comparative.png— Gyro spectrogram (PSD vs. time)*_Throttle_Freq_Heatmap_comparative.png— Throttle/frequency heatmap analysis*_Motor_vs_eRPM_stacked.png— One row per motor, commanded output and eRPM telemetry overlaid, each normalized to its own 0-100% range; vertical markers at every Motor Desync Detection event timestamp. Skipped when the log has no eRPM telemetry.
*_report.md— Structured flight report written alongside PNGs on every run. Sections: Metadata, Gyro Filter Configuration, PID Tuning, Step Response Analysis, Gyro Analysis, D-Term Analysis, Motor Oscillation, Motor Desync Detection, Stick Input Smoothness, Stick Position & Rate Analysis, PNG links, and a Skipped Plots list. Optimal P Estimation and Bode Analysis sections appear when those features are active. See OVERVIEW.md for exact per-section content and omission conditions.
- Current P:D ratio and peak analysis with response assessment
- Conservative and Moderate tuning recommendations (with D/D-Min/D-Max values)
- Warning indicators for severe overshoot or unreasonable ratios
- Gyro filtering delay estimates (filtered vs. unfiltered, with confidence)
- Filter configuration parsing and spectrum peak detection summaries
- Optimal P estimation (
--estimate-optimal-p): Td timing, target deviation, noise level, consistency, P/D recommendations and skip-reason warnings - Use
--debugflag for additional metadata: header information, flight data key mapping, sample header values, and debug mode identification
For a detailed explanation of the program's functionality, especially the step-response calculation and comparison with other tools like PIDtoolbox (Matlab) and PlasmaTree PID-Analyzer (Python), please see OVERVIEW.md.
To set up your development environment with proper formatting and pre-commit hooks:
# Clone and setup
git clone https://github.com/nerdCopter/blackbox_analyzer.git
cd blackbox_analyzer
# Run setup script (optional but recommended)
chmod +x .github/setup-dev.sh
./.github/setup-dev.sh# 1. Check for clippy warnings (must be fixed first)
cargo clippy --all-targets --all-features -- -D warnings
# 2. Format code
cargo fmt --all
# 3. Check formatting compliance
cargo fmt --all -- --check
# 4. Run all tests
cargo test --verbose
# 5. Build release
cargo build --releaseThe development setup includes an automated pre-commit hook that will:
- Automatically format your code with
cargo fmt - Run clippy checks to catch code issues
- Prevent commits with formatting issues
The project enforces strict formatting and code quality standards.
This project is dual-licensed under the terms of the AGPL-3.0-or-later and a commercial license.
-
AGPL-3.0-or-later: You may use, distribute, and modify this software under the terms of the GNU Affero General Public License, version 3 or any later version. The full license text is available in the LICENSE file.
-
Commercial License: If you wish to use this software in a commercial product without being bound by the terms of the AGPL, you must purchase a commercial license. For more information, please see the LICENSE_COMMERCIAL file.