Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: Maximum acceleration values broken when airbrake is used #840

@nalquas

Description

@nalquas

Describe the bug

When running any Flight with a Rocket containing an Airbrake, the maximum acceleration and G values are broken as follows:

  • "Maximum Acceleration During Motor Burn" is absurdly high (e.g. ~4000m/s²)
  • "Maximum Gs During Motor Burn" is absurdly high (e.g. ~400g)
  • "Maximum Acceleration After Motor Burn" is zero
  • "Maximum Gs After Motor Burn" is zero

To Reproduce

Given an existing RocketPy simulation (such as given in https://docs.rocketpy.org/en/latest/user/first_simulation.html), add an airbrake to the rocket with an "empty" airbrake controller function:

# The following code assumes env is the Environment used by the simulation

def airbrake_controller_function(
    time: float,
    sampling_rate: float,
    state_raw: list,
    state_history_raw: list,
    observed_variables: list,
    air_brakes: AirBrakes,
):
    air_brakes.deployment_level = 0.0
    wind_x: float = env.wind_velocity_x(state_raw[2])
    wind_y: float = env.wind_velocity_y(state_raw[2])
    free_stream_speed = (
        (wind_x - state_raw[3]) ** 2 + (wind_y - state_raw[4] ** 2 + (state_raw[5]) ** 2
    ) ** 0.5
    mach_number = free_stream_speed / env.speed_of_sound(state_raw[2])
    return (
        time,
        air_brakes.deployment_level,
        air_brakes.drag_coefficient(air_brakes.deployment_level, mach_number),
    )
    
rocket.add_air_brakes(
    drag_coefficient_curve="airbrake_drag_curve.csv", # Note that you need to provide that file in the same folder
    controller_function=airbrake_controller_function,
    sampling_rate=10,
    clamp=True,
)

Here is an example drag curve file in .csv format (store it as "airbrake_drag_curve.csv"):

0.0, 0.1, 0.0
0.0, 0.95, 0.0
1.0, 0.1728, 0.37
1.0, 0.5, 0.37
1.0, 0.6, 0.39
1.0, 0.7, 0.53
1.0, 0.8, 0.7
1.0, 0.9, 1.08
1.0, 0.95, 1.1

After running the simulation, call flight.prints.all() and observe the output.

Expected behavior

(tested with a sounding rocket in development by BEARS e.V.) / without Airbrake added

Maximum Values

Maximum Speed: 311.570 m/s at 1.82 s
Maximum Mach Number: 0.920 Mach at 1.82 s
Maximum Reynolds Number: 2.556e+06 at 1.79 s
Maximum Dynamic Pressure: 5.721e+04 Pa at 1.79 s
Maximum Acceleration During Motor Burn: 191.146 m/s² at 0.73 s
Maximum Gs During Motor Burn: 19.491 g at 0.73 s
Maximum Acceleration After Motor Burn: 11.323 m/s² at 14.41 s
Maximum Gs After Motor Burn: 1.155 Gs at 14.41 s
Maximum Stability Margin: 3.157 c at 1.85 s
Maximum Upper Rail Button Normal Force: 0.000 N
Maximum Upper Rail Button Shear Force: 0.000 N
Maximum Lower Rail Button Normal Force: 0.000 N
Maximum Lower Rail Button Shear Force: 0.000 N

Observed behavior

(tested with a sounding rocket in development by BEARS e.V.) / with Airbrake added but zero deployment

Maximum Values

Maximum Speed: 311.663 m/s at 1.81 s
Maximum Mach Number: 0.920 Mach at 1.81 s
Maximum Reynolds Number: 2.556e+06 at 1.80 s
Maximum Dynamic Pressure: 5.723e+04 Pa at 1.80 s
Maximum Acceleration During Motor Burn: 3893.683 m/s² at 1.83 s
Maximum Gs During Motor Burn: 397.045 g at 1.83 s
Maximum Acceleration After Motor Burn: 0.000 m/s² at 0.00 s
Maximum Gs After Motor Burn: 0.000 Gs at 0.00 s
Maximum Stability Margin: 3.157 c at 1.83 s
Maximum Upper Rail Button Normal Force: 0.000 N
Maximum Upper Rail Button Shear Force: 0.000 N
Maximum Lower Rail Button Normal Force: 0.000 N
Maximum Lower Rail Button Shear Force: 0.000 N

Notice how the output maximum acceleration is absurdly high during motor burn and is zero after motor burn (despite parachutes deploying at some point etc.). The flight otherwise performs the same (apogee and everything else is identical).

Additional context

Tested in RocketPy 1.10.0.

The issue does not appear when no Airbrake is configured.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingControllersControlling rocket flight methodsHelp wantedExtra attention is needed

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions