Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 18 additions & 7 deletions rocketpy/rocket/parachute.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Parachute:
case, the parachute will be ejected when the rocket reaches this height
above ground level.

- The string "apogee," which triggers the parachute at apogee, i.e.,
- The string "apogee" which triggers the parachute at apogee, i.e.,
when the rocket reaches its highest point and starts descending.

Note: The function will be called according to the sampling rate
Expand Down Expand Up @@ -126,7 +126,7 @@ def __init__(
case, the parachute will be ejected when the rocket reaches this
height above ground level.

- The string "apogee," which triggers the parachute at apogee, i.e.,
- The string "apogee" which triggers the parachute at apogee, i.e.,
when the rocket reaches its highest point and starts descending.

Note: The function will be called according to the sampling rate
Expand Down Expand Up @@ -171,11 +171,17 @@ def __init__(

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 @@ def triggerfunc(p, h, y):

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 @@ def triggerfunc(p, h, y):

self.triggerfunc = triggerfunc

return None
else:
raise ValueError(
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
2 changes: 1 addition & 1 deletion rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ def add_parachute(
case, the parachute will be ejected when the rocket reaches this height
above ground level.

- The string "apogee," which triggers the parachute at apogee, i.e.,
- The string "apogee" which triggers the parachute at apogee, i.e.,
when the rocket reaches its highest point and starts descending.

Note: The function will be called according to the sampling rate
Expand Down