Skip to content

Commit 74a0183

Browse files
Revert "ENH: add Flight post-step callback across all phases (#758) (#1128)"
This reverts commit 826531b.
1 parent bfea194 commit 74a0183

3 files changed

Lines changed: 0 additions & 64 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Attention: The newest changes should be on top -->
3737
- ENH: Support fixed-time parachute deployment triggers [#1133](https://github.com/RocketPy-Team/RocketPy/pull/1133) [#437](https://github.com/RocketPy-Team/RocketPy/issues/437)
3838
- DOC: Add SIL parachute ejection integration example [#1131](https://github.com/RocketPy-Team/RocketPy/pull/1131) [#524](https://github.com/RocketPy-Team/RocketPy/issues/524)
3939
- ENH: Model unbonded solid-motor grain CM shift [#1138](https://github.com/RocketPy-Team/RocketPy/pull/1138) [#340](https://github.com/RocketPy-Team/RocketPy/issues/340)
40-
- ENH: Add `Flight` post-step callback across all phases [#1128](https://github.com/RocketPy-Team/RocketPy/pull/1128) [#758](https://github.com/RocketPy-Team/RocketPy/issues/758)
4140
- DOC: Document angle-of-attack drag inputs [#1142](https://github.com/RocketPy-Team/RocketPy/pull/1142)
4241
- ENH: Create ensembles from user-defined profiles [#1141](https://github.com/RocketPy-Team/RocketPy/pull/1141)
4342
- ENH: Add tube-fin aerodynamic surface [#1144](https://github.com/RocketPy-Team/RocketPy/pull/1144)

‎rocketpy/simulation/flight.py‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,6 @@ class Flight:
7979
Name of the flight.
8080
Flight._controllers : list
8181
List of controllers to be used during simulation.
82-
Flight.post_step_callback : callable, optional
83-
Optional callback invoked once after every successful ODE solver
84-
step for the entire simulation, including parachute descent.
85-
Receives the ``Flight`` instance (``callback(flight)``). Use
86-
``flight.t`` and ``flight.y_sol`` for the current time and state.
87-
Controllers stop being useful after parachute deployment; this
88-
callback is the extension point for full-lifecycle observers
89-
(e.g. ground-station / radio update simulation).
9082
Flight.max_time : int, float
9183
Maximum simulation time allowed. Refers to physical time
9284
being simulated, not time taken to run simulation.
@@ -536,7 +528,6 @@ def __init__( # pylint: disable=too-many-arguments,too-many-statements
536528
equations_of_motion="standard",
537529
ode_solver="LSODA",
538530
simulation_mode="6 DOF",
539-
post_step_callback=None,
540531
use_udot_rail2=False,
541532
):
542533
"""Run a trajectory simulation.
@@ -624,12 +615,6 @@ def __init__( # pylint: disable=too-many-arguments,too-many-statements
624615
simulation_mode : str, optional
625616
Simulation mode to use. Can be "6 DOF" for 6 degrees of freedom or
626617
"3 DOF" for 3 degrees of freedom. Default is "6 DOF".
627-
post_step_callback : callable, optional
628-
Callback invoked once after every successful ODE solver step for
629-
the entire simulation, including parachute phases. Signature is
630-
``callback(flight)``, matching phase/node callbacks. Access the
631-
current time and state via ``flight.t`` and ``flight.y_sol``.
632-
Default is None.
633618
use_udot_rail2 : bool, optional
634619
If True, enable the intermediate 3-DOF "tip-off" rail phase
635620
``udot_rail2``: after the upper rail button leaves the rail (at
@@ -647,9 +632,6 @@ def __init__( # pylint: disable=too-many-arguments,too-many-statements
647632
----------
648633
.. [1] https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html
649634
"""
650-
if post_step_callback is not None and not callable(post_step_callback):
651-
raise TypeError("post_step_callback must be callable or None")
652-
653635
# Save arguments
654636
self.env = environment
655637
self.rocket = rocket
@@ -676,7 +658,6 @@ def __init__( # pylint: disable=too-many-arguments,too-many-statements
676658
self.equations_of_motion = equations_of_motion
677659
self.simulation_mode = simulation_mode
678660
self.ode_solver = ode_solver
679-
self.post_step_callback = post_step_callback
680661
# Enable or disable the intermediate 3-DOF rail phase
681662
self.use_udot_rail2 = use_udot_rail2
682663

@@ -788,9 +769,6 @@ def __simulate(self, verbose):
788769
self.sensors,
789770
self.env,
790771
)
791-
# Full-lifecycle observer (all phases, including parachute)
792-
if self.post_step_callback is not None:
793-
self.post_step_callback(self)
794772
if self.__check_simulation_events(phase, phase_index, node_index):
795773
break # Stop if simulation termination event occurred
796774

‎tests/unit/simulation/test_flight.py‎

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -235,47 +235,6 @@ def test_initial_solution_from_flight_sets_initial_time(
235235
assert second.t_initial == first.solution[-1][0]
236236

237237

238-
def test_post_step_callback_runs_before_and_after_apogee(
239-
calisto_robust, example_plain_env
240-
):
241-
"""post_step_callback must fire across the full flight, including descent.
242-
243-
Controllers are not a substitute: air-brake fixtures often terminate at
244-
apogee, and parachute phases are not meant to keep feeding actuators.
245-
This callback is the full-lifecycle observer hook (issue #758).
246-
"""
247-
callback_times = []
248-
249-
def record_step(flight):
250-
callback_times.append(flight.t)
251-
252-
flight = Flight(
253-
rocket=calisto_robust,
254-
environment=example_plain_env,
255-
rail_length=5.2,
256-
inclination=85,
257-
heading=0,
258-
terminate_on_apogee=False,
259-
post_step_callback=record_step,
260-
)
261-
262-
assert callback_times, "post_step_callback was never invoked"
263-
assert min(callback_times) < flight.apogee_time
264-
assert max(callback_times) > flight.apogee_time
265-
assert flight.t_final > flight.apogee_time
266-
267-
268-
def test_post_step_callback_must_be_callable(calisto, example_plain_env):
269-
"""Non-callable post_step_callback values are rejected at construction."""
270-
with pytest.raises(TypeError, match="post_step_callback"):
271-
Flight(
272-
rocket=calisto,
273-
environment=example_plain_env,
274-
rail_length=5.2,
275-
post_step_callback="not-callable",
276-
)
277-
278-
279238
def test_initial_stability_margin(flight_calisto_custom_wind):
280239
"""Test the initial_stability_margin method of the Flight class.
281240

0 commit comments

Comments
 (0)