Enh/acceleration data to trigger parachutes #911
+575
−43
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.
Pull Request: Add Acceleration-Based Parachute Triggers with IMU Sensor Simulation
Pull request type
Checklist
black rocketpy/ tests/) has passed locallypytest tests -m slow --runslow) have passed locallyCurrent behavior
Currently, RocketPy forces users to trigger parachute deployment based on state variables (altitude
z, vertical velocityvz) or pressure. This simulates "God Mode" avionics rather than realistic flight computer behavior.Real-world rocket avionics (flight computers) trigger events based on accelerometer data (IMU):
Users had no way to access acceleration (
u_dot) inside trigger functions, making it impossible to simulate realistic avionics algorithms.Related Issue: RocketPy#156
New behavior
This PR introduces acceleration-based parachute triggers with the following features:
1. Acceleration Data Access in Triggers
Parachute trigger functions now optionally receive acceleration data (
u_dot):2. Built-in Acceleration-Based Triggers
New triggers on
rocketpy/rocket/parachute.pyprovides realistic avionics functions:detect_apogee_acceleration: Detects apogee when vertical velocity ≈ 0 AND acceleration becomes negativedetect_motor_burnout: Detects motor shutdown by sudden acceleration dropdetect_freefall: Detects free-fall condition (total acceleration < 1.5 m/s²)detect_liftoff: Detects liftoff by high total acceleration (> 15 m/s²)Usage:
3. Optional IMU Sensor Noise Simulation
New parameter
acceleration_noise_functioninFlight.__init__allows simulating realistic accelerometer noise:4. Performance Optimization
The Flight class automatically detects trigger signatures:
u_dotparameter → computes acceleration at event checks5. Full Backward Compatibility
trigger=300) continue workingTechnical Details
Implementation Changes
rocketpy/rocket/parachute.py__evaluate_trigger_function()now wraps triggers with signature detection_expects_udotattribute for Flight optimization"apogee","burnout","freefall","liftoff"flight.py
_evaluate_parachute_trigger()now computesu_dotwhen neededacceleration_noise_functionTests Added
test_parachute_triggers.py
test_trigger_receives_u_dot_and_noise: Validates acceleration computation and noise injectiontest_trigger_with_u_dot_only: Tests acceleration-only triggerstest_legacy_trigger_does_not_compute_u_dot: Ensures performance optimization worksTrade-offs and Considerations
Performance Impact
u_dotat event points doubles physics evaluations locallyCoordinate System
u_dot[3:6]follow state vector convention:[ax, ay, az]Breaking change
Additional information
Examples of Usage
Realistic apogee detection:
Simulating sensor noise:
Custom acceleration trigger:
Testing Performed
Documentation Notes