Skip to content

BUG: fix the tip-off phase and run it without a flag - #1217

Merged
MateusStano merged 3 commits into
developfrom
bug/tip-off-fixes
Nov 17, 2026
Merged

MateusStano merged 3 commits into
developfrom
bug/tip-off-fixes

Conversation

@MateusStano

Copy link
Copy Markdown
Member

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added
  • Docs have been reviewed and updated
  • Lint (ruff, pylint) has passed locally
  • All tests (pytest tests) have passed locally
  • CHANGELOG.md: no action needed here, see the note at the end

What this is

This closes the Flight task of the v1.14.0 release checklist (#1209): "the 4 tip-off bugs in #920, a validation test against an independent ODE, rail-exit root finding". It fixes the tip-off phase from #920 (#28) instead of reverting it, as discussed in #1194.

Current behavior

The phase is on develop behind Flight(use_udot_rail2=True), with these problems:

  • No quantitative validation is committed.
  • Inside the window the reported accelerations are those of a free rocket, and the force on the lower button is not reported.
  • The rail exit time comes from one cubic fitted over the last solver step. On a long step the exit is misplaced (14.6 m of travel instead of 3.86 m in a smooth case), and with the flag on it raises "No valid roots found".
  • A parachute opening inside the window is handed back to free flight, tip_off_duration can be negative, and a very short rail leaves the flight in the tip-off phase forever.

New behavior

  • The phase is always on, with no flag. It runs whenever both rail buttons start on the rail, in 6 DOF with the standard equations of motion. Otherwise the flight goes straight to free flight and reports no window.
  • Validated. The tests compare the phase with an independent rigid-body model (button sliding on the rail, thrust and gravity only), integrated separately. Pitch angle and pitch rate at the end of the window agree to about 1e-7 at 85° and 60°, and the button force to 1e-5. The leading term matches equation (2) of Peng et al. (2017), the reference posted on ENH: Implement 3-DOF Single Rail Button Flight Phase (Tip-off Analysis) #28.
  • Rail exits are found with brentq on the solver's own interpolation of the step.
  • Outputs. Accelerations inside the window are the constrained ones. rail_button2_normal_force and rail_button2_shear_force cover the window. between_rails_* is renamed to tip_off_end_*.
  • udot_rail2 simplified, and the three event bugs above are fixed with regression tests.
  • docs/technical/tip_off.rst updated, including the limits of the model.

Why always on

I want this to be the default with no switch:

  • It is physics every rail launch goes through, not an optional feature. Without the phase the rocket is fully free while its lower button is still in the rail, so the button drifts off the rail line (0.27 mm for Calisto, 12.6 mm at thrust-to-weight 2 on a 60° rail). With the phase it stays on the rail.
  • It is validated and cheap: 17 to 21 derivative calls per flight, under 1% of the run time.
  • A flag would be a liability. use_udot_rail2 is named after an internal method, was never released, and would have to be deprecated as soon as the phase became the default. Removing it now costs nothing.
  • Results should not depend on a switch most users would never find. The effect is a bias, always nose-down, so a Monte Carlo study does not average it out.

Effect on results

Every flight with two rail buttons changes: the rocket leaves the rail with a small nose-down pitch rate. Calisto on a 5.2 m rail, no wind, against the phase switched off:

Rail Solid (M1670): apogee Solid: impact range Liquid (docs example): apogee Liquid: impact range
90° 0.0 m +0.1 m -0.1 m +0.2 m
85° -2.3 m (-0.07%) +22.7 m (+3.5%) -8.5 m (-0.19%) +70.1 m (+7.3%)
80° -8.9 m (-0.28%) +41.3 m (+3.2%) -32.3 m (-0.75%) +124.7 m (+6.8%)
70° -31.4 m (-1.10%) +61.0 m (+2.6%) -107.8 m (-2.87%) +164.0 m (+5.0%)

At 85° this is the same as tilting the rail by about 0.2° (solid) or 0.4° (liquid, slower rail exit). Pinned values in tests/unit/simulation/test_flight.py are re-baselined; the acceptance tests against measured flights pass unchanged.

Limits, stated in the docs: no rail friction, no contact between the rocket body and the rail, and no measured flight to compare against.

Breaking change

  • No

use_udot_rail2 and the between_rails_* names exist only on develop. Simulation results change as described above.

Additional information

  • BUG: fix Monte Carlo release blockers #1213 passes use_udot_rail2 through StochasticFlight, tests it and names it in the changelog. Whichever PR merges second has to drop those lines.
  • CHANGELOG: the existing ENH: Implement 3-DOF Single Rail Button Flight Phase (Tip-off Analysis) #920 entry describes the opt-in flag and the old names, and needs rewording when this merges.
  • One line in rocketpy/tools.py is reformatted so ruff format --check passes.
  • Found on the way, same on master, not fixed here: the rail button forces with both buttons on the rail use a wrong lever arm and leave out the weight, and a rocket whose thrust starts below its weight never leaves the rail unless max_time_step is set.

Refs #1209, #1194, #920, #28.

🤖 Generated with Claude Code

MateusStano and others added 3 commits November 16, 2026 19:35
The line was too long for ruff format --check.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The phase from #920 now runs in every 6 DOF flight with the standard
equations of motion whose two rail buttons start on the rail. The
use_udot_rail2 flag is removed.

- udot_rail2 is rewritten: same model, no closure, no numpy solve and no
  cache written by u_dot_generalized on every call.
- Rail exits are found with brentq on the solver's dense output instead
  of one cubic fitted over the last step, which misplaced the exit on
  long steps and could raise "No valid roots found".
- The accelerations reported inside the window are the constrained ones.
- The lower rail button forces cover the window and are saved with the
  flight.
- between_rails_* is renamed to tip_off_end_*, and tip_off_end_time is
  saved with the flight.
- A parachute opening inside the window is no longer handed back to free
  flight, tip_off_duration is never negative, and a rail shorter than the
  nozzle to lower button distance skips the phase.
- The on-rail button forces select their points by time, since flights
  with controllers store no post-processed point at event times.

The tests compare the phase with an independent rigid-body model of a
button sliding on the rail (pitch angle, pitch rate and button force).
Pinned values that depend on the trajectory are re-baselined.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Removes the flag, corrects the sign of the r_CM x omega_dot terms after
#1196, states the limits of the model (no friction, no contact between
the rocket body and the rail), describes the outputs and adds a
verification section with the reference of Peng et al. (2017).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@MateusStano
MateusStano requested a review from a team as a code owner November 16, 2026 22:36
@MateusStano

Copy link
Copy Markdown
Member Author

@Gui-FernandesBR this is a follow-up for the v1.14.0 release: it covers the Flight task of #1209 (the tip-off bugs in #920, the validation test and the rail-exit root finding), fixing the phase forward instead of reverting it.

Two things to be aware of:

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.68%. Comparing base (501c1a8) to head (92aa021).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1217   +/-   ##
========================================
  Coverage    91.67%   91.68%           
========================================
  Files          131      131           
  Lines        18242    18221   -21     
========================================
- Hits         16724    16706   -18     
+ Misses        1518     1515    -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.

Comment on lines +1058 to +1060
def distance_left(t):
x, y, z = interpolator(t)[:3]
return effective_rl**2 - (x**2 + y**2 + (z - elevation) ** 2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function will be defined at every single call, right? Maybe defining it outside of the main flight loop would save us some execution time, no?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i ran a profiler on the code, this is not impacting simulation at all

@MateusStano
MateusStano merged commit 65b9838 into develop Nov 17, 2026
10 checks passed
@MateusStano
MateusStano deleted the bug/tip-off-fixes branch November 17, 2026 00:09
@Gui-FernandesBR Gui-FernandesBR mentioned this pull request Nov 20, 2026
7 of 11 tasks
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.

2 participants