Skip to content

Implement actuator module#8

Open
chichunwang wants to merge 10 commits into
developfrom
enh/actuator
Open

Implement actuator module#8
chichunwang wants to merge 10 commits into
developfrom
enh/actuator

Conversation

@chichunwang

Copy link
Copy Markdown

Summary

This PR implements the actuator-related features and prepares them for the active control simulation workflow.

Main changes

  • Added actuator implementation
  • Updated actuator dynamics and operating limits
  • Prepared actuator module for simulation integration

Testing

  • Existing tests should be checked
  • Actuator behavior should be verified in simulation

Branch

Source branch: enh/actuator
Target branch: develop

Copilot AI review requested due to automatic review settings June 9, 2026 13:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new actuator abstraction and concrete actuator implementations (roll, throttle, and thrust vector control) to support active control workflows in RocketPy, replacing the previous standalone TVC/throttle/roll control classes and wiring the new actuators into Rocket and Flight.

Changes:

  • Added a new rocketpy.rocket.actuator module (base Actuator + Roll/Throttle/TVC actuators, including rate limiting and first-order dynamics).
  • Updated Rocket/Flight to use the new actuator objects and renamed TVC integration to thrust_vector_control.
  • Added unit tests for actuators and updated the active-control example notebook accordingly; removed legacy control classes and their print helpers.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 26 comments.

Show a summary per file
File Description
tests/unit/rocket/test_actuators.py Adds unit tests for the new actuator classes and dynamics/validation.
rocketpy/simulation/flight.py Updates flight dynamics and reset logic to use thrust_vector_control and new actuator interfaces.
rocketpy/rocket/rocket.py Switches rocket control-component creation to actuator classes; introduces add_thrust_vector_control and updated roll/throttle control creation.
rocketpy/rocket/actuator/actuator.py Adds the shared actuator base class (range limiting, rate limiting, optional 1st-order dynamics).
rocketpy/rocket/actuator/roll.py Adds roll actuator implementation built on the new base class.
rocketpy/rocket/actuator/throttle.py Adds throttle actuator implementation built on the new base class.
rocketpy/rocket/actuator/thrust_vector.py Adds 1D and 2D thrust-vector actuator implementations.
rocketpy/rocket/actuator/init.py Exposes actuator types at the package level.
rocketpy/prints/thrust_vector_actuator_prints.py Adds print helpers for the thrust vector actuator.
rocketpy/prints/throttle_actuator_prints.py Adds print helpers for the throttle actuator.
rocketpy/prints/roll_actuator_prints.py Adds print helpers for the roll actuator.
rocketpy/rocket/tvc.py Removes legacy TVC component (superseded by actuator module).
rocketpy/rocket/throttle_control.py Removes legacy throttle control component (superseded by actuator module).
rocketpy/rocket/roll_control.py Removes legacy roll control component (superseded by actuator module).
rocketpy/prints/tvc_prints.py Removes legacy TVC print helper.
rocketpy/prints/throttle_control_prints.py Removes legacy throttle control print helper.
rocketpy/prints/roll_control_prints.py Removes legacy roll control print helper.
docs/examples/halcyon_flight_sim_active_control.ipynb Updates the active-control example to the new API (add_thrust_vector_control, new actuator behavior/plotting).
Comments suppressed due to low confidence (1)

docs/examples/halcyon_flight_sim_active_control.ipynb:524

  • Notebook kernel metadata is environment-specific; other example notebooks use a generic display name (e.g., "RocketPy"). Keeping this consistent reduces noisy diffs.

assert actuator.name == "Throttle Control"
assert actuator.demand_rate == 100
assert actuator.actuator_range == (0, 1)
assert actuator.throttle == 0.0
Comment on lines +113 to +119
actuator = ThrottleActuator(
name="Custom Throttle",
demand_rate=50,
max_throttle=0.8,
throttle_rate_limit=0.1,
initial_throttle=0.5,
)

def test_throttle_property(self):
"""Test throttle getter and setter."""
actuator = ThrottleActuator(max_throttle=1.0)

def test_throttle_clamping(self):
"""Test throttle clamping to range."""
actuator = ThrottleActuator(max_throttle=1.0, clamp=True)
Comment on lines +140 to +150
actuator = ThrottleActuator(
name="Test Throttle",
max_throttle=0.8,
throttle_rate_limit=0.1,
initial_throttle=0.3,
)
data = actuator.to_dict()
assert data["name"] == "Test Throttle"
assert data["max_throttle"] == 0.8
assert data["throttle_rate_limit"] == 0.1
assert data["initial_throttle"] == 0.3
Comment on lines +204 to +207
roll_torque_time_constant : float, optional
Time constant for the roll torque actuator dynamics (first-order IIR
filter) in seconds. If None, no actuator dynamics are applied.
Must be non-negative. Default is None. demand_rate must be specified if roll_torque_time_constant is not None.
Comment on lines +235 to +237
def gimbal_angle_x(self):
"""Returns the current gimbal angle around the y-axis (yaw)."""
return self.x.gimbal_angle
Comment on lines +9 to +13
This class represents a roll actuator that applies roll torque around the rocket's Z-axis.
Magic/hand-of-god roll torque is assumed. The roll torque is positive for counter-clockwise rotation when
viewed from the nose of the rocket.
This actuator is typically controlled by a controller function similar to air brakes
and is used by ``Flight`` to model roll control system.
initial_roll_torque=0.0,
roll_torque_time_constant=None,
):
"""Initializes the RollControl class.
initial_gimbal_angle=initial_gimbal_angle,
gimbal_time_constant=gimbal_time_constant,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants