fix(crane_physics): 単一ロボット割当でコストを無視してtarget0を固定する不具合を修正#1385
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_physicsの位置割当ロジック (position_assignments.hpp) において、ロボットが1台のみのケースで距離・コストを一切評価せず無条件にターゲットインデックス{0}を返していた不具合を修正します。問題
getOptimalAssignments(距離ベース)およびgetOptimalAssignmentsWithCost(カスタムコストベース)の early-return 分岐で、ロボットが1台のとき常に{0}を返していました。複数ターゲットが存在する場合でも最適ターゲットが index0 とは限らないため、より遠い(あるいはコストの高い)ターゲットへ誤って割り当てられる可能性がありました。原因
1台時の early-return で argmin を計算せず、ハードコードした
{0}を返していたためです。修正内容
ロボットが1台のとき、ターゲット集合に対して最小コストとなるインデックスを argmin で選択して返すように変更しました。
getOptimalAssignments:bg::distance(robot_positions[0], targets[j])が最小となるターゲットインデックスを選択。getOptimalAssignmentsWithCost:cost_func(0, j)が最小となるターゲットインデックスを選択。ターゲットが1個の場合は従来通り
{0}を返します(argmin の結果が0になるため動作は変わりません)。Hungarian アルゴリズムを呼ぶ複数ロボット時のパスは変更していません。検証
colcon build(cwm ws build --no-rdeps)を実行し、crane_physicsのコンパイルが成功することを確認(Build complete.、エラーなし)。SingleRobotはロボット (0,0) に対し target0 (1,1) が最近傍であるため、argmin の結果も{0}となり従来通りパスすることを確認。レビュー観点
test/test_position_assignments.cppのSingleRobot期待値(最近傍が target0 のケース)が引き続き成立すること。{0}を返すこと。本PRはソースコード監査ワークフローで検出・敵対的検証されたバグに対する単一修正です。