Fix energy analysis: AKit delta-log overcounting and Kraken regen#175
Merged
nlaverdure merged 2 commits intomainfrom Mar 25, 2026
Merged
Fix energy analysis: AKit delta-log overcounting and Kraken regen#175nlaverdure merged 2 commits intomainfrom
nlaverdure merged 2 commits intomainfrom
Conversation
interp_entry used left=vs[0] extrapolation, which holds the first logged current value backwards in time. For motors that are idle at exactly 0 A (spindexer, kicker pre-shoot), no log entries exist until the motor fires — so the first in-window sample was mid-shoot (~60 A), falsely inflating energy for the entire pre-activation window. Fix: after interpolation, zero out current values before the first actual logged timestamp within the match analysis window. Affects process_match() in energy_analysis.py and the standalone energy_feeder_auto_q54.py script. Corrected values (avg across 14 matches): Kicker: 22.4 -> 16.7 kJ Spindexer: 19.0 -> 11.9 kJ Total: 326.1 -> 311.5 kJ Also adds energy_feeder_auto_q54.py — focused spindexer+kicker auto-only plot for Q54, and updates writeup tables and observations accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove supply current floor (np.maximum(..., 0)) for Kraken-powered mechanism groups (Drive, Flywheel, Lower Roller, Upper Roller). TalonFX/Phoenix 6 reports negative supply current during regen; clamping it to zero was silently discarding ~3.2–3.6 kJ of recovery per match (~1.8% of drive energy). Add KRAKEN_GROUPS constant to control which groups integrate without clamping. Non-Kraken groups (Spindexer, Kicker, Turret, Hood, Compressor) and PDH-sourced Electronics keep clamp=True since their supply current is always non-negative. Updated numbers (14-match average): Drive: 180.6 → 177.4 kJ Total: 311.5 → 308.1 kJ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AKit delta-log overcounting bug: AdvantageKit only writes a new record when a value changes. Motors idle at 0 A produce no log entries, so
interp_entry's left-extrapolation held the first non-zero sample (e.g. a mid-shoot 60 A reading) back across the entire pre-activation window. This falsely accumulated energy for every mechanism that started the match idle. Fix: after interpolation, zero out current before the first logged timestamp within the analysis window. Corrected average totals: Kicker 22.4→16.7 kJ, Spindexer 19.0→11.9 kJ, Total 326.1→311.5 kJ.Kraken regenerative braking: TalonFX/Phoenix 6 reports negative supply current during regen. The previous
np.maximum(current, 0.0)clamp was silently discarding ~3.2–3.6 kJ of recovery per match (~1.8% of drive energy). AddedKRAKEN_GROUPS = {"Drive", "Flywheel", "Lower Roller", "Upper Roller"}and aclampparameter tocumulative_energy_J; non-Kraken groups and PDH-sourced Electronics retain clamping. Corrected average totals: Drive 180.6→177.4 kJ, Total 311.5→308.1 kJ.Added
scripts/energy_feeder_auto_q54.py— focused stacked-area plot for Spindexer + Kicker over the Q54 autonomous period only, with shoot-window annotation.Updated
doc/energy_analysis_writeup.mdtables and key observations to reflect corrected numbers.Test plan
python scripts/energy_analysis.py <q54_log> 150.011873 314.890358— verify Drive ≈ 208 kJ, Total ≈ 330 kJpython scripts/energy_analysis.py(14-match average) — verify Drive ≈ 177 kJ, Total ≈ 308 kJpython scripts/energy_feeder_auto_q54.py— verify Spindexer ≈ 1.5 kJ, Kicker ≈ 2.0 kJ for auto only, plot saved todoc/assets/🤖 Generated with Claude Code