Skip to content

Commit a49baf4

Browse files
committed
MNT: move controller initialization to private method
1 parent aaa3f7b commit a49baf4

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

rocketpy/simulation/flight.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -607,18 +607,7 @@ def __init__(
607607
self.equations_of_motion = equations_of_motion
608608

609609
# Controller initialization
610-
self._controllers = self.rocket._controllers[:]
611-
if self._controllers:
612-
if self.time_overshoot == True:
613-
warnings.warn(
614-
"time_overshoot is set to True, but controllers are present. "
615-
"Controllers will not work properly. "
616-
"Consider setting time_overshoot=False in the Flight object "
617-
"to use controllers."
618-
)
619-
# reset controllable object to initial state (only airbrakes for now)
620-
for air_brakes in self.rocket.air_brakes:
621-
air_brakes._reset()
610+
self.__init_controllers()
622611

623612
# Flight initialization
624613
self.__init_post_process_variables()
@@ -1219,6 +1208,21 @@ def __init_equations_of_motion(self):
12191208
if self.equations_of_motion == "solid_propulsion":
12201209
self.u_dot_generalized = self.u_dot
12211210

1211+
def __init_controllers(self):
1212+
"""Initialize controllers"""
1213+
self._controllers = self.rocket._controllers[:]
1214+
if self._controllers:
1215+
if self.time_overshoot == True:
1216+
warnings.warn(
1217+
"time_overshoot is set to True, but controllers are present. "
1218+
"Controllers will not work properly. "
1219+
"Consider setting time_overshoot=False in the Flight object "
1220+
"to use controllers."
1221+
)
1222+
# reset controllable object to initial state (only airbrakes for now)
1223+
for air_brakes in self.rocket.air_brakes:
1224+
air_brakes._reset()
1225+
12221226
def __cache_post_process_variables(self):
12231227
"""Cache post-process variables for simulations with controllers."""
12241228
self.__retrieve_arrays = [

0 commit comments

Comments
 (0)