Skip to content

BUG: use the angular rates in the solid propulsion equations of motion - #1195

Open
MateusStano wants to merge 1 commit into
developfrom
bug/solid-propulsion-angular-rates
Open

MateusStano wants to merge 1 commit into
developfrom
bug/solid-propulsion-angular-rates

Conversation

@MateusStano

Copy link
Copy Markdown
Member

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Lint (ruff) has passed locally
  • Flight, simulation and acceptance tests have passed locally
  • CHANGELOG.md — no action needed; an LLM workflow auto-updates it after merge

Current behavior

Flight.u_dot, the "solid_propulsion" equations of motion, zeroes the angular rates right after unpacking the state:

_, _, z, vx, vy, vz, e0, e1, e2, e3, omega1, omega2, omega3 = u
omega1, omega2, omega3 = 0, 0, 0

So the aerodynamics (every surface's forces and moments, the rate-dependent drag inputs, the ω × r term 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 SolidMotor is 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_dot used the real rates.

On Calisto with 5–15 m/s wind, apogee-terminated:

before after u_dot_generalized
max pitch rate 12.0 rad/s 0.13 rad/s 0.12 rad/s
max roll rate, 1.5° cant 1035 rad/s 38.4 rad/s 38.5 rad/s
apogee 4729 m 4643 m 4632 m
position at apogee (x, y) (303, 366) m (−585, 568) m (−654, 569) m

New 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_flight only checked all_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_flight now asserts the roll rate is bounded and tracks the airspeed through the coast.

With the bug re-introduced, the three tests that exercise u_dot fail.

Breaking change

  • No

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_dot and u_dot_generalized line by line for a review question on #968. The same fix is applied on enh/events.

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.
@MateusStano
MateusStano requested a review from a team as a code owner September 15, 2026 00:59
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.59%. Comparing base (a50d07d) to head (f3c0c86).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant