Skip to content

Rigid-body dynamics

Each entity is a 6-DOF rigid body with state \((\mathbf{r}, \mathbf{p}, m, q, \mathbf{L})\) and up to four wheel momenta \(h_k\) (symbols). The right-hand side below is compute_state_derivative, shared by Euler and RK4; the symplectic kernel splits it into kicks and a drift (integrators).

Translational motion

In the inertial frame,

\[ \dot{\mathbf{r}} = \frac{\mathbf{p}}{\tilde m}, \qquad \dot{\mathbf{p}} = \mathbf{F} + \dot{m}\,\frac{\mathbf{p}}{\tilde m}, \qquad \tilde m = \max(m, m_{dry}), \]

with the total force

\[ \mathbf{F} = m\,\mathbf{a}_g(\mathbf{r}) + \mathbf{F}_{drag}(\mathbf{r}, \mathbf{v}) + R(q)\,\mathbf{F}_{thr,b}, \]

from gravity and J2, drag and the body-frame thrust rotated by \(R(q)\), each only when its flag is on. The \(\dot m\,\mathbf{v}\) term (Meshchersky) accounts for propellant leaving at the vehicle velocity, the thrust being already in \(\mathbf{F}\); together they give \(m\,\dot{\mathbf{v}} = \mathbf{F}\), so a burn reproduces the rocket equation. The floor \(\tilde m\) only guards the division: the mass never falls below \(m_{dry}\) (burnout).

Rotational motion

The state stores the angular momentum \(\mathbf{L}\) of the body alone, in the body frame, so \(\boldsymbol{\omega} = \mathbf{I}^{-1}\mathbf{L}\) with \(\mathbf{I}\) the constant body inertia. The wheels add \(\mathbf{h} = \sum_k h_k\,\hat{\mathbf{a}}_k\) along their unit spin axes \(\hat{\mathbf{a}}_k\). Euler's equation for the body with its wheels ([5], [6]) is

\[ \dot{\mathbf{L}} = \boldsymbol{\tau}_{ext} - \dot{\mathbf{h}} - \boldsymbol{\omega} \times \left(\mathbf{L} + \mathbf{h}\right), \]

with \(\boldsymbol{\tau}_{ext}\) the thruster, gravity-gradient and magnetic torques (body frame), \(-\dot{\mathbf{h}}\) the wheels' reaction on the body, and the gyroscopic term from expressing \(\mathbf{L} + \mathbf{h}\) in the rotating frame. Each wheel follows

\[ \dot h_k = \operatorname{clamp}(\tau_{cmd,k}, \pm\tau_{max}) - \frac{b}{J_w}\,h_k, \qquad |h_k| \le h_{max}, \]

solved in closed form within the step (actuators). The integrators subtract the wheel momentum change \(\Delta\mathbf{h}\) over each (sub)step from \(\mathbf{L}\) instead of forming \(\dot{\mathbf{h}}\), which exchanges momentum exactly.

Quaternion kinematics

With \(q\) mapping body to inertial coordinates and \(\boldsymbol{\omega}\) in the body frame ([10], [7]):

\[ \dot{q} = \tfrac{1}{2}\, q \otimes \begin{bmatrix} \boldsymbol{\omega} \\ 0 \end{bmatrix}. \]

\(q\) is normalized on every reset, before the product and after every update.

Variable mass

Thrusters consume propellant at the mass-flow rate ([16])

\[ \dot{m} = -\frac{T_{max} \sum_i u_i}{I_{sp}\, g_0}, \qquad g_0 = 9.80665\ \mathrm{m/s^2}, \]

over the configured thrusters, throttles \(u_i \in [0, 1]\); \(I_{sp} = 0\) (the default) is ideal, consuming nothing. Whatever \(I_{sp}\), thrusters produce nothing once \(m \le m_{dry}\).

Burnout within a step. Thrust, thruster torque and \(\dot m\) are evaluated once per step from the commands and the propellant at the step start (thruster_wrench). On the step where the propellant would run out after \(t_b < \Delta t\), all three are scaled by the burn fraction \(f = t_b / \Delta t\), so the mass reaches \(m_{dry}\) exactly at the step's end: every integrator stores the step-end mass \(m - \Delta t\,\dot m\) rounded once, and \(m_{dry}\) itself on the burnout step (so mass_limit = mass_dry fires there). The burn is stretched in time with its impulse unchanged: delta-v and propellant used are exact for a fixed thrust direction. The position lags an exact cutoff by \(\tfrac{T}{m_{dry}}\,\Delta t^2 f(1-f)/2\) to leading order, at most \(T\,\Delta t^2 / (8\,m_{dry})\), once per burnout (checked); the attitude differs at the same order through the thruster torque.

Constant mass properties

The inertia tensor and the centre of mass do not change as propellant is consumed; only the scalar mass varies.

Implementation: core/integrators/base.py (compute_state_derivative, state_add_scaled) · physics/aggregation.py · actuators/thrusters.py (thruster_wrench)

References: [5], [6], [7], [10], [16] — see the full bibliography.