Skip to content

PIDReview: show rise time, overshoot and settling time of step response - #377

Open
j-w9 wants to merge 6 commits into
ArduPilot:mainfrom
j-w9:pid-review-step-stats
Open

j-w9 wants to merge 6 commits into
ArduPilot:mainfrom
j-w9:pid-review-step-stats

Conversation

@j-w9

@j-w9 j-w9 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

"Settling time read out. also other stats overshoot ect." from #92.

A table under the Step Response plot gives, for the mean response of each test: rise time (10 to 90%), peak and peak time, overshoot, settling time (5% band) and final value. Times are in seconds to match the plot, peak and final value are a percentage of the step.

  • The last 0.1 s of the estimate is ignored, because it turns up at the end (visible in the screenshot). Stats use 0 to 0.4 s, and the final value is the mean from 0.2 to 0.4 s.
  • If the final value is outside 50 to 150%, only the final value is shown, as the other numbers would be misleading. On one of my logs the mean settles at 21%.
  • Overshoot is the peak above the final value. It is 0 if the peak is at 0.4 s, as the response is still rising. Settling shows "> 0.400 s" if it hasn't settled by then.
  • Stats are taken once per test after the batch loop. The mean plot is updated on each batch, so only the final mean is used.

The calculation matches an independent Python version on three analytic second order responses (damping 0.3/0.5/0.8). For damping 0.5 it gives 16.4% overshoot with the peak at 90 ms, against theory's 16.3% at 90.7 ms. The thresholds (step_stats_*) are easy to change if you'd prefer other definitions. No change to the step estimate itself.

Step response stats

@tridge tridge added the AIReview label Nov 9, 2026
@AP-Review

AP-Review commented Nov 9, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-11-09)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head 10c97399dc.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/377/1.html#prWebTools-377

The step-response stats table works and gives correct values for the default 400 Hz / 512-sample case, but there are two edge cases where it shows misleading numbers.

Should fix

  • PIDReview/PIDReview.js:1039: when the estimate is shorter than 0.4 s (FFT window 128 at 400 Hz, 256 at 1 kHz, or the default 512 at 2 kHz fast-rate logging), len falls back to response.length. The final value then uses the end-of-estimate region the comment above says to avoid, an unsettled response shows as > 400 ms, and the note still says 200-400 ms. Return early (or mark the row unreliable) when end_index < 0.
  • PIDReview/PIDReview.js:1336: switching to an axis that has data but no complete FFT window leaves the previous axis's table visible, because redraw() returns on PID.sets.FFT == null before redraw_step(). Call show_step_stats([]) from setup_FFT_data()/setup_axis(), or before that early return.
Minor (1)
  • PIDReview/PIDReview.js:1325: rows for tests unchecked with the per-test set_selection_N boxes stay in the table, because update_hidden() only redraws the plot. Skip unchecked sets in redraw_step() and refresh the table from update_hidden().

@AP-Review

AP-Review commented Nov 9, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-11-09)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: ACCEPT

Reviewed at head 9eae3fefc9.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/377/2.html#prWebTools-377

The step-response stats table now looks good to merge at head 9eae3fe, with no open findings.

All three earlier findings are fixed. Short estimates (under 0.4 s) no longer produce a row, switching to an axis without an FFT clears the table, and unticked tests drop out of the table.

Two new concerns were checked and dropped as pre-existing behaviour rather than this PR. After a Scale or Calculate redraw, unticked mean lines come back on the plot, because redraw_step() forces them visible at PIDReview/PIDReview.js:1323. A failed recalculation leaves the step plot stale, and the table matches that stale plot.

@IamPete1

Copy link
Copy Markdown
Member

I think the time units in the table should be in seconds to match the time scale on the graph. I think the Peak and Final value should be in a percentage. This matches the titles for Rise time and Settling time. I also think the new stuff should go under the graph.

I'm not getting overshoot on two of the plots here:

image

Both cases say the peak is larger than the final value.

@j-w9

j-w9 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Done: times are in seconds, peak and final value are a percentage of the step, and the table is under the plot. The missing overshoot was the rule that left it blank when the peak was in the final value window (0.2 to 0.4 s), both your peaks were in there. It's now shown whenever the peak is above the final value, except a peak right at 0.4 s, where the response is still rising, which shows 0%.

@AP-Review

AP-Review commented Nov 20, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-11-20)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head 97b3890855.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/377/3.html#prWebTools-377

The stats table is in good shape at head 97b3890, with one minor overshoot edge case left.

Since the last review (9eae3fe), the table has moved below the plot. Times now show in seconds, and peak and final value as percentages. A peak inside the final window (Test 2 in the screenshot) now gets an overshoot value.

Minor (1)
  • PIDReview/PIDReview.js:1076: "still rising" is decided by whether the single last sample is the peak. A response still climbing through 0.2-0.4 s shows 0 % overshoot if its last sample is highest, but about 13 % if that sample is 0.001 lower. Judging it from the trend over the last few samples, e.g. treating the end as still rising when it is within the 5 % band of the peak, would make the result stable. The note at line 1153 would need to match.

@AP-Review

AP-Review commented Nov 20, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-11-20)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: COMMENT

Reviewed at head 2571c2d007.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/377/4.html#prWebTools-377

One overshoot issue is left at head 2571c2d, and it was introduced by the fix for the last one.

Since the last review (97b3890), the overshoot no longer flips when the last sample is a little below the peak.

Should fix

  • PIDReview/PIDReview.js:1081: the still-rising test never checks where the peak is. A well-damped response with a small early overshoot (under 5 %) and a tail that creeps up by any amount shows 0 % overshoot. For example, a zeta 0.7 step with 4.5 % overshoot at 0.14 s shows 0 % if its tail rises 0.0005 between 0.35 and 0.40 s. A sustained oscillation that ends on a rising crest also shows 0 %. Adding peak_index >= rising_start to the test keeps the still-rising ramps at 0 % and restores the 97b3890 values otherwise. This is the trend rule the last review suggested, which was missing that condition.

@AP-Review

AP-Review commented Nov 21, 2026 •

Copy link
Copy Markdown

Deprecated — see below for the updated review.

Previous review (2026-11-21)

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: ACCEPT

Reviewed at head 0839900d9b.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/377/5.html#prWebTools-377

The step-response stats table looks good to merge at head 0839900, with no open findings.

Since the last review (2571c2d), the still-rising check also requires the peak to be at the end of the window. A small early overshoot followed by a creeping tail, or a sustained oscillation, now shows its overshoot again, while responses that are still rising stay at 0 %.

@IamPete1

Copy link
Copy Markdown
Member

Just chuck in a blank line here:

image

(or mess about with the margins if you prefer) and fix the merge conflicts.

j-w9 added 6 commits November 20, 2026 20:20
…icked tests

No stats when the estimate is shorter than the 0.4 s window, clear the
table when the axis data is set up, and leave out tests that are
unticked.
Times are in seconds to match the plot and peak and final value are a
percentage of the step. Overshoot is shown whenever the peak is above
the final value, unless the peak is at the end of the measured range,
where the response is still rising. The table is now under the plot.
Rather than whether the last sample is the peak, which flipped the
overshoot between 0 and the full value on a tiny difference.
…s at the end

A small early overshoot with a tail that creeps up showed 0%.
@j-w9
j-w9 force-pushed the pid-review-step-stats branch from 0839900 to 0afb8e5 Compare November 21, 2026 01:24
@j-w9

j-w9 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

rebased onto master and kept your step note below the table, and added some space above the table

@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: ACCEPT

Reviewed at head 0afb8e5031.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/webtools/377/6.html#prWebTools-377

The step-response stats table looks good to merge at head 0afb8e5, with no open findings.

Since the last review (0839900), the PR has been rebased onto main, so the merge conflicts are gone, and the table now has a 1em gap below the plot as requested. The stats code is unchanged, and the peak-location fix for overshoot still holds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants