@@ -79,6 +79,14 @@ 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).
8290 Flight.max_time : int, float
8391 Maximum simulation time allowed. Refers to physical time
8492 being simulated, not time taken to run simulation.
@@ -506,6 +514,7 @@ def __init__( # pylint: disable=too-many-arguments,too-many-statements
506514 equations_of_motion = "standard" ,
507515 ode_solver = "LSODA" ,
508516 simulation_mode = "6 DOF" ,
517+ post_step_callback = None ,
509518 ):
510519 """Run a trajectory simulation.
511520
@@ -592,6 +601,12 @@ def __init__( # pylint: disable=too-many-arguments,too-many-statements
592601 simulation_mode : str, optional
593602 Simulation mode to use. Can be "6 DOF" for 6 degrees of freedom or
594603 "3 DOF" for 3 degrees of freedom. Default is "6 DOF".
604+ post_step_callback : callable, optional
605+ Callback invoked once after every successful ODE solver step for
606+ the entire simulation, including parachute phases. Signature is
607+ ``callback(flight)``, matching phase/node callbacks. Access the
608+ current time and state via ``flight.t`` and ``flight.y_sol``.
609+ Default is None.
595610 Returns
596611 -------
597612 None
@@ -600,6 +615,9 @@ def __init__( # pylint: disable=too-many-arguments,too-many-statements
600615 ----------
601616 .. [1] https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html
602617 """
618+ if post_step_callback is not None and not callable (post_step_callback ):
619+ raise TypeError ("post_step_callback must be callable or None" )
620+
603621 # Save arguments
604622 self .env = environment
605623 self .rocket = rocket
@@ -626,6 +644,7 @@ def __init__( # pylint: disable=too-many-arguments,too-many-statements
626644 self .equations_of_motion = equations_of_motion
627645 self .simulation_mode = simulation_mode
628646 self .ode_solver = ode_solver
647+ self .post_step_callback = post_step_callback
629648
630649 # Controller initialization
631650 self .__init_controllers ()
@@ -800,6 +819,9 @@ def __simulate(self, verbose):
800819 self .sensors ,
801820 self .env ,
802821 )
822+ # Full-lifecycle observer (all phases, including parachute)
823+ if self .post_step_callback is not None :
824+ self .post_step_callback (self )
803825 if self .__check_simulation_events (phase , phase_index , node_index ):
804826 break # Stop if simulation termination event occurred
805827
0 commit comments