fix(crane_physics): FLYINGボールの着地時間計算でpos_zを考慮するよう修正 - #1390
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のBallPhysicsModelにおいて、FLYING(チップキック飛行中)状態のボールの着地時間計算が現在高度pos_zを無視していた不具合を修正します。問題
ball_physics_model.cppのgetStopTime/getMaxDistanceの FLYING 分岐では、着地時間をで算出していました。この式は地面(z=0)から打ち上げたボールの滞空時間を表すものであり、現在のボール高度
pos_zを完全に無視しています。そのため、高所からの落下中(
vel_z <= 0)ではlanding_timeが 0 にクランプされ、飛行中の水平移動が一切加算されません。結果として停止時間・最大到達距離(着地位置)の推定が過小評価されていました。一方で同クラスの
predictPosition/predictVelocityは正しくpos_zを考慮した放物運動の根を解いており、関数間で挙動が不整合な状態でした。原因
地面(z=0)からの打ち上げ滞空時間の式を流用し、
getMaxDistanceでは引数pos_zを[[maybe_unused]]として無視、getStopTimeではそもそもpos_zを受け取っていませんでした。修正内容
predictPosition/predictVelocityと同一のロジックで着地時間を解く private ヘルパーgetFlyingLandingTime(pos_z, vel_z)を新設しました。z(t) = pos_z + vel_z * t + 0.5 * gravity * t^2 = 0(gravityは負値)の正の最小根を返します。getStopTimeのシグネチャにpos_zを追加し、FLYING 分岐で当該ヘルパーを使用するよう変更しました。getMaxDistanceの引数pos_zの[[maybe_unused]]を外し、FLYING 分岐で当該ヘルパーを使用するよう変更しました。ball_info.cppのBall::getStopTime()を新シグネチャ(pos_z受け渡し)に追従させました。これにより、飛行中の高度を考慮した着地時間・着地位置が算出され、
predictPosition/predictVelocityとの整合性が取れます。検証
colcon build(--no-rdeps)によるcrane_physicsのコンパイルが成功することを確認しました(Build complete.、エラーなし。既存テストコードの警告のみ)。colcon test --packages-select crane_physics: 1 package finishedcolcon test-result --verbose: 118 tests, 0 errors, 0 failures, 0 skipped(gtest 10 件含む)レビュー観点
vel_z <= 0を含む高所落下中)における停止時間・最大到達距離(着地位置)推定の妥当性。getFlyingLandingTimeの根の選択(正の最小根)とフォールバック(判別式負・非正根)の妥当性、およびpredictPosition/predictVelocityとの一貫性。getStopTimeのシグネチャ変更に伴う呼び出し側の追従漏れがないこと。本PRはソースコード監査ワークフローで検出・敵対的検証されたバグに対する単一修正です。