-
-
Notifications
You must be signed in to change notification settings - Fork 252
ENH: acceleration data to trigger parachutes #911
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
Open
ViniciusCMB
wants to merge
22
commits into
RocketPy-Team:develop
Choose a base branch
from
ViniciusCMB:enh/acceleration-data-to-trigger-parachutes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2575950
ENH: Pass Acceleration Data to Parachute Trigger Functions (RocketPy-…
ViniciusCMB 7ec7ac9
ENH: Add acceleration-based parachute triggers with IMU sensor simula…
ViniciusCMB 18aab57
ENH: Enable sensors+acceleration triggers in parachutes
ViniciusCMB 0932277
Merge branch 'develop' into enh/acceleration-data-to-trigger-parachutes
ViniciusCMB 916b0fc
STY: Apply ruff format to flight.py
ViniciusCMB 8e88fa8
STY: Fix pylint for parachute triggers
ViniciusCMB e84df40
Merge branch 'develop' into enh/acceleration-data-to-trigger-parachutes
ViniciusCMB a7f5c3a
TST: Add comprehensive unit tests for acceleration-based parachute tr…
ViniciusCMB ad7e6d0
DOC: Add comprehensive documentation for acceleration-based parachute…
ViniciusCMB 8f65022
STY: Apply ruff format to test_parachute_trigger_acceleration.py
ViniciusCMB d45b3a5
STY: Fix pylint warnings in test_parachute_triggers.py
ViniciusCMB 6d79d62
FIX: Add missing u_dot parameter to direct triggerfunc calls
ViniciusCMB 5619b3a
STY: Apply ruff format to flight.py
ViniciusCMB c66cffc
MNT: align acceleration trigger API with review feedback
ViniciusCMB 56c1e51
Merge branch 'develop' into enh/acceleration-data-to-trigger-parachutes
ViniciusCMB 02d344d
STY: apply ruff format fixes
ViniciusCMB 00e94b9
STY: apply ruff format fixes to flight.py
ViniciusCMB a0cb73d
STY: Apply ruff check after pip update
ViniciusCMB aba648b
Merge branch 'develop' into enh/acceleration-data-to-trigger-parachutes
ViniciusCMB 6beab3c
Merge branch 'develop' into enh/acceleration-data-to-trigger-parachutes
MateusStano aa89d50
Merge branch 'develop' into enh/acceleration-data-to-trigger-parachutes
MateusStano 6a9795d
Merge branch 'develop' into enh/acceleration-data-to-trigger-parachutes
MateusStano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
ENH: Pass Acceleration Data to Parachute Trigger Functions (RocketPy-…
…Team#XXX) * ENH: add u_dot parameter computation inside parachute trigger evaluation. * ENH: add acceleration_noise_function parameter to Flight class for realistic IMU simulation. * ENH: implement automatic detection of trigger signature to compute derivatives only when needed. * TST: add unit tests for parachute trigger with acceleration data and noise injection. * TST: add test runner for trigger acceleration validation without full test suite dependencies.
- Loading branch information
commit 25759506f8006c2d699f6df42ad58edf8fe33fbc
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import numpy as np | ||
| import traceback | ||
|
|
||
| from rocketpy.simulation.flight import Flight | ||
| from rocketpy.rocket.parachute import Parachute | ||
|
|
||
|
|
||
| def _test_trigger_receives_u_dot_and_noise(): | ||
| def derivative_func(t, y): | ||
| return np.array([0, 0, 0, 1.0, 2.0, 3.0, 0, 0, 0, 0, 0, 0, 0]) | ||
|
|
||
| recorded = {} | ||
|
|
||
| def user_trigger(p, h, y, u_dot): | ||
| recorded["u_dot"] = np.array(u_dot) | ||
| return True | ||
|
|
||
| parachute = Parachute( | ||
| name="test", | ||
| cd_s=1.0, | ||
| trigger=user_trigger, | ||
| sampling_rate=100, | ||
| ) | ||
|
|
||
| dummy = type("D", (), {})() | ||
| dummy.acceleration_noise_function = lambda: np.array([0.1, -0.2, 0.3]) | ||
|
|
||
| res = Flight._evaluate_parachute_trigger( | ||
| dummy, | ||
| parachute, | ||
| pressure=0.0, | ||
| height=10.0, | ||
| y=np.zeros(13), | ||
| sensors=[], | ||
| derivative_func=derivative_func, | ||
| t=0.0, | ||
| ) | ||
|
|
||
| assert res is True | ||
| assert "u_dot" in recorded | ||
| assert np.allclose(recorded["u_dot"][3:6], np.array([1.1, 1.8, 3.3])) | ||
|
|
||
|
|
||
| def _test_trigger_with_sensors_and_u_dot(): | ||
| def derivative_func(t, y): | ||
| return np.array([0, 0, 0, -1.0, -2.0, -3.0, 0, 0, 0, 0, 0, 0, 0]) | ||
|
|
||
| recorded = {} | ||
|
|
||
| def user_trigger(p, h, y, sensors, u_dot): | ||
| recorded["sensors"] = sensors | ||
| recorded["u_dot"] = np.array(u_dot) | ||
| return False | ||
|
|
||
| parachute = Parachute( | ||
| name="test2", | ||
| cd_s=1.0, | ||
| trigger=user_trigger, | ||
| sampling_rate=100, | ||
| ) | ||
|
|
||
| dummy = type("D", (), {})() | ||
| dummy.acceleration_noise_function = lambda: np.array([0.0, 0.0, 0.0]) | ||
|
|
||
| res = Flight._evaluate_parachute_trigger( | ||
| dummy, | ||
| parachute, | ||
| pressure=0.0, | ||
| height=5.0, | ||
| y=np.zeros(13), | ||
| sensors=["s1"], | ||
| derivative_func=derivative_func, | ||
| t=1.234, | ||
| ) | ||
|
|
||
| assert res is False | ||
| assert recorded["sensors"] == ["s1"] | ||
| assert np.allclose(recorded["u_dot"][3:6], np.array([-1.0, -2.0, -3.0])) | ||
|
|
||
|
|
||
| def _test_legacy_trigger_does_not_compute_u_dot(): | ||
| def derivative_func(t, y): | ||
| raise RuntimeError("derivative should not be called for legacy triggers") | ||
|
|
||
| called = {} | ||
|
|
||
| def legacy_trigger(p, h, y): | ||
| called["ok"] = True | ||
| return True | ||
|
|
||
| parachute = Parachute( | ||
| name="legacy", | ||
| cd_s=1.0, | ||
| trigger=legacy_trigger, | ||
| sampling_rate=100, | ||
| ) | ||
|
|
||
| dummy = type("D", (), {})() | ||
| dummy.acceleration_noise_function = lambda: np.zeros(3) | ||
|
|
||
| res = Flight._evaluate_parachute_trigger( | ||
| dummy, | ||
| parachute, | ||
| pressure=0.0, | ||
| height=0.0, | ||
| y=np.zeros(13), | ||
| sensors=[], | ||
| derivative_func=derivative_func, | ||
| t=0.0, | ||
| ) | ||
|
|
||
| assert res is True | ||
| assert called.get("ok", False) is True | ||
|
|
||
|
|
||
| def run_all(): | ||
| tests = [ | ||
| _test_trigger_receives_u_dot_and_noise, | ||
| _test_trigger_with_sensors_and_u_dot, | ||
| _test_legacy_trigger_does_not_compute_u_dot, | ||
| ] | ||
| failures = 0 | ||
| for t in tests: | ||
| name = t.__name__ | ||
| try: | ||
| t() | ||
| print(f"[PASS] {name}") | ||
| except Exception: | ||
| failures += 1 | ||
| print(f"[FAIL] {name}") | ||
| traceback.print_exc() | ||
| if failures: | ||
| print(f"{failures} test(s) failed") | ||
| raise SystemExit(1) | ||
| print("All tests passed") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| run_all() |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.