ENH: Zero Inertia tensor Check

オープン
#826 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@aZira371 がすでに取り組んでいます。

2025年6月13日 から。

  • #833 @aZira371 による — マージされずにクローズ

評価

この issue はまだ評価されていません。

説明

Enhancement

Is your feature request related to a problem? Please describe.

Previously, users could accidentally set the rocket's dry inertia tensor to a zero vector or otherwise singular configuration. This led to runtime errors during simulation, typically manifesting as RuntimeWarning: divide by zero encountered in scalar divide and subsequent integration failures in the ODE solver.

Describe the solution you'd like

The dry inertia tensor should be validated as soon as the Rocket object is initialized. Specifically:

  • Construct the 3×3 inertia matrix from user-provided I_ij values in Rocket.init.

  • Immediately compute its determinant.

  • Raise a clear ValueError if the determinant is zero (i.e., the tensor is singular), with a helpful message prompting users to provide physically realistic values.

  • This approach shifts error detection earlier in the development cycle, prevents invalid configurations from reaching the solver, and gives users a precise explanation of what's wrong.

  • No changes are made to motor or dynamic inertia evaluation. Only the dry inertia (which is static and available at init) is validated.

Additional context

  • This change improves usability and safety, especially for multi-stage and upper-stage configurations where users often define placeholder or dummy inertia values.

  • It avoids obscure integration failures and makes RocketPy more robust to user error.

  • The solution avoids invasive structural changes by operating entirely within the Rocket class and leveraging existing Matrix functionality.

Future extensions could optionally introduce runtime checks for singular dynamic inertias (e.g., in u_dot_generalized), but this patch focuses only on validating static dry inertia at creation time. For dynamic inertia evaluation a debug_inertia_check can be implemented as optional boolean flag added to the Flight class to catch near-singular total inertia tensors during simulation. When enabled, it performs a lightweight determinant check on the dynamically evaluated total inertia matrix at each time step. If the determinant falls below a safe threshold, a clear error is raised indicating potential instability due to ill-conditioned inertial properties. This helps users catch modeling or configuration issues in motor or mass properties that may otherwise cause silent solver failures. The feature is off by default to avoid performance overhead in production runs.

主要言語
Python
スター
1.1k
フォーク
280
平均マージ
3日 2時間
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RocketPy-Team/RocketPy のほかの issue

RocketPy-Team/RocketPy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。