Implement actuator module#8
Open
chichunwang wants to merge 10 commits into
Open
Conversation
There was a problem hiding this comment.
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.actuatormodule (baseActuator+ Roll/Throttle/TVC actuators, including rate limiting and first-order dynamics). - Updated
Rocket/Flightto use the new actuator objects and renamed TVC integration tothrust_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, | ||
| ) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the actuator-related features and prepares them for the active control simulation workflow.
Main changes
Testing
Branch
Source branch:
enh/actuatorTarget branch:
develop