Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Parachute trigger doesn't work if "Apogee" is used instead of "apogee" #489

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ straightforward as possible.

### Fixed

-
- ENH: Parachute trigger doesn't work if "Apogee" is used instead of "apogee" [#489](https://github.com/RocketPy-Team/RocketPy/pull/489)

## [v1.1.2] - 2023-11-25

Expand Down
21 changes: 16 additions & 5 deletions rocketpy/rocket/parachute.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,17 @@

self.prints = _ParachutePrints(self)

# evaluate the trigger
self.__evaluate_trigger_function(trigger)

def __evaluate_trigger_function(self, trigger):
"""This is used to set the triggerfunc attribute that will be used to
interact with the Flight class.
"""
if callable(trigger):
self.triggerfunc = trigger

elif isinstance(trigger, (int, float)):
# trigger is interpreted as the absolute height at which the parachute will be ejected
# The parachute is deployed at a given height
def triggerfunc(p, h, y):
# p = pressure considering parachute noise signal
# h = height above ground level considering parachute noise signal
Expand All @@ -184,8 +190,8 @@

self.triggerfunc = triggerfunc

elif trigger == "apogee":
# trigger for apogee
elif trigger.lower() == "apogee":
# The parachute is deployed at apogee
def triggerfunc(p, h, y):
# p = pressure considering parachute noise signal
# h = height above ground level considering parachute noise signal
Expand All @@ -194,7 +200,12 @@

self.triggerfunc = triggerfunc

return None
else:
raise ValueError(

Check warning on line 204 in rocketpy/rocket/parachute.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/rocket/parachute.py#L204

Added line #L204 was not covered by tests
f"Unable to set the trigger function for parachute '{self.name}'. "
+ "Trigger must be a callable, a float value or the string 'apogee'. "
+ "See the Parachute class documentation for more information."
)

def __str__(self):
"""Returns a string representation of the Parachute class.
Expand Down
Loading