Repository navigation
fix(ui): record the G peaks that were measured, not the ones the dial can draw - #209
Merged
Merged
Conversation
The blog/ folder holds posts written for caterham7diaries.com. The device is the subject and the facts have to come from this repository, which is why the drafts are written here, but they are not part of this project's history. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… can draw rotate_sample() clamped both planar axes to kImuDisplayLimitG before anything else saw them, so the session peak summary was bounded by the radar's drawing range rather than by what the car did. A hand-shaken session recorded 2577 milli-g, which is sqrt(2^2 + 2^2): both axes pinned at the clamp, not a measurement. The measurement now reaches update_peaks() first and the display clamps its own copy, so the dial still stays inside its 2.0 g artwork while the peaks hold what the IMU actually reported. Peaks are bounded instead by kImuRecordedLimitG, a credibility limit at 10 g rather than a drawing limit, and anything beyond it sets ImuPeakSummary::truncated so a clipped figure can never be read as a real one. A static_assert ties that limit to logger::kMaximumCrediblePeakG, which is the bound the log writer already applied downstream. The vertical axis went the same way: it was clamped on its way into the snapshot, so a kerb strike was recorded as 2.0 g whatever it really was. Tests cover a 2.6 g corner recorded as measured while the dial shows 2.0, a 3.4 g vertical strike, a 14 g spike that is both bounded and flagged, and an ordinary session that the change leaves untouched. The clamp was temporarily reinstated to confirm the new assertions fail without the fix. Closes #162 Co-Authored-By: Claude Opus 5 <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.
Closes #162.
The defect
ImuMeterController::rotate_sample()clamped both planar axes tokImuDisplayLimitG(2.0 g) before returning, andupdate()fed that already-clamped point toupdate_peaks(). The recorded session peaks were therefore bounded by the radar's drawing range rather than by anything the car did.The evidence in the issue is a hand-shaken session that recorded 2577 milli-g —
sqrt(2² + 2²), i.e. both axes sitting exactly on the clamp. That is the artwork's diagonal, not a measurement.The vertical axis had the same problem by a different route: it was clamped on its way into the snapshot, so a kerb strike was logged as 2.0 g whatever it really was.
The fix
update_peaks()first; the display clamps its own copy. The dial still never draws outside its 2.0 g artwork.kImuRecordedLimitG = 10.0F— a credibility limit, not a drawing one.ImuPeakSummary::truncated, so a clipped figure can never be read back as a real one.static_assertinscreen_router.cpptieskImuRecordedLimitGtologger::kMaximumCrediblePeakG, the bound the log writer already applied downstream. The two cannot drift apart silently.Tests
Four new blocks in
tests/cpp/test_imu_meter.cpp:truncatedsetI reinstated the clamp temporarily to confirm the new assertions actually fail without the fix:
Verification
make check→CHECK_RC=00xfdb00, 32% freerepo-checkpassesThis is verifiable on the bench: shake the device in G-METER mode and the peak summary should now exceed 2.0 g. No car required.
Also in this PR
One unrelated commit adds
blog/to.gitignore— post drafts for caterham7diaries.com are written in the working tree because the facts have to come from this repository, but they are not part of its history.🤖 Generated with Claude Code