RocketPy
RocketPy copied to clipboard
ENH: Continuous and Discrete Control
High powered rockets nowadays often have different actuators to control its trajectory, such as air brakes, canards and thrust vectoring. The trajectories of these rockets can only be accurately simulated if their actuators and controllers are taken into account.
Therefore, this issue proposes methods to handle such actuators and controllers.
This issue is directly related to issue #273.
Proposed Usage Example
from rocketpy import Rocket, Flight
from rocketpy.sensors import Accelerometer
test_rocket = Rocket(...)
nose_cone_accel = Accelerometer(...)
test_rocket.add_sensor(
sensor=nose_cone_accel,
position=(x, y, z)
)
def throttle_control():
if nose_cone_accel.current_value[0] > 100:
# To fast, throttle_down
...
test_rocket.add_discrete_controller(
controller=throttle_control
refresh_rate=100
)
test_flight = Flight(...)
nose_cone_accel.export_data('accel.csv')
Requirements
-
The
Rocketclass should have at least to additional methods:Rocket.add_discrete_controllerRocket.add_continuous_controller
-
Discrete controllers can be any callable with no argument, and that returns None. They can control the flight by changing actuators attributes, such as fin can't angle, air brake opening factor or thrust force.
-
Discrete controllers should be called several times during the integration of the equations of motion, respecting the refresh rate defined during its initialization.
-
Continuous controllers can be any callable which receives a state vector and returns a list with control forces and moments that should act on the rocket. They can also use sensors.
Proposed Architecture
Not specific guidance here, only a question: should controllers be any callable or should they be defined by a new class?
Proposed Milestone
This feature should be implemented in a major release with a better support for sensors, along with a refactoring of the Flight class.
Therefore, it can be released with v2.0.0.