Skip to content

Commit b11b21d

Browse files
committed
ENH: private controller class and related attributes
1 parent c0408ce commit b11b21d

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

rocketpy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
TankGeometry,
2323
UllageBasedTank,
2424
)
25-
from .control import Controller
25+
from .control import _Controller
2626
from .rocket import (
2727
AeroSurface,
2828
AirBrakes,

rocketpy/control/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .controller import Controller
1+
from .controller import _Controller

rocketpy/control/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ..prints.controller_prints import _ControllerPrints
22

33

4-
class Controller:
4+
class _Controller:
55
"""A class for storing and running controllers on a rocket. Controllers
66
have a controller function that is called at a specified sampling rate
77
during the simulation. The controller function can access and modify

rocketpy/rocket/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from rocketpy.control.controller import Controller
1+
from rocketpy.control.controller import _Controller
22
from rocketpy.rocket.aero_surface import (
33
AeroSurface,
44
AirBrakes,

rocketpy/rocket/rocket.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy as np
44

5-
from rocketpy.control.controller import Controller
5+
from rocketpy.control.controller import _Controller
66
from rocketpy.mathutils.function import Function
77
from rocketpy.motors.motor import EmptyMotor
88
from rocketpy.plots.rocket_plots import _RocketPlots
@@ -99,7 +99,7 @@ class Rocket:
9999
Collection of parachutes of the rocket.
100100
Rocket.air_brakes : list
101101
Collection of air brakes of the rocket.
102-
Rocket.controllers : list
102+
Rocket._controllers : list
103103
Collection of controllers of the rocket.
104104
Rocket.cp_position : Function
105105
Function of Mach number expressing the rocket's center of pressure
@@ -282,7 +282,7 @@ def __init__(
282282
self.parachutes = []
283283

284284
# Controllers data initialization
285-
self.controllers = []
285+
self._controllers = []
286286

287287
# AirBrakes data initialization
288288
self.air_brakes = []
@@ -811,7 +811,7 @@ def add_surfaces(self, surfaces, positions):
811811
self.evaluate_stability_margin()
812812
self.evaluate_static_margin()
813813

814-
def add_controllers(self, controllers):
814+
def _add_controllers(self, controllers):
815815
"""Adds a controller to the rocket.
816816
817817
Parameters
@@ -826,9 +826,9 @@ def add_controllers(self, controllers):
826826
None
827827
"""
828828
try:
829-
self.controllers.extend(controllers)
829+
self._controllers.extend(controllers)
830830
except TypeError:
831-
self.controllers.append(controllers)
831+
self._controllers.append(controllers)
832832

833833
def add_tail(
834834
self, top_radius, bottom_radius, length, position, radius=None, name="Tail"
@@ -1280,15 +1280,15 @@ def add_air_brakes(
12801280
deployment_level=0,
12811281
name=name,
12821282
)
1283-
controller = Controller(
1283+
controller = _Controller(
12841284
interactable_objects=air_brakes,
12851285
controller_function=controller_function,
12861286
sampling_rate=sampling_rate,
12871287
initial_observed_variables=initial_observed_variables,
12881288
name=controller_name,
12891289
)
12901290
self.air_brakes.append(air_brakes)
1291-
self.add_controllers(controller)
1291+
self._add_controllers(controller)
12921292
return air_brakes, controller
12931293

12941294
def set_rail_buttons(

rocketpy/simulation/flight.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Flight:
5050
the beginning of the rail.
5151
Flight.name: str
5252
Name of the flight.
53-
Flight.controllers : list
53+
Flight._controllers : list
5454
List of controllers to be used during simulation.
5555
Flight.max_time : int, float
5656
Maximum simulation time allowed. Refers to physical time
@@ -584,7 +584,7 @@ def __init__(
584584
if self.rail_length <= 0:
585585
raise ValueError("Rail length must be a positive value.")
586586
self.parachutes = self.rocket.parachutes[:]
587-
self.controllers = self.rocket.controllers[:]
587+
self._controllers = self.rocket._controllers[:]
588588
self.inclination = inclination
589589
self.heading = heading
590590
self.max_time = max_time
@@ -660,7 +660,7 @@ def __init__(
660660
self.parachutes, phase.t, phase.time_bound
661661
)
662662
phase.TimeNodes.add_controllers(
663-
self.controllers, phase.t, phase.time_bound
663+
self._controllers, phase.t, phase.time_bound
664664
)
665665
# Add lst time node to permanent list
666666
phase.TimeNodes.add_node(phase.time_bound, [], [])
@@ -693,7 +693,7 @@ def __init__(
693693
for callback in node.callbacks:
694694
callback(self)
695695

696-
for controller in node.controllers:
696+
for controller in node._controllers:
697697
controller(self.t, self.y_sol, self.solution)
698698

699699
for parachute in node.parachutes:
@@ -3630,7 +3630,7 @@ def __init__(self, t, parachutes, controllers):
36303630
self.t = t
36313631
self.parachutes = parachutes
36323632
self.callbacks = []
3633-
self.controllers = controllers
3633+
self._controllers = controllers
36343634

36353635
def __repr__(self):
36363636
return (

0 commit comments

Comments
 (0)