Skip to content

Commit

Permalink
MNT: move controller initialization to private method
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusStano committed Apr 25, 2024
1 parent aaa3f7b commit a49baf4
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions rocketpy/simulation/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,18 +607,7 @@ def __init__(
self.equations_of_motion = equations_of_motion

# Controller initialization
self._controllers = self.rocket._controllers[:]
if self._controllers:
if self.time_overshoot == True:
warnings.warn(
"time_overshoot is set to True, but controllers are present. "
"Controllers will not work properly. "
"Consider setting time_overshoot=False in the Flight object "
"to use controllers."
)
# reset controllable object to initial state (only airbrakes for now)
for air_brakes in self.rocket.air_brakes:
air_brakes._reset()
self.__init_controllers()

# Flight initialization
self.__init_post_process_variables()
Expand Down Expand Up @@ -1219,6 +1208,21 @@ def __init_equations_of_motion(self):
if self.equations_of_motion == "solid_propulsion":
self.u_dot_generalized = self.u_dot

def __init_controllers(self):
"""Initialize controllers"""
self._controllers = self.rocket._controllers[:]
if self._controllers:
if self.time_overshoot == True:
warnings.warn(
"time_overshoot is set to True, but controllers are present. "
"Controllers will not work properly. "
"Consider setting time_overshoot=False in the Flight object "
"to use controllers."
)
# reset controllable object to initial state (only airbrakes for now)
for air_brakes in self.rocket.air_brakes:
air_brakes._reset()

def __cache_post_process_variables(self):
"""Cache post-process variables for simulations with controllers."""
self.__retrieve_arrays = [
Expand Down

0 comments on commit a49baf4

Please sign in to comment.