MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:RocketPy(High-Power Rocketry 6-DOF Trajectory Simulation)

项目背景与痛点

在高功率模型火箭的领域中,轨道模拟一直存在着显著的痛点。火箭设计师需要预测火箭飞行过程中的轨迹,这涉及到多项动态因素。传统的模拟方法不仅复杂,还需要大量的计算资源和时间。RocketPy 项目正好解决了这一痛点,通过高精度的六自由度(6-DOF)轨迹模拟,提供了一个强大而高效的工具,帮助火箭设计师快速、准确地预测和理解火箭的飞行特性。

技术核心揭秘

RocketPy 架构精简且优雅,通过利用 Python 和科学计算库(如 numpy、scipy)实现了高效的设计思想。6-DOF 模拟涉及高度复杂的动力学模型,包括火箭的姿态控制、空气动力学力和力矩的计算以及火箭运动方程的数值解法。项目采用基于矢量的模型,简化了多自由度系统的状态表示,大幅提升了数值处理的效率。

graph TD A[用户输入参数] --> B[初始化火箭] B --> C{"空气动力学?"} C -->|"是"| D[计算气动力和力矩] C -->|"否"| E[静力学分析] D --> F[姿态控制] F --> G[数值积分求解] E --> G G --> H[保存结果]

上述流程描述了 RocketPy 核心的轨迹模拟过程。从初始化火箭状态开始,根据是否需要考虑空气动力学效应,选择不同的计算路径,并最终通过数值积分求解火箭轨迹。

功能亮点与差异

比起其他同类工具,RocketPy 的独特之处在于其基于 Python 的高性能实现以及灵活的配置选项。它不仅可以模拟火箭的刚体力学,还考虑了气动效应,包括真实的升力和阻力模型。此外,RocketPy 支持多种不同的火箭组件,开发者可以根据实际需要自定义设计。这样的灵活性和性能优化,使得 RocketPy 成为了高功率模型火箭设计者的理想选择。

应用场景与落地建议

将 RocketPy 应用于生产环境时,需要注意充足的计算资源和合理的性能优化。比如,对于复杂的气动模拟,代码可能会变得非常耗时。此外,RocketPy 提供的配置和插件系统,可以帮助用户针对具体的应用场景作出调整。

RocketPy 适用于高功率模型火箭的设计与测试场景。它不仅能够帮助快速构建复杂的飞行器模型,还能在设计阶段前就能够有效的预测飞行器行为,对于提升火箭的成功发射率具有重要的作用。开发团队在使用 RocketPy 时,需注意资源管理与算法优化,以发挥其最佳性能。

综合评价

RocketPy 在高精度高功率模型火箭轨迹模拟领域,表现了革命性的创新力。它的设计思想注入了科学研究精神,充分利用现代计算工具来模拟复杂的动力学问题。然而,RocketPy 对计算资源的需求较高,不太适合资源受限的环境。优势在于它高度的灵活性和强大的性能表现,可以灵活应对各种复杂场景。对于需要高精度飞行动力学分析的开发者来说,RocketPy 展现了不容忽视的价值。

关于

GitHub 原始描述(英文)

Next generation High-Power Rocketry 6-DOF Trajectory Simulation

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Dockerfile
Makefile
Python

Release

README

RocketPy Logo

Open In Colab Documentation Status PyPI Conda Version codecov Code style: black Contributors Sponsor RocketPy Chat on Discord Instagram LinkedIn DOI Ask DeepWiki

RocketPy

RocketPy is the next-generation trajectory simulation solution for High-Power Rocketry. The code is written as a Python library and allows for a complete 6 degrees of freedom simulation of a rocket’s flight trajectory, including high-fidelity variable mass effects as well as descent under parachutes. Weather conditions, such as wind profiles, can be imported from sophisticated datasets, allowing for realistic scenarios. Furthermore, the implementation facilitates complex simulations, such as multi-stage rockets, design and trajectory optimization and dispersion analysis.

Main features

  1. Nonlinear 6 Degrees of Freedom Simulations

    • Rigorous treatment of mass variation effects
    • Efficiently solved using LSODA with adjustable error tolerances
    • Highly optimized for fast performance
  2. Accurate Weather Modeling

    • Supports International Standard Atmosphere (1976)
    • Custom atmospheric profiles and Soundings (Wyoming)
    • Weather forecasts, reanalysis, and ensembles for realistic scenarios
  3. Aerodynamic Models

    • Optional Barrowman equations for lift coefficients
    • Easy import of drag coefficients from other sources (e.g., CFD simulations)
  4. Parachutes with External Trigger Functions

    • Test the exact code that will fly
    • Sensor data augmentation with noise for comprehensive parachute simulations
  5. Solid, Hybrid, and Liquid Motors Models

    • Burn rate and mass variation properties from the thrust curve
    • Define custom rocket tanks based on flux data
    • Support for CSV and ENG file formats
  6. Monte Carlo Simulations

    • Conduct dispersion analysis and global sensitivity analysis
  7. Flexible and Modular

    • Perform straightforward engineering analysis (e.g., apogee and lift-off speed as a function of mass)
    • Handle non-standard flights (e.g., parachute drop test from a helicopter)
    • Support multi-stage rockets and custom continuous/discrete control laws
    • Easily create new classes, such as other types of motors
  8. Integration with MATLAB®

    • Effortlessly run RocketPy from MATLAB®
    • Convert RocketPy results to MATLAB® variables for further processing

These powerful features make RocketPy an indispensable tool for high-power rocket trajectory simulation, catering to enthusiasts, researchers, and engineers in the field of rocketry.

Validation

RocketPy’s features have been validated in our latest research article published in the Journal of Aerospace Engineering.

The table below shows a comparison between experimental data and the output from RocketPy. Flight data and rocket parameters used in this comparison were kindly provided by EPFL Rocket Team and Notre Dame Rocket Team.

Mission Result Parameter RocketPy Measured Relative Error
Bella Lui Kaltbrumn Apogee altitude (m) 461.03 458.97 0.45 %
Bella Lui Kaltbrumn Apogee time (s) 10.61 10.56 0.47 %
Bella Lui Kaltbrumn Maximum velocity (m/s) 86.18 90.00 -4.24 %
NDRT launch vehicle Apogee altitude (m) 1,310.44 1,320.37 -0.75 %
NDRT launch vehicle Apogee time (s) 16.77 17.10 -1.90 %
NDRT launch vehicle Maximum velocity (m/s) 172.86 168.95 2.31 %

Over years of development and testing, RocketPy has been validated across an expanding range of flight scenarios. For more information on these validated flights, visit our Flight Examples page in the documentation.

Documentation

Check out documentation details using the links below:


Join Our Community!

RocketPy is growing fast! Many university groups and rocket hobbyists have already started using it. The number of stars and forks for this repository is skyrocketing. And this is all thanks to a great community of users, engineers, developers, marketing specialists, and everyone interested in helping.

If you want to be a part of this and make RocketPy your own, join our Discord server today!


Previewing

You can preview RocketPy’s main functionalities by browsing through a sample notebook in Google Colab. No installation is required!

When you are ready to run RocketPy locally, you can read the Getting Started section!


Getting Started

Quick Installation

To install RocketPy’s latest stable version from PyPI, just open up your terminal and run:

pip install rocketpy

For other installation options, visit our Installation Docs. To learn more about RocketPy’s requirements, visit our Requirements Docs.

Running Your First Simulation

In order to run your first rocket trajectory simulation using RocketPy, you can start a Jupyter Notebook and navigate to the docs/notebooks folder. Open getting_started.ipynb and you are ready to go. We recommend that you read the First Simulation page to get a complete description.

Otherwise, you may want to create your own script or your own notebook using RocketPy. To do this, let’s see how to use RocketPy’s four main classes:

  • Environment - Keeps data related to weather.
  • Motor - Subdivided into SolidMotor, HybridMotor and LiquidMotor. Keeps data related to rocket motors.
  • Rocket - Keeps data related to a rocket.
  • Flight - Runs the simulation and keeps the results.

The following image shows how the four main classes interact with each other:

Diagram

A typical workflow starts with importing these classes from RocketPy:

from rocketpy import Environment, Rocket, SolidMotor, Flight

An optional step is to import datetime, which is used to define the date of the simulation:

import datetime

Then create an Environment object. To learn more about it, you can use:

help(Environment)

A sample code is:

env = Environment(
    latitude=32.990254,
    longitude=-106.974998,
    elevation=1400,
)

tomorrow = datetime.date.today() + datetime.timedelta(days=1)

env.set_date(
  (tomorrow.year, tomorrow.month, tomorrow.day, 12), timezone="America/Denver"
) # Tomorrow's date in year, month, day, hour UTC format

env.set_atmospheric_model(type='Forecast', file='GFS')

This can be followed up by starting a Solid Motor object. To get help on it, just use:

help(SolidMotor)

A sample Motor object can be created by the following code:

Pro75M1670 = SolidMotor(
    thrust_source="data/motors/cesaroni/Cesaroni_M1670.eng",
    dry_mass=1.815,
    dry_inertia=(0.125, 0.125, 0.002),
    center_of_dry_mass_position=0.317,
    grains_center_of_mass_position=0.397,
    burn_time=3.9,
    grain_number=5,
    grain_separation=0.005,
    grain_density=1815,
    grain_outer_radius=0.033,
    grain_initial_inner_radius=0.015,
    grain_initial_height=0.12,
    nozzle_radius=0.033,
    throat_radius=0.011,
    interpolation_method="linear",
    nozzle_position=0,
    coordinate_system_orientation="nozzle_to_combustion_chamber",
)

With a Solid Motor defined, you are ready to create your Rocket object. As you may have guessed, to get help on it, use:

help(Rocket)

A sample code to create a Rocket is:

calisto = Rocket(
    radius=0.0635,
    mass=14.426,  # without motor
    inertia=(6.321, 6.321, 0.034),
    power_off_drag="data/rockets/calisto/powerOffDragCurve.csv",
    power_on_drag="data/rockets/calisto/powerOnDragCurve.csv",
    center_of_mass_without_motor=0,
    coordinate_system_orientation="tail_to_nose",
)

buttons = calisto.set_rail_buttons(
    upper_button_position=0.0818,
    lower_button_position=-0.6182,
    angular_position=45,
)

calisto.add_motor(Pro75M1670, position=-1.255)

nose = calisto.add_nose(
    length=0.55829, kind="vonKarman", position=1.278
)

fins = calisto.add_trapezoidal_fins(
    n=4,
    root_chord=0.120,
    tip_chord=0.040,
    span=0.100,
    sweep_length=None,
    cant_angle=0,
    position=-1.04956,
)

tail = calisto.add_tail(
    top_radius=0.0635, bottom_radius=0.0435, length=0.060, position=-1.194656
)

You may want to add parachutes to your rocket as well:

main = calisto.add_parachute(
    name="main",
    cd_s=10.0,
    trigger=800,  # ejection altitude in meters
    sampling_rate=105,
    lag=1.5,
    noise=(0, 8.3, 0.5),
    radius=1.5,
    height=1.5,
    porosity=0.0432,
)

drogue = calisto.add_parachute(
    name="drogue",
    cd_s=1.0,
    trigger="apogee",  # ejection at apogee
    sampling_rate=105,
    lag=1.5,
    noise=(0, 8.3, 0.5),
    radius=1.5,
    height=1.5,
    porosity=0.0432,
)

Finally, you can create a Flight object to simulate your trajectory. To get help on the Flight class, use:

help(Flight)

To actually create a Flight object, use:

test_flight = Flight(
  rocket=calisto, environment=env, rail_length=5.2, inclination=85, heading=0
)

Once the Flight object is created, your simulation is done! Use the following code to get a summary of the results:

test_flight.info()

To see all available results, use:

test_flight.all_info()

Here is just a quick taste of what RocketPy is able to calculate. There are hundreds of plots and data points computed by RocketPy to enhance your analyses.

6-DOF Trajectory Plot

If you want to see the trajectory on Google Earth, RocketPy can easily export a KML file for you:

from rocketpy.simulation import FlightDataExporter

FlightDataExporter(test_flight).export_kml(file_name="test_flight.kml")
6-DOF Trajectory Plot

Authors and Contributors

This package was originally created by Giovani Ceotto as part of his work at Projeto Jupiter. Rodrigo Schmitt was one of the first contributors. Later, Guilherme Fernandes and Lucas Azevedo joined the team to work on the expansion and sustainability of this project.

Since then, the RocketPy Team has been growing fast and our contributors are what makes us special!

Institutional Contributors

RocketPy extends its gratitude to the following institutions for their support and contributions:

Individual Contributors

RocketPy is also indebted to a growing list of individual contributors who actively participate in its development. These include:

GitHub Contributors Image

See a detailed list of contributors who are actively working on RocketPy.

Supporting RocketPy and Contributing

The easiest way to help RocketPy is to demonstrate your support by starring our repository!

starcharts stargazers over time

You can also become a sponsor and help us financially to keep the project going.

If you are actively using RocketPy in one of your projects, reaching out to our core team via Discord and providing feedback can help improve RocketPy a lot!

And if you are interested in going one step further, please read the development documentation to learn more about how you can contribute to the development of this next-gen trajectory simulation solution for rocketry.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Release Notes

Want to know which bugs have been fixed and the new features of each version? Check out the release notes.

评论

暂无评论