ENH: Discrete and Continuous Controllers#946
Open
Malmahrouqi3 wants to merge 9 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #946 +/- ##
===========================================
+ Coverage 80.27% 81.07% +0.80%
===========================================
Files 104 113 +9
Lines 12769 14555 +1786
===========================================
+ Hits 10250 11801 +1551
- Misses 2519 2754 +235 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
538aca0 to
a4de476
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class support for discrete (fixed refresh rate) and continuous (called every solver step) controllers to RocketPy’s flight simulation, aligning with the controller architecture discussed in issue #274.
Changes:
- Invoke continuous controllers during the solver stepping loop (instead of via fixed time nodes).
- Add
Rocket.add_discrete_controllerandRocket.add_continuous_controllerhelpers that build_Controllerobjects with finite vsinfsampling rates. - Update
_Controllerto defaultsampling_ratetomath.infand document the “infinite sampling” behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
rocketpy/simulation/flight.py |
Calls continuous controllers each solver step and skips time-node creation for sampling_rate=inf. |
rocketpy/rocket/rocket.py |
Adds Rocket-level APIs to register discrete vs continuous controllers. |
rocketpy/control/controller.py |
Defaults controller sampling rate to infinity and updates documentation accordingly. |
Comments suppressed due to low confidence (1)
rocketpy/control/controller.py:81
- The added note in the docstring exceeds the typical line-length used elsewhere in the project (and likely will be reformatted by Ruff/Black). Please wrap this note to keep docstring formatting consistent/readable, and consider clarifying how
sampling_rate=infinteracts with the existing1/sampling_ratewording in thesampling_rateparameter description.
.. note:: The function will be called according to the sampling rate
specified. If unspecified, the default sampling rate is set to infinity, meaning that the
controller function will be called at every step of the simulation.
sampling_rate : float
The sampling rate of the controller function in Hertz (Hz). This
means that the controller function will be called every
`1/sampling_rate` seconds.
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.
Pull request type
Checklist
black rocketpy/ tests/) has passed locallyCurrent behavior
#274
New behavior
Tested on the Airbrakes Example (
docs/user/airbrakes.rst)Breaking change
Additional information
There is no node creation for continuous controllers hence this step is skipped in
flight.py. Instead, they are called in each of the ODE solver step, hence not relying on fixed sampling rate.