Skip to content

ENH: Acceleration data to trigger parachutes #156

Description

@giovaniceotto

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 call self.u_dot(t, y) to obtain the current derivatives.
  • Performance Note: Calling u_dot inside 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 Flight class to calculate u_dot inside 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 y contains [x, y, z, vx, vy, vz, ...].
  • The acceleration [ax, ay, az] is only available after computing the derivative u_dot.

Activity

  1. added
    EnhancementNew feature or request, including adjustments in current codes
    on Mar 21, 2022
  2. Gui-FernandesBR commented on Mar 21, 2022

    @Gui-FernandesBR
    Member

    @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

  3. giovaniceotto commented on Aug 17, 2022

    @giovaniceotto
    MemberAuthor
  4. 7 remaining items

  5. ViniciusCMB commented on Nov 28, 2025

    @ViniciusCMB
    Contributor

    Hi @giovaniceotto ! I'm interested in working on this issue for the recruitment process.

    Since I work with embedded systems in my rocketry team, adding acceleration-based triggers feels very relevant to me (especially because we actually faced issues with our parachute triggering during the last LASC).

    I am currently analyzing flight.py to understand the best way to access the acceleration data (from u_dot) and pass it to the parachute triggers.

    Let me know if I can proceed with this!

  6. Gui-FernandesBR commented on Nov 28, 2025

    @Gui-FernandesBR
    Member

    Hi @giovaniceotto ! I'm interested in working on this issue for the recruitment process.

    Since I work with embedded systems in my rocketry team, adding acceleration-based triggers feels very relevant to me (especially because we actually faced issues with our parachute triggering during the last LASC).

    I am currently analyzing flight.py to understand the best way to access the acceleration data (from u_dot) and pass it to the parachute triggers.

    Let me know if I can proceed with this!

    Hello @ViniciusCMB I will try to guide you with these.

    Since this issue was raised, a lot has already changed in this lib. It's possible that we no longer need to solve this one. I need to read it more carefully through the weekend and then get back to you asap.

  7. ViniciusCMB commented on Nov 29, 2025

    @ViniciusCMB
    Contributor

    Thanks for the heads-up!

    I understand, a lot changes in 3 years. I will wait for your feedback after the weekend then.

    In the meantime, I might take a look at other "good first issues" just to familiarize myself with the codebase and maybe tackle something else if this one turns out to be deprecated.

    Looking forward to hearing from you.

  8. Gui-FernandesBR commented on Nov 29, 2025

    @Gui-FernandesBR
    Member

    @ViniciusCMB way to go!!

    Easy PRs are: #725, #656, and #242

    I will try to update every issue on our repo in the next few weeks.

  9. ViniciusCMB commented on Nov 29, 2025

    @ViniciusCMB
    Contributor

    Thank you for the guidance!

    I appreciate the heads-up regarding the complexity of #156. Following your recommendation, I'll tackle issue #242

  10. Gui-FernandesBR commented on Nov 29, 2025

    @Gui-FernandesBR
    Member

    @ViniciusCMB , I reviewed the architecture. This is not deprecated, it is actually a very important feature for simulating realistic avionics. The challenge is that you need to calculate u_dot(t, y) inside the event loop to get the acceleration. I have updated the issue description with the technical details.

    In case you want to read a more detailed description, here it goes:

    This is a critical feature for advanced users. It is definitely still necessary.
    Here is the breakdown of why, how to solve it, and the updated issue description.

    1. Is this still necessary? YES.

    Why?
    Real-world rocket avionics (flight computers) rarely use "altitude" or "vertical velocity" directly to detect events because barometers are noisy and GPS is slow.
    Most avionics trigger events based on Accelerometer data (IMU):

    • Liftoff detection: High positive acceleration.
    • Burnout detection: Sudden drop in acceleration.
    • Apogee detection: 0 velocity (integrated from acceleration).

    Currently, RocketPy forces users to trigger parachutes based on state variables (Position z, Velocity vz) or Pressure. This is "God Mode" simulation. To simulate realistic avionics logic, the user needs access to acceleration (and ideally, noisy acceleration) inside the trigger function.

    2. How can we do this?

    The Problem:
    RocketPy uses scipy.integrate.solve_ivp.

    • The solver passes (t, y) (Time and State Vector) to the Event/Trigger function.
    • Acceleration is NOT in the State Vector y (which is [x, v, ...]).
    • Acceleration is the derivative y' (or u_dot).

    The Solution:
    To get acceleration inside the trigger, we must calculate the derivative inside the event function.

    1. Current Flow:
      Trigger(pressure, state_vector)
    2. New Flow:
      Inside the internal wrapper that RocketPy uses for events:
      def parachute_trigger_wrapper(t, y):
          # 1. Calculate the physics derivative at this exact moment
          # This gives us [vx, vy, vz, ax, ay, az, ...]
          u_dot = flight.u_dot(t, y) 
          
          # 2. Extract acceleration
          acc_z = u_dot[5] # (assuming index 5 is az)
          
          # 3. (Optional) Add Sensor Noise here if strictly required
          
          # 4. Call the user's trigger function with extra data
          return user_trigger_function(pressure, y, acceleration=acc_z)

    Trade-off: This adds computational cost (physics is calculated twice: once for the step, once for the event check). However, this is the only accurate way to do it.

  11. ViniciusCMB commented on Dec 7, 2025

    @ViniciusCMB
    Contributor

    Hi @Gui-FernandesBR!

    I have just submitted PR #911 addressing this issue.

    The PR implements the logic to expose acceleration (u_dot) to parachute triggers, enabling realistic avionics simulation. It includes:

    New Built-in Triggers: apogee_acc, detect_motor_burnout, detect_liftoff, and detect_freefall.

    IMU Simulation: Added acceleration_noise_function to the Flight class to simulate sensor noise.

    Optimization: The simulation only calculates u_dot inside the event loop if the trigger signature explicitly requests it, preventing performance drops for legacy triggers.

    Backward Compatibility: Fully supports existing 3-parameter triggers.

    Looking forward to your review!

  12. added 2 commits that reference this issue on Jun 27, 2026
    b320dad
    5bdc4a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ControllersControlling rocket flight methodsEnhancementNew feature or request, including adjustments in current codesParachuteRelated to parachutes methods and usage

    Projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions