Repository navigation
fix: share one step-response builder across plot, console and report - #243
Conversation
…nd report The plot legend peak was read after a first-sample shift and a second renormalization, while the console, report and title read the raw QC average. Add calc_step_response::displayed_response (average, then steady-state renormalization to mean 1.0) and call it from the plot and from the P:D analysis in main, so all outputs use one curve and one peak. Drop the first-sample shift: PIDtoolbox applies none, and it zeroed the whole response for a plant that starts at 1.0. Update OVERVIEW.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KoqKWyH8bEnezDzEVxkNPQ
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@coderabbitai — AI generated comment Analysis requested on these points:
|
|
Tip For best results, initiate chat on the files or code changes. Analysis chain
I recommend tests with distinct rows and partial masks, nonconstant values at the steady-state boundaries, and a combined plot/report parity check. I did not run tests or inspect the PNGs in this sandbox; the owner’s PNG comparison remains outstanding. Learnings used
You are interacting with an AI system. |
…d peaks in OVERVIEW Add a test with distinct rows and partial masks so a builder that ignores the mask or averages the wrong rows fails. OVERVIEW.md now separates the combined legend peak from the low/high subset legend peaks used with --dps. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KoqKWyH8bEnezDzEVxkNPQ
|
@coderabbitai — AI generated comment Addressed the points from your reply, head fa0dba9:
Analysis requested on the new head:
|
|
Tip For best results, initiate chat on the files or code changes. Analysis chain
One documentation inconsistency remains: I inspected the code but did not run the tests or inspect the PNGs. The owner’s PNG comparison remains unverified. Learnings added
Learnings used
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
…efinition in OVERVIEW The masked-row test now gives the two selected rows different shapes, so an implementation that picks only one active row fails. OVERVIEW.md described the peak as the first maximum after crossing 1.0, but find_peak_value returns the maximum finite sample. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KoqKWyH8bEnezDzEVxkNPQ
|
@coderabbitai — AI generated comment Analysis requested on head f66739d (changes since fa0dba9: the masked-row test now gives the two selected rows different shapes, and OVERVIEW.md describes the peak as the maximum finite sample of the displayed response):
|
|
Tip For best results, initiate chat on the files or code changes. Analysis chain
Learnings used
You are interacting with an AI system. |
… peak wording in OVERVIEW Add a report test that feeds the peak from displayed_response and find_peak_value through generate_markdown_report and expects the three-decimal value. OVERVIEW.md now names the report label "Peak Value" and states that find_peak_value applies no time filter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KoqKWyH8bEnezDzEVxkNPQ
|
@coderabbitai — AI generated comment Addressed the points from your reply on f66739d, new head below:
Analysis requested on the new head:
|
|
Tip For best results, initiate chat on the files or code changes. Analysis chain
Learnings used
You are interacting with an AI system. |
|
@coderabbitai review |
Action performed
|
AI Generated pull-request Refs #242 (part 1, QC steady-state bounds). Part 2 was merged in PR #243. ## Summary - **QC bounds (IT 242 part 1):** with `APPLY_INDIVIDUAL_RESPONSE_Y_CORRECTION` on (the default), each window is divided by its own steady-state mean, so the mean check and the final tolerance could never reject a response. Removed. The per-sample bounds (min 0.5, max 3, as in PIDtoolbox) stay. - **Optimal P statistics:** Td is the median of the per-window values, with a robust spread (1.4826 x MAD / median). - **Punch detection:** the throttle-rise window is 100 ms (was 50 ms). The Td achievability factor is 2.0 (was 2.5). - **Recommendation rules:** no P increase when Td is already faster than the target. One shared function builds the Optimal text. - **Outputs:** the Optimal P block has one order and shared value, label and recommendation text in the console, report and legend; line formatting differs per output (report bullets, legend minimal). New `Flight clip` line. The skip reason is in the report. - **Docs and tests:** README usage block equals `--help` (test). Recommendation table documented and pinned by a test. `AGENTS.md` scope and test rules. ## Root causes 1. Y-correction divides each window by its own steady-state mean, so that mean is 1.0 by construction. The mean bounds and the final tolerance tested that value. Traced on real logs: every window that passed QC had a mean of 1.0 within 1e-4. PIDtoolbox has no mean check. 2. The plain mean and standard deviation of per-window Td followed a few windows that fail deconvolution and return Td of 100 ms or more. The deviation was biased high and the reliability check failed on repeatable data. 3. A manually applied throttle rise takes 100-250 ms. The 50 ms window found too few punches (the 5-punch gate failed on about half of the logs checked). The wider window changes the torque ratio, so the achievability factor needed a new value. 4. With low noise, a Td already faster than the target still got "increase P". A faster response has no headroom by that target. ## Behavior changes (output) - **Optimal P block order:** Recommendation, Td (median), Flight clip, Deviation, Noise, Td source, Reliable. The legend drops `Current P=` (the axis title shows it). The console and report keep it. - **Td labels:** `Td (median)` in the Optimal P block. The first legend line (`Td:` of the averaged curve) has one decimal. - **Removed from outputs:** the window count (neighbouring windows overlap, so it overstates the evidence). - **New text:** `Td source: N flights, M punches, spread S%`. `Flight clip: 218s` is the log time available to the step-response windows (the span after `--start`/`--end` and the 3 s margins; rejected windows can leave part unused). The flight count in `Td source` is per axis: files that gave that axis at least one punch. - **Recommendations (low noise):** P +5% from 0% to 30% slower than target, P +10% beyond 30% slower (a step rounds down to whole P, so it can be zero for a very small P). More than 15% faster: `No change suggested, headroom possible` (headroom is not quantified). Between 15% faster and 0%: `Current P is optimal`. Increases keep the matching D line. The full table is in `OVERVIEW.md`. - **Report:** a skipped axis lists the reason. Legend line width: step-response curves are 2 px. ## Commits | Group | Commits | |---|---| | QC | `cc444e9` | | Td statistics and punch source | `f07254d`, `9ae1771`, `c112e30` (later replaced by `2057094`), `ed3312d`, `dc7f161` | | Recommendation rules and text | `468ac1b`, `6a903ac`, `c95f8b2`, `5078044`, `d3fa267` | | Output layout | `6a351da`, `eb4e870`, `2539850`, `272ebff`, `be555dd`, `f33e24c`, `d166bfe`, `53cc9a9`, `b5dccfb`, `dbbab9d` (per-axis flight count) | | Docs and tests | `7738354`, `ae3ac0a`, `81bff48`, `7dbdf96`, `b15995d`, `c512bbd`, `29a4740`, `0e6d978`, `f5b0183`, `0bb1057`, `7771a49` | | CI fix | `7c37a8b` (`is_multiple_of`) | ## Validation - `cargo clippy --all-targets --all-features -- -D warnings`, `cargo fmt --all`, full `cargo test` (513 pass), `cargo build --release`. - New tests: median and robust spread, shared Optimal text, flight clip, skip reason in the report, README equals `--help`, recommendation table (22 Td zone and noise cases). - Output checked by comparing console, report and legend before and after each change on real logs. - Local review: CodeRabbit CLI (2 minor findings, fixed), opencode (4 findings checked, none valid), remote Ollama (no finding). GitHub: CodeRabbit review and analysis, findings handled in the PR thread and comments. ## Not verified - No independent known-good tunes. Optimal P stays experimental. - The achievability factor is set from a limited set of logs. One value cannot centre every aircraft. - Peaks read about 0.035 higher than PIDtoolbox for the same data: BBA divides each window by its mean (exact), PIDtoolbox multiplies by (2 - mean). A residual of 0.03-0.05 on some axes is not explained. - The punch ratio uses the largest single-sample gyro change; a slope-based ratio is not implemented. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KoqKWwCzFDgbyFBKx3fnAe <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Improvements** * Optimal P results now use median-based timing and robust noise measurements, with updated recommendations and clearer reporting of flight duration, source counts, and analyses that could not be performed. * Throttle-punch detection uses a 100 ms window. Optimal P estimation requires header metadata and at least five throttle punches in a log or pooled group; metadata can be embedded or provided separately. * Step-response results no longer apply the normalized-mean tolerance check. Plot labels and recommendation details have also been updated. * **Documentation** * Command help and README usage guidance clarify supported log formats, metadata requirements, and analysis options. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
AI Generated pull-request
Summary
The legend Peak and the console/report "Actual Peak" came from two different curves. The plot applied a first-sample shift and a second steady-state renormalization. The console, report and title read the raw QC average.
calc_step_response::displayed_response(average, then steady-state renormalization to mean 1.0). The plot and the P:D analysis inmain.rsboth call it, so every output uses one curve and one peak.OVERVIEW.mdstates that peaks are read on the unsmoothed curve.Refs #242
Gaps left
PEAK_*andTD_*constants stay.Test plan
cargo clippy --all-targets --all-features -- -D warnings,cargo fmt,cargo testpass.Summary by CodeRabbit
--dps, low- and high-setpoint legend peaks reflect their respective response subsets.