test_cannonballDrag

test_cannonballDrag.test_cannonballDrag()[source]

Unit test for the CannonballDrag model in isolation.

This test verifies that the aerodynamic drag force and torque computed by CannonballDrag match the analytical cannonball drag formulation for a single site-fixed reference frame. The test prescribes atmospheric density, drag geometry, site attitude, and inertial velocity via input messages, and executes one simulation step.

The expected drag force is computed analytically by rotating the inertial velocity into the site frame using the provided MRPs and applying \(F = \tfrac{1}{2} \rho v^2 C_D A\) in the direction opposite the flow. The expected torque is computed as the cross product between the center-of-pressure offset and the drag force.

The test passes if the force and torque published by forceOutMsg and torqueOutMsg match the analytical reference values to within numerical tolerance.

test_cannonballDrag.test_orbit(orbitCase: Literal['LPO', 'LTO'], planetCase: Literal['earth', 'mars'], showPlots=False)[source]

Integration test for CannonballDrag in an orbital simulation.

This test validates the behavior of the CannonballDrag module when coupled with MuJoCo dynamics, point-mass gravity, and an exponential atmosphere model. A spacecraft is propagated in either a low circular orbit (LPO) or a low transfer orbit (LTO) about a selected planet, and the drag force is applied continuously throughout the orbit.

At each simulation step, the drag force produced by CannonballDrag is compared against an independent reference implementation that computes cannonball drag directly from the recorded inertial velocity, atmospheric density, drag coefficient, projected area, and attitude. Agreement between the simulated and reference drag forces over the entire trajectory is required for the test to pass.

Optional plots can be generated to visualize orbital motion, atmospheric density, and drag force history when showPlots is enabled.