Skip to content

Commit 3e54f4f

Browse files
nerdCopterclaude
andauthored
refactor: core-only default output with --extended, --step, --bode CLI (#153)
* feat: refactor default outputs to core-only and consolidate CLI flags - Change default output to a "Core" set: Step Response, Spectrums, Tracking, and Latency. - Disable specialized plots (Heatmaps, PSD, Feedforward, and extended PID analysis) by default to reduce file clutter. - Consolidate PID Activity and PID Error plots under a single `--pid` flag. - Add granular flags for all core outputs (`--spectrums`, `--tracking`, `--gyro-filt`). - Introduce `--core` (marked as DEFAULT in help) and `--extended` (all plots except Bode) bulk controls. - Update `--help` and README.md usage to reflect the new additive/exclusive flag behavior. * feat: combine setpoint flags into a single --setpoint parameter - Remove redundant --setpoint-diff flag. - Update --setpoint to enable both Tracking and Feedforward (Setpoint Derivative) plots when used in 'Only' mode. - Synchronize help message and README.md with the consolidated flag. * docs: explicitly include Motor spectrums in --core description * fix: mutual exclusion for --core/--extended, simplify PlotConfig init, update docs - Add mutual exclusion check: --core and --extended now error if passed together - Simplify has_only_flags block: replace none()+override pattern with if/else if/else - Add sync comment on PlotConfig struct to keep none/default/all in step - README: add breaking-change notice block for default core-only output - README: restructure Output section into Core/Extended groups; add missing _SetpointDerivative_stacked.png - OVERVIEW.md: update stale "defaults to all enabled" text; update flag list in arg-parsing description Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: merge --setpoint into --pid, drop --setpoint flag --pid now covers the full PID tuning session: Tracking, FF (setpoint derivative), PID Activity, and PIDsum/Error overlay. --setpoint is removed as it was new to this branch with no prior users. Update debug log, help text, README, and OVERVIEW.md accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * revert: restore --setpoint flag, --pid back to 2 plots (Activity & Error) Individual flags group by visual type, not tuning domain. --pid covers pid_activity + pidsum_error_setpoint; --setpoint covers setpoint_vs_gyro + setpoint_derivative. Consistent with --spectrums, --psd, --heatmaps grouping philosophy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: simplify CLI to default + --extended + --step + --bode Drop all individual plot flags (--core, --motor, --spectrums, --tracking, --gyro-filt, --setpoint, --pid, --psd, --heatmaps). Surfaced flags: default (no flag) = core plots --extended = all plots except Bode --step = step response only --bode = Bode only (requires system-id log) --estimate-optimal-p = [EXPERIMENTAL] analysis add-on Plot config derivation replaces the has_only_flags block with a simple if/else if/else expression. Mark --estimate-optimal-p as experimental in help text. Update README and OVERVIEW with explicit core/extended plot lists in all three reference locations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: restore --core [default] flag, clean up help text formatting Add --core back as an explicit named flag for the default plot set, mutually exclusive with --extended. Reformat --help to the standard no-blank-lines-between-options layout with aligned columns and [default] tag. Sync README and OVERVIEW to match. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: gate verbose key-mapping diagnostics behind --debug flag Flight data key mapping output (header detection per-channel) is now only shown with --debug. The fallback warning (⚠️ Using debug[0-2] as gyroUnfilt[0-2] and Debug mode value: N) remains always visible. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 09af3fa commit 3e54f4f

4 files changed

Lines changed: 214 additions & 162 deletions

File tree

OVERVIEW.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ All analysis parameters, thresholds, plot dimensions, and algorithmic constants
2323
### Core Functionality
2424

2525
1. **Argument Parsing (`src/main.rs`):**
26-
* Parses command-line arguments: input CSV file(s), an optional `--dps` parameter (requires a numeric threshold value for detailed step response plots with low/high split), an optional `--output-dir` for specifying the output directory, and an optional `--step` flag to generate only step response plots.
26+
* Parses command-line arguments: input CSV file(s), an optional `--dps` parameter (requires a numeric threshold value for detailed step response plots with low/high split), an optional `--output-dir` for specifying the output directory, and plot-selection flags (`--core` [default], `--extended`, `--step`, `--bode`).
2727
* Additional options include `--help` and `--version` for user assistance.
2828
* The `--output-dir` parameter now requires a directory path when specified. If omitted, plots are saved in the source folder (input file's directory).
2929
* Handles multiple input files and determines if a directory prefix should be added to output filenames to avoid collisions when processing files from different directories.
@@ -91,17 +91,22 @@ All analysis parameters, thresholds, plot dimensions, and algorithmic constants
9191
* Clear disclaimers that recommendations are starting points, not absolute values
9292
* Works for all aircraft sizes including 10"+ where D > P (P:D < 1.0)
9393
* Recommendations appear in both console output and step response plot legends
94-
* **Other plots generated (`src/plot_functions/`):** When the `--step` flag is not used, the following additional plots are generated. These per-plot gates are controlled by the `PlotConfig` struct (defaults to all enabled; `PlotConfig::step_only()` when `--step` is specified):
95-
* `plot_pidsum_error_setpoint`: PIDsum (P+I+D), PID Error (Setpoint - GyroADC), and Setpoint time-domain traces for each axis.
96-
* `plot_setpoint_vs_gyro`: Setpoint and filtered gyro time-domain comparison for each axis.
97-
* `plot_gyro_vs_unfilt`: Filtered vs. unfiltered gyro time-domain comparison for each axis. Includes enhanced cross-correlation filtering delay calculation.
98-
* `plot_gyro_spectrums`: Frequency-domain amplitude spectrums of filtered and unfiltered gyro data with intelligent peak detection and labeling using scale-aware thresholds (`FILTERED_GYRO_MIN_THRESHOLD` for filtered gyro data). Includes enhanced cross-correlation filtering delay calculation and flight firmware filter response curve overlays.
99-
* `plot_psd`: Power Spectral Density plots in dB scale with peak labeling. Includes enhanced cross-correlation filtering delay calculation.
100-
* `plot_d_term_spectrums`: Frequency-domain amplitude spectrums of D-term data with intelligent peak detection using scale-aware thresholds (`FILTERED_D_TERM_MIN_THRESHOLD` for filtered D-term data). Includes enhanced cross-correlation filtering delay calculation with intelligent D-term activity detection (skips axes where D gain = 0).
101-
* `plot_d_term_psd`: Power Spectral Density plots of D-term data in dB scale with intelligent threshold filtering (`PSD_PEAK_LABEL_MIN_VALUE_DB` for filtered data) and enhanced formatting. Includes enhanced cross-correlation filtering delay calculation with intelligent D-term activity detection (skips axes where D gain = 0).
102-
* `plot_d_term_heatmap`: D-term throttle-frequency heatmaps showing PSD vs. throttle (Y-axis) and frequency (X-axis) to analyze D-term energy distribution across different throttle levels.
103-
* `plot_psd_db_heatmap`: Spectrograms showing PSD vs. time as heatmaps using Short-Time Fourier Transform (STFT) with configurable window duration and overlap.
104-
* `plot_throttle_freq_heatmap`: Heatmaps showing PSD vs. throttle (Y-axis) and frequency (X-axis) to analyze noise characteristics across different throttle levels.
94+
* **Other plots generated (`src/plot_functions/`):** Which plots are generated is controlled by the `PlotConfig` struct. The default (no flag) enables the core set; `--extended` enables all plots except Bode. Plots are gated per-field in `PlotConfig`:
95+
* **Core plots (default — no flag required):**
96+
* `plot_setpoint_vs_gyro`: Setpoint and filtered gyro time-domain comparison for each axis.
97+
* `plot_gyro_vs_unfilt`: Filtered vs. unfiltered gyro time-domain comparison for each axis. Includes enhanced cross-correlation filtering delay calculation.
98+
* `plot_gyro_spectrums`: Frequency-domain amplitude spectrums of filtered and unfiltered gyro data with intelligent peak detection and labeling using scale-aware thresholds (`FILTERED_GYRO_MIN_THRESHOLD` for filtered gyro data). Includes enhanced cross-correlation filtering delay calculation and flight firmware filter response curve overlays.
99+
* `plot_d_term_spectrums`: Frequency-domain amplitude spectrums of D-term data with intelligent peak detection using scale-aware thresholds (`FILTERED_D_TERM_MIN_THRESHOLD` for filtered D-term data). Includes enhanced cross-correlation filtering delay calculation with intelligent D-term activity detection (skips axes where D gain = 0).
100+
* `plot_motor_spectrums`: Motor output frequency analysis.
101+
* **Extended plots (`--extended` adds these to the core set):**
102+
* `plot_pidsum_error_setpoint`: PIDsum (P+I+D), PID Error (Setpoint - GyroADC), and Setpoint time-domain traces for each axis.
103+
* `plot_pid_activity`: P, I, D term activity over time.
104+
* `plot_setpoint_derivative`: Setpoint rate-of-change (feed-forward proxy) for each axis.
105+
* `plot_psd`: Power Spectral Density plots in dB scale with peak labeling. Includes enhanced cross-correlation filtering delay calculation.
106+
* `plot_d_term_psd`: Power Spectral Density plots of D-term data in dB scale with intelligent threshold filtering (`PSD_PEAK_LABEL_MIN_VALUE_DB` for filtered data) and enhanced formatting. Includes enhanced cross-correlation filtering delay calculation with intelligent D-term activity detection (skips axes where D gain = 0).
107+
* `plot_d_term_heatmap`: D-term throttle-frequency heatmaps showing PSD vs. throttle (Y-axis) and frequency (X-axis) to analyze D-term energy distribution across different throttle levels.
108+
* `plot_psd_db_heatmap`: Spectrograms showing PSD vs. time as heatmaps using Short-Time Fourier Transform (STFT) with configurable window duration and overlap.
109+
* `plot_throttle_freq_heatmap`: Heatmaps showing PSD vs. throttle (Y-axis) and frequency (X-axis) to analyze noise characteristics across different throttle levels.
105110

106111
### Filtering Delay Calculation
107112

README.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ cargo build --release
2525
```
2626

2727
### Usage
28+
29+
> **Notice:** Default output is **core plots only**. Use `--extended` for all plots.
30+
2831
```shell
2932
Usage: ./BlackBox_CSV_Render <input1> [<input2> ...] [OPTIONS]
3033

@@ -36,28 +39,29 @@ Usage: ./BlackBox_CSV_Render <input1> [<input2> ...] [OPTIONS]
3639

3740
=== PLOT TYPE SELECTION ===
3841

39-
Note: Plot flags are combinable. Without flags, all plots generated.
40-
41-
--step: Generate only step response plots.
42-
--motor: Generate only motor spectrum plots.
43-
--setpoint: Generate only setpoint-related plots.
44-
--pid: Generate only P, I, D activity plot.
45-
--bode: Bode plot analysis (requires chirp/sweep system-id test flight, not normal logs).
42+
--core [default] Step Response, Gyro Spectrums, D-term Spectrums,
43+
Setpoint vs Gyro, Gyro vs Unfiltered, Motor Spectrums.
44+
--extended All plots except Bode — adds PIDsum/Error, PID Activity,
45+
Setpoint Derivative, Gyro PSD, D-term PSD, and heatmaps.
46+
--step Step response only.
47+
--bode Bode only (requires chirp/sweep system-id test flight).
4648

4749
=== ANALYSIS OPTIONS ===
4850

49-
--butterworth: Show Butterworth PT1 cutoffs on gyro/D-term spectrum plots.
50-
--dps <value>: Deg/s threshold for detailed step response plots (positive number).
51-
--estimate-optimal-p: Enable optimal P estimation from throttle-punch dynamics. Requires .headers.csv; skips P estimation if absent.
51+
--butterworth Show Butterworth PT1 cutoffs on gyro/D-term spectrum plots.
52+
--dps <value> Deg/s threshold for detailed step response plots (positive number).
53+
--estimate-optimal-p [EXPERIMENTAL] Optimal P estimation from throttle-punch
54+
dynamics. Requires .headers.csv; skips if absent.
5255

5356
=== GENERAL ===
5457

55-
--debug: Show detailed metadata during processing.
56-
-h, --help: Show this help message and exit.
57-
-V, --version: Show version information.
58+
--debug Show detailed metadata during processing.
59+
-h, --help Show this help message and exit.
60+
-V, --version Show version information.
5861
```
5962
6063
Arguments can be in any order. Wildcards (e.g., *.csv) are shell-expanded and work with mixed file/directory patterns.
64+
6165
### Example execution commands
6266
```shell
6367
./target/release/BlackBox_CSV_Render path/to/BTFL_Log.csv
@@ -72,10 +76,7 @@ Arguments can be in any order. Wildcards (e.g., *.csv) are shell-expanded and wo
7276
./target/release/BlackBox_CSV_Render path/to/ -R --step --output-dir ./step-only
7377
```
7478
```shell
75-
./target/release/BlackBox_CSV_Render path/to/ --setpoint --output-dir ./setpoint-only
76-
```
77-
```shell
78-
./target/release/BlackBox_CSV_Render path/to/ --step --setpoint --motor --output-dir ./all-selective
79+
./target/release/BlackBox_CSV_Render path/to/ --extended --output-dir ./all-plots
7980
```
8081
```shell
8182
./target/release/BlackBox_CSV_Render path/to/BTFL_Log.csv --step --estimate-optimal-p
@@ -84,19 +85,24 @@ Arguments can be in any order. Wildcards (e.g., *.csv) are shell-expanded and wo
8485
### Output
8586
8687
#### PNG Files Generated
88+
89+
**Core (default):**
8790
- `*_Step_Response_stacked_plot_*.png` — Step response analysis with P:D recommendations
88-
- `*_PIDsum_PIDerror_Setpoint_stacked.png` — PIDsum, PID error, and setpoint traces
8991
- `*_SetpointVsGyro_stacked.png` — Setpoint vs. filtered gyro comparison
9092
- `*_GyroVsUnfilt_stacked.png` — Filtered vs. unfiltered gyro comparison with delay estimates
9193
- `*_Gyro_Spectrums_comparative.png` — Frequency-domain gyro amplitude spectrums
92-
- `*_Gyro_PSD_comparative.png` — Gyro power spectral density (dB scale)
9394
- `*_D_Term_Spectrums_comparative.png` — Frequency-domain D-term amplitude spectrums
95+
- `*_Motor_Spectrums_stacked.png` — Motor output frequency analysis (supports any motor count; colors wrap every 8 motors)
96+
97+
**Extended (`--extended` adds these to the core set):**
98+
- `*_PIDsum_PIDerror_Setpoint_stacked.png` — PIDsum, PID error, and setpoint traces
99+
- `*_PID_Activity_stacked.png` — P, I, D term activity over time
100+
- `*_SetpointDerivative_stacked.png` — Setpoint rate-of-change / feed-forward proxy
101+
- `*_Gyro_PSD_comparative.png` — Gyro power spectral density (dB scale)
94102
- `*_D_Term_PSD_comparative.png` — D-term power spectral density (dB scale)
95103
- `*_D_Term_Heatmap_comparative.png` — D-term throttle/frequency heatmap
96104
- `*_Gyro_PSD_Spectrogram_comparative.png` — Gyro spectrogram (PSD vs. time)
97105
- `*_Throttle_Freq_Heatmap_comparative.png` — Throttle/frequency heatmap analysis
98-
- `*_Motor_Spectrums_stacked.png` — Motor output frequency analysis (supports any motor count; colors wrap every 8 motors)
99-
- `*_PID_Activity_stacked.png` — P, I, D term activity over time (stacked plot showing all three PID components)
100106
101107
#### Console Output:
102108
- Current P:D ratio and peak analysis with response assessment

0 commit comments

Comments
 (0)