Repository navigation
BUG: use the angular rates in the solid propulsion equations of motion - #1195
MateusStano wants to merge 1 commit into
Conversation
Flight.u_dot zeroed omega1, omega2 and omega3 right after unpacking the state, so the aerodynamics and the Euler equations saw a rocket that never rotates: no aerodynamic damping at all. A pitch rate produced no restoring moment and a canted fin spun the rocket up without bound (1000 rad/s for a 1.5 degree cant on Calisto). Every rocket with a SolidMotor is mapped to these equations, so every such 6-DOF flight was affected. Introduced with the 3-DOF work in #745. With the rates back, the solid propulsion equations agree with the generalized ones to 0.25% on apogee and 0.2% on roll rate. Tests: each body axis rate must produce a damping angular acceleration with both sets of equations, the two must agree when rotating, and a rolling flight's roll rate must stay bounded and track the airspeed.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1195 +/- ##
===========================================
+ Coverage 91.58% 91.59% +0.01%
===========================================
Files 132 132
Lines 18404 18403 -1
===========================================
+ Hits 16855 16857 +2
+ Misses 1549 1546 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Gui-FernandesBR
left a comment
There was a problem hiding this comment.
The fix is right: it restores u_dot exactly as it was before #745. The three u_dot tests fail on develop (a50d07d5) and pass here, and pytest tests -m "not slow" plus the acceptance tests pass locally. One correction to the description, and two old bugs in u_dot that this PR makes live again.
-
Scope.
equations_of_motiondefaults to"standard"(u_dot_generalized), and nothing pickssolid_propulsionautomatically. So only flights that opt in were affected (v1.12.0 to v1.13.0), not everySolidMotorflight. None of the acceptance tests opts in, so they don't cover this change. The zeroing also froze the attitude (e0dot..e3dotwere 0), not only the aero. The changelog entry will be written from this description, so it's worth fixing. -
Linear acceleration, wrong axis. The transport terms in L2450-2465 treat the propellant offset
bas lying on body axis 1, but it lies on axis 3 (the thrust axis). Onflight_calisto_robustat t = 1.5 s (m_p = 1.57 kg), a pure roll of ω3 = 20 rad/s givesu_dota lateral body acceleration of −30.3 m/s², whileu_dot_generalizedgives none. With the offset on axis 3 and the same sign convention, the terms areb·m_p·(α2 + ω1ω3),b·m_p·(−α1 + ω2ω3)and−b·m_p·(ω1² + ω2²). -
Inertia rate, wrong units.
mass_flow_rate * (rocket_dry_mass - 1) * (b / total_mass) ** 2(L2403, L2428) is dimensionally inconsistent. Since d(μb²)/dt = ṁ·b²·(m_r/M)², it should readrocket_dry_mass**2.
Neither 2 nor 3 blocks this PR, since without it the rocket doesn't rotate at all. Fixing them here or in a follow-up is your call.
| # The canted fins spin the rocket up and their damping balances it, so the | ||
| # roll rate tracks the airspeed during the coast. Without damping it grows | ||
| # past a thousand rad/s. | ||
| times = test_flight.w3[:, 0] |
There was a problem hiding this comment.
This flight runs with the default equations_of_motion="standard", so it also passes on develop and doesn't guard this fix. It's still useful coverage of u_dot_generalized.
| the angular acceleration a rate produces must agree closely. | ||
| """ | ||
| flight = flight_calisto_robust | ||
| t, state = _coasting_state(flight) |
There was a problem hiding this comment.
In the coast m_p = 0, so every b·m_p coupling term vanishes and this test can't see the axis bug in the linear acceleration (point 2 in the review). A burn-phase case would catch it once it's fixed, e.g. t = 1.5 s with ω3 = 20 rad/s.
Pull request type
Checklist
ruff) has passed locallyCHANGELOG.md— no action needed; an LLM workflow auto-updates it after mergeCurrent behavior
Flight.u_dot, the"solid_propulsion"equations of motion, zeroes the angular rates right after unpacking the state:So the aerodynamics (every surface's forces and moments, the rate-dependent drag inputs, the
ω × rterm of each surface's local airspeed) and the Euler equations see a rocket that never rotates. There is no aerodynamic damping at all: a pitch rate produces no restoring moment, and a canted fin spins the rocket up without bound.Every rocket with a
SolidMotoris mapped to these equations automatically, so every such 6-DOF flight has been affected. The line was introduced with the 3-DOF work in #745; before it,u_dotused the real rates.On Calisto with 5–15 m/s wind, apogee-terminated:
u_dot_generalizedNew behavior
The line is removed. The solid-propulsion equations now agree with the generalized ones to ~0.25 % on apogee and ~0.2 % on roll rate, which is the genuine modelling difference between them (two-body mass model and axisymmetric inertia versus the full tensor).
Why the suite never caught it: no test asserted anything about rotation (
test_rolling_flightonly checkedall_info()), the hard-coded expected values are sampled at rail exit, apogee and landing where the rates are zero anyway, the fixture environments have no wind so there is no angle of attack to damp, and the two sets of equations were never compared. The new tests close those gaps:test_an_angular_rate_is_aerodynamically_damped(unit, both derivatives): a rate about each body axis, on a coasting state, produces an angular acceleration that opposes it, roughly linearly.test_solid_propulsion_and_generalized_equations_agree_when_rotating(unit): with a pitch rate applied, both models give the same damping moment and accelerations.test_solid_propulsion_equations_damp_rotation(integration): a 1.5° canted-fin Calisto reaches the same roll rate with either model, and stays under 100 rad/s.test_rolling_flightnow asserts the roll rate is bounded and tracks the airspeed through the coast.With the bug re-introduced, the three tests that exercise
u_dotfail.Breaking change
Results of solid-motor 6-DOF flights change, since they are now damped: apogee moves by a percent or so on Calisto, and any quantity involving rotation (roll rate, angular accelerations, sensor readings on gyroscopes) changes substantially. The acceptance tests against real flight data still pass.
Additional information
Found while comparing
u_dotandu_dot_generalizedline by line for a review question on #968. The same fix is applied onenh/events.