Skip to content

Conversation

@Gui-FernandesBR
Copy link
Member

@Gui-FernandesBR Gui-FernandesBR commented Aug 15, 2025

Pull request type

  • Code maintenance (refactoring, formatting, tests)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior vs New behavior

  1. The Flight.__simulate() method is more readable
  2. Controllers can now be used with time overshoot option = True (solves ENH: Allow overshooting controllers #663)
  3. the same is valid for sensors

Controllers and Sensors Simulations should run faster!!

Breaking change

  • No

Additional information

  • I need help to review this PR carefully, although tests are passing locally.

@Gui-FernandesBR Gui-FernandesBR requested a review from a team as a code owner August 15, 2025 02:44
@Gui-FernandesBR Gui-FernandesBR self-assigned this Aug 15, 2025
@Gui-FernandesBR Gui-FernandesBR added Refactor Flight Flight Class related features labels Aug 15, 2025
@Gui-FernandesBR Gui-FernandesBR added this to the Release v1.X.0 milestone Aug 15, 2025
@Gui-FernandesBR Gui-FernandesBR linked an issue Aug 15, 2025 that may be closed by this pull request
Copy link

Copilot AI left a comment

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 refactors the Flight class's __simulate() method to improve readability and enable time overshoot functionality for controllers and sensors. The main changes include:

  • Breaking down the monolithic __simulate() method into smaller, focused methods for better maintainability
  • Enabling controllers and sensors to work with time_overshoot=True option, which was previously disabled
  • Optimizing simulation performance by allowing overshootable time nodes for sensors and controllers

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rocketpy/simulation/flight.py Major refactoring of Flight simulation methods, breaking __simulate() into smaller helper methods and adding support for time overshoot with controllers/sensors
tests/integration/test_plots.py Reduced number of test flight configurations from 16 to 4 for faster test execution
tests/integration/test_flight.py Added new test for air brakes with time overshoot and renamed existing test for clarity
tests/integration/test_environment.py Minor cleanup removing unused today variable
tests/fixtures/flight/flight_fixtures.py Added new fixture for air brakes flight with time overshoot enabled

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@phmbressan phmbressan left a comment

Choose a reason for hiding this comment

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

Good work! I hope this is the beginning of having a much more readable and developer friendly Flight class.

My only concern is making sure the behavior is exactly the same as before, therefore I made a single important comment on the early return of parachute triggers just to make sure we are on the same page. Of course, all the tests being green is already a big step.

Aside from that, my other suggestions are more style/naming choices. I prefer having some more standardized names for some methods, but I would approve the PR in the current state even if these suggestions are not taken, since it already does loads for readability.

@Gui-FernandesBR Gui-FernandesBR marked this pull request as draft November 27, 2025 12:58
@Gui-FernandesBR Gui-FernandesBR force-pushed the mnt/overshoot-controllers branch from b9660cf to dd80852 Compare November 27, 2025 20:09
@Gui-FernandesBR Gui-FernandesBR marked this pull request as ready for review November 27, 2025 20:36
@Gui-FernandesBR
Copy link
Member Author

Gui-FernandesBR commented Nov 27, 2025

Remaining tasks:

  • update changelog
  • run pytest slow mode

@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 88.58696% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.08%. Comparing base (9cf3dd4) to head (7358e68).
⚠️ Report is 24 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/simulation/flight.py 88.20% 21 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #843      +/-   ##
===========================================
+ Coverage    80.27%   81.08%   +0.80%     
===========================================
  Files          104      107       +3     
  Lines        12769    13812    +1043     
===========================================
+ Hits         10250    11199     +949     
- Misses        2519     2613      +94     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (2)

rocketpy/simulation/flight.py:697

  • Duplicate controller processing. Controllers are already processed inside __process_sensors_and_controllers_at_current_node() at line 848-854. This loop at lines 691-697 should be removed to avoid executing controllers twice at each node.
                self.__process_sensors_and_controllers_at_current_node(node, phase)

                for controller in node._controllers:
                    controller(
                        self.t,
                        self.y_sol,
                        self.solution,
                        self.sensors,
                    )

rocketpy/simulation/flight.py:714

  • Duplicate parachute handling logic. The parachute trigger check and deployment logic at lines 699-759 duplicates the functionality in __check_and_handle_parachute_triggers() called at line 760. This entire block should be removed since the extracted method already handles this logic.
                for parachute in node.parachutes:
                    # Calculate and save pressure signal
                    (
                        noisy_pressure,
                        height_above_ground_level,
                    ) = self.__calculate_and_save_pressure_signals(
                        parachute, node.t, self.y_sol[2]
                    )
                    if parachute.triggerfunc(
                        noisy_pressure,
                        height_above_ground_level,
                        self.y_sol,
                        self.sensors,
                    ):
                        # Remove parachute from flight parachutes
                        self.parachutes.remove(parachute)

@Gui-FernandesBR Gui-FernandesBR linked an issue Nov 29, 2025 that may be closed by this pull request
@Gui-FernandesBR Gui-FernandesBR force-pushed the mnt/overshoot-controllers branch 6 times, most recently from 5a9c9c6 to 69da915 Compare December 4, 2025 21:21
…ontroller processing

TST: add tests for overshootable controllers

TST: fix slow tests

fix merge conflicts
fix slow tests

update CHANGELOG

Update rocketpy/simulation/flight.py

fix lint
@Gui-FernandesBR Gui-FernandesBR force-pushed the mnt/overshoot-controllers branch from 69da915 to 7358e68 Compare December 9, 2025 00:16
@Gui-FernandesBR
Copy link
Member Author

I'm merging with this since no further comments were made since last copilot's review. I'm confident the test coverage will handle any problems.

@Gui-FernandesBR Gui-FernandesBR merged commit 45a891e into develop Dec 9, 2025
7 checks passed
@Gui-FernandesBR Gui-FernandesBR deleted the mnt/overshoot-controllers branch December 9, 2025 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Flight Flight Class related features Refactor

Projects

No open projects
Status: Backlog

Development

Successfully merging this pull request may close these issues.

ENH: Flight Class Overhaul ENH: Allow overshooting controllers

3 participants