ENH: Acceleration data to trigger parachutes
Is your feature request related to a problem? Please describe. Currently, custom functions used to trigger parachutes (events) only have access to Pressure and the State Vector (position, velocity, attitude, angular rates).
However, real-world flight computers (avionics) heavily rely on Accelerometers (IMU) to detect flight phases (e.g., Liftoff, Motor Burnout, Apogee).
- Example: A user wants to deploy a drogue parachute only if the rocket detects it is under free-fall (approx 0g total acceleration) or has detected a specific deceleration curve.
Because RocketPy does not expose acceleration to the trigger, users cannot simulate these realistic avionics algorithms.
Describe the solution you'd like
I would like to update the Flight class event handling logic to pass acceleration data to the parachute trigger callbacks.
The trigger signature should ideally support:
def my_trigger(p, y, u_dot):
# p = pressure
# y = state vector [x, y, z, vx, vy, vz...]
# u_dot = derivative [vx, vy, vz, ax, ay, az...]
vertical_acceleration = u_dot[5]
return vertical_acceleration < -9.0 # Deploy if falling
Implementation Details
- Target File:
rocketpy/flight/flight.py - Mechanism: Inside the event wrapper methods (which interface with
scipy.integrate), we need to explicitly callself.u_dot(t, y)to obtain the current derivatives. - Performance Note: Calling
u_dotinside the event checker effectively doubles the physics load for event detection. This is acceptable for the gained accuracy, but we should document it. - Noise: Ideally, we should allow a way to inject "sensor noise" into this acceleration before passing it to the trigger, simulating a real MEMS accelerometer.
Acceptance Criteria
- [ ] Update
Flightclass to calculateu_dotinside the event checking loop. - [ ] Pass the acceleration components (or the full
u_dot) to the user-defined trigger function. - [ ] Add a tutorial example showing how to trigger a parachute based on "Motor Burnout" (sudden drop in acceleration).
Additional Context
- Currently, the state vector
ycontains[x, y, z, vx, vy, vz, ...]. - The acceleration
[ax, ay, az]is only available after computing the derivativeu_dot.
@FranzYuri can you please take a look at this since it's releated to parachute functions? I think you'll like it!!
Might not be too complicated, but let's use some minutes during the week to discuss if needed
@MateusStano, these may help you:
- https://github.com/scipy/scipy/commit/7e2ddf86c5f8df9642f330e4a1d09f838e953306
- https://computing.llnl.gov/sites/default/files/ODEPACK_pub2_u113855.pdf (page 93)