fix(crane_geometry): Interval::eraseの境界一致ケース取りこぼしを修正 - #1379
Open
HansRobo wants to merge 1 commit into
Open
Conversation
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.
概要
crane_geometryのInterval::erase(区間減算)における境界一致ケースの取りこぼしを修正しました。問題
interval.hppのeraseは厳密不等号(</>)のみで境界判定を行っていたため、あるeraseが生成した境界に後続のeraseが接するケース等で境界一致を取りこぼし、不正な区間を生成していました。再現例:
この区間計算は
world_model_wrapper.cpp:306のシュートコース角度計算で利用されており、誤った区間幅が実害につながっていました。原因
<=を使うべき箇所が<になっており、境界一致時に区間が正しく縮められなかった。uppers/lowersを個別にsortしていたため、本来ペアであるべき上端・下端の対応がソートで崩れうる脆さがあった(特に中抜き分割時に対応がずれる)。修正内容
eraseを区間減算として正しく再実装しました。消去区間[L, U]を各既存区間[lo, hi]から引く際、以下の場合分けを行います。U <= lo || L >= hi: 重なりなし(境界一致を含む)→ 区間はそのまま残すL <= lo && U >= hi: 完全に覆われる → 区間を削除L > lo && U < hi: 中抜き →[lo, L]と[U, hi]の 2 区間に分割L <= lo: 下端を縮める →[U, hi]lo < L,hi <= U): 上端を縮める →[lo, L]結果は新しい区間リストとして再構築することで、
uppers/lowersのペア対応を常に保持します。これにより個別sortによるペア崩れの脆さも解消しています。検証
cwm ws build --no-rdeps)し、コンパイルが正常に完了することを確認(Build complete.)。colcon test --packages-select crane_geometryを実行し、ユニットテスト(test_interval/test_geometryを含む gtest 2 件、linter / copyright / xmllint 含む計 23 チェック)がすべて成功することを確認(0 errors, 0 failures)。append(1,8); append(8,19); erase(1,7)で幅が期待どおり 12 になること)でもロジックを検証。レビュー観点
<=の使用、中抜き分割、端の縮め)の網羅性と正当性。uppers/lowersをペアとして再構築することで対応が崩れないこと。本PRはソースコード監査ワークフローで検出・敵対的検証されたバグに対する単一修正です。