Skip to content

Conversation

RahulKrishna145
Copy link

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)
  • ReadMe, Docs and GitHub updates
  • Other (please describe):

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

Current behavior

here, air brakes controller doesn't pass environment as parameter but uses the global variables.

New behavior

Now, air brakes controller uses env parameter, you can use the file "test_environment_parameter.py" to check functioning.

Breaking change

  • No

Additional information

Enter text here...

@Gui-FernandesBR
Copy link
Member

@MateusStano could you review this one please?

Copy link

@Copilot 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 solves the issue where air brake controllers relied on global environment variables by adding an environment parameter to the controller function signature. This enables local access to atmospheric conditions without using global variables.

  • Added environment parameter support to controller functions (6, 7, or 8 parameters now supported)
  • Updated controller initialization to handle the new environment parameter with backward compatibility
  • Created test fixtures and standalone test script to demonstrate the new functionality

Reviewed Changes

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

Show a summary per file
File Description
tests/fixtures/function/function_fixtures.py Added new test fixture demonstrating environment parameter usage in controller
test_environment_parameter.py Standalone test script showing different controller signatures and environment usage
rocketpy/simulation/flight.py Updated simulation to pass environment parameter to controllers
rocketpy/rocket/rocket.py Updated documentation to describe the new environment parameter
rocketpy/control/controller.py Enhanced controller initialization to support 8-parameter functions and updated call signature

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

altitude_ASL = state[2] # altitude above sea level
altitude_AGL = altitude_ASL - environment.elevation # altitude above ground level
vx, vy, vz = state[3], state[4], state[5]

Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Remove trailing whitespace on line 147 to maintain code cleanliness.

Suggested change

Copilot uses AI. Check for mistakes.

print(" • Backward compatibility maintained")

print(f"\n🚀 Example usage in controller:")
print(" # Old way (with global variables):")
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

[nitpick] The example shows 'env' as a global variable, but this is misleading. The old way would typically use a different pattern. Consider showing a more accurate example of how global variables were actually accessed before this change.

Suggested change
print(" # Old way (with global variables):")
print(" # Old way (with global variables):")
print(" from globals import env # ❌ Import global variable")

Copilot uses AI. Check for mistakes.

Comment on lines +158 to +159
"observed_variables, interactive_objects, sensors, environment). "
"The last two arguments (sensors and environment) are optional."
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

The error message is inconsistent - it states that both sensors and environment are optional, but a 6-parameter function doesn't include sensors. Consider clarifying that sensors is optional for 6-7 parameter functions, and environment is optional for 6-8 parameter functions.

Suggested change
"observed_variables, interactive_objects, sensors, environment). "
"The last two arguments (sensors and environment) are optional."
"observed_variables, interactive_objects[, sensors[, environment]]). "
"The 'sensors' argument is optional for 6-7 parameter functions, "
"and the 'environment' argument is optional for 6-8 parameter functions."

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

3 participants