Open-source aerospace simulation toolkit + adaptive control catalogue
Pure-NumPy 6-DoF dynamics ยท Gymnasium-native envs ยท Classical / ADP / Deep RL agents
๐ Documentation โข ๐ Quickstart โข ๐ก Examples โข ๐ค Contributing
- ๐ Overview
- ๐ How it compares
- ๐งญ Application areas
- ๐ Quickstart
- ๐ค Supported algorithms
โ๏ธ Aircraft & spacecraft library- ๐ฎ Simulation environments
- ๐ Examples & guides
โ ๏ธ Known limitations- ๐ ๏ธ Development
- ๐ How to cite
- ๐ Documentation
- ๐ค Community & support
- โญ Star history
- ๐ License
TensorAeroSpace ships 12+ aircraft and spacecraft models (7 of them as full nonlinear 6-DoF airframes with peer-reviewed source data), 20+ control algorithms spanning classical PID/MPC through the full incremental-ADP family to modern deep RL, and 100+ runnable example notebooks covering trim, cruise, coordinated turns, in-flight damage and fault recovery โ all glued together by the standard Gymnasium API.
Why it stands out:
- ๐ฏ Real airframes, not toys. B-747 transcribed from NASA CR-2144, X-15 from NASA TM X-1669, Skywalker X8 from CEAS Aeronautical Journal 2025, B-737 from JSBSim + Roskam, RQ-7 Shadow from Beard & McLain. Trim-points reach machine precision.
- โก Pure NumPy core. No proprietary simulators, no MATLAB licence, no compiled binaries โ lightweight for control-synthesis sweeps with no startup overhead or XML parsing.
- ๐ง Unique adaptive-control catalogue. Standard RL stack (PPO, SAC, DDPG, DQN, A2C, A3C, GAIL) plus the full incremental-ADP family (IHDP, IM-GDHP, ET-DHP, iADP, AA-INDI, AIDI) โ rarely co-located in a single OSS package.
- ๐ฅ Damage subsystem built-in. Per-surface effectiveness loss, hard-overs, jam events, asymmetric-thrust engine-out, flap-jam configuration override โ all composable into
DamageProfileinstances. - ๐งช Locked down by regression coverage. Trim convergence, surface-deflection sign conventions, propellant burnout times โ all under unit tests.
- ๐ค Hugging Face Hub native. All PyTorch agents inherit
from_pretrained/publish_to_hubfromtensoraerospace.agent.baseโ pretrained checkpoints live at huggingface.co/TensorAeroSpace.
How TensorAeroSpace positions against the tools control engineers and RL researchers usually reach for:
| TensorAeroSpace | JSBSim | MATLAB / Simulink | Stable-Baselines3 | Gymnasium | |
|---|---|---|---|---|---|
| License | MIT (open-source) | LGPL (open-source) | Commercial | MIT (open-source) | MIT (open-source) |
| Core language | Python (pure NumPy) | C++ + XML | Proprietary + C | Python (PyTorch) | Python |
| 6-DoF airframes bundled | 7 peer-reviewed | 30+ | None bundled | None | None |
| Damage / FTC subsystem | โ built-in (mass, CG, inertia, surfaces, engines) | Partial (failure scripts) | Manual (Stateflow) | โ | โ |
| Classical control (PID/MPC) | โ with autotuning | โ | โ (Toolboxes) | โ | โ |
| Adaptive Dynamic Programming | โ IHDP, IM-GDHP, ET-DHP, iADP, AA-INDI, AIDI | โ | โ (manual) | โ | โ |
| Deep RL agents | โ PPO, SAC, DSAC, DDPG, DQN, A2C, A3C, GAIL | โ | โ (Reinforcement Learning Toolbox separate) | โ | โ (API only) |
| Gymnasium env API | โ native | Indirect | Custom | Consumer | โ definition |
| Hugging Face Hub integration | โ
from_pretrained / publish_to_hub |
โ | โ | โ | โ |
| Best fit | Adaptive flight control + FTC research | High-fidelity flight simulation | Industrial control prototyping | General RL benchmarks | RL environment standard |
Pick TensorAeroSpace when you need a single Python package that ships realistic airframes and the controllers to fly them โ including online adaptive critics rarely co-located in any other OSS toolkit.
- Automatic flight control โ stabilisation, trajectory tracking, attitude control for aircraft, UAVs, experimental vehicles.
- Rocket / spacecraft control โ launch vehicles, satellites in different orbital classes, ascent-trajectory optimisation.
- Hybrid control synthesis โ designing and tuning loops that combine classical and intelligent methods.
- Algorithm benchmarking โ automated hyperparameter search, head-to-head comparisons, metric visualisation.
- Simulator integration โ game engines (Unity ML-Agents), CAD/CAE (Simulink, SimInTech), bidirectional model exchange.
- Reliability and FTC research โ failure-mode studies, controller-reconfiguration assessment, dataset preparation.
Each area has working examples and documentation (see ๐ Examples & guides).
๐ก Interactive walkthrough: open
quickstart.ipynbto run a SAC benchmark on the B-747 end-to-end in Jupyter / VS Code.
| Component | Minimum | Recommended |
|---|---|---|
| OS | Linux x86_64, Windows 10, macOS 13 | Ubuntu 22.04 LTS / Windows 11 |
| CPU | 4 cores, AVX | 8+ cores, AVX2/FMA |
| RAM | 8 GB | 16โ32 GB for RL/Simulink |
| GPU | Optional | NVIDIA RTX with โฅ8 GB VRAM for SAC/DSAC/PPO, CUDA โฅ 12.0 |
| Python | 3.10โ3.13 | 3.11/3.12 |
| Optional | Git, Poetry or pip, Docker | MATLAB/Simulink R2022b+ (Simulink examples), Unity 2021.3.5f1/2023.2.20f1 |
git clone https://github.com/tensoraerospace/tensoraerospace.git
cd tensoraerospace
poetry install
eval $(poetry env activate) # activate the venv
poetry run pytest # quick smoke testpip install tensoraerospace # core (NumPy, gymnasium, PyTorch)
pip install 'tensoraerospace[ray]' # + Ray RLlib for distributed trainingAdditional development environments are exposed as Poetry groups (used when working from a clone):
| Group | Purpose | Install |
|---|---|---|
dev |
linters, mypy, pytest plugins, mkdocs | poetry install --with dev |
test |
extra fixtures and CI helpers | poetry install --with test |
jupyter |
nbconvert, kernels, notebook execution |
poetry install --with jupyter |
Combine groups:
poetry install --with dev,jupyterreproduces the CI environment used bynotebooks-smoke.yml.
Image launches JupyterLab by default (see Dockerfile).
docker pull ghcr.io/tensoraerospace/tensoraerospace:latest
docker run --rm -it -p 8888:8888 \
-v "$(pwd)/projects:/workspace/projects" \
ghcr.io/tensoraerospace/tensoraerospace:latest
# GPU (NVIDIA Container Toolkit)
docker run --rm -it --gpus all -p 8888:8888 \
-v "$(pwd)/projects:/workspace/projects" \
ghcr.io/tensoraerospace/tensoraerospace:latestimport gymnasium as gym
import numpy as np
from tensoraerospace.agent.pid import PID
from tensoraerospace.utils import generate_time_period
from tensoraerospace.signals.standard import unit_step
dt = 0.01
tp = generate_time_period(tn=10, dt=dt)
N = len(tp)
reference = unit_step(degree=5, tp=tp, time_step=100, output_rad=True).reshape(1, -1)
env = gym.make('LinearLongitudinalF16-v0',
number_time_steps=N, initial_state=[[0], [0]],
reference_signal=reference, use_reward=False)
pid = PID(env, kp=-14.290, ki=-8.240, kd=-1.299, dt=dt)
# Tip: skip the magic numbers and let the autotuner find them
# pid = PID(env, dt=dt); pid.tune_matlab_style()
obs, _ = env.reset()
for t in range(N - 1):
u = pid.select_action(reference[0, t], float(obs[0]))
obs, *_ = env.step(np.array([[float(u)]], dtype=np.float32))Compose damage events declaratively, run any controller โ agent sees a different plant the moment the event fires.
import numpy as np
from tensoraerospace.aerospacemodel.f16.nonlinear.damage import WING_STRIKE_LEFT_TIP
from tensoraerospace.envs.f16.nonlinear_angular import NonlinearAngularF16
env = NonlinearAngularF16(
initial_state=np.zeros(14),
number_time_steps=2000,
damage_profile=WING_STRIKE_LEFT_TIP, # left-tip loss at t=10s
split_stab=True, # split stabilator into left/right halves for asymmetric damage
)
obs, _ = env.reset()
for _ in range(2000):
obs, r, term, trunc, info = env.step(np.zeros(4))
if info.get("damage_events_triggered"):
print(info["damage_events_triggered"]) # โ ['left_tip_full_loss']What's modelled: section loss (mass / S / b / MAC / c.g. / inertia tensor / aero coefficients all recomputed via Huygens-Steiner), surface failure (jam / efficiency loss / lost), engine flameout (partial / full thrust scaling), structural events (payload drop, icing, ฮm / ฮc.g. / ฮJ).
๐ Aircraft damage modelling guide
| Algorithm | Description |
|---|---|
| PID | Proportional-Integral-Derivative with anti-windup and MATLAB-style autotuning. Strong baseline for state-space tasks; the autotuner extracts the env's (A,B,C,D) matrices and optimises gains via differential evolution against the step-response criterion. |
| MPC | Model-Predictive Control with three swappable plant-model variants โ MLP, NARX, Transformer โ over a QP / numerical receding-horizon optimisation. Use when the plant is known or can be learned from data. |
| Algorithm | Description |
|---|---|
| PPO | Proximal Policy Optimization. Stable and easy to tune; the standard "just works" starting point for continuous and discrete tasks. |
| A2C | Advantage Actor-Critic โ synchronous on-policy. Simpler than PPO, useful as a clean reference. |
| A2C-NARX | A2C with a NARX critic instead of MLP โ better captures temporal structure. |
| A3C | Asynchronous Advantage Actor-Critic โ multiple workers, shared global network. Great for CPU-parallel distributed training (Unity envs). |
| Algorithm | Description |
|---|---|
| SAC | Soft Actor-Critic โ off-policy, maximum-entropy. Data-efficient default for continuous control. |
| DSAC | Distributional SAC with quantile (IQN-style) twin critics + CAPS regularisation. Better tracking dynamics than vanilla SAC under sensor noise / multi-modal cost. |
| DDPG | Deep Deterministic Policy Gradient โ foundational; SAC outperforms it in most cases but DDPG remains useful for quiet low-frequency tasks. |
| DQN | Deep Q-Learning โ value-based for discrete action spaces; used here for Unity envs with discrete control. |
| Algorithm | Description |
|---|---|
| GAIL | Generative Adversarial Imitation Learning โ learn from expert demonstrations without explicit reward. Useful for cloning a pre-built PID/MPC trajectory before fine-tuning with an RL critic. |
| Algorithm | Description |
|---|---|
| HDP | Heuristic Dynamic Programming โ actor-critic with a pre-trained offline plant network providing the policy gradient via โf/โu. |
| ADHDP | Action-Dependent HDP โ value function depends on (state, action); no explicit model gradient required. |
| ADP | Base Adaptive Dynamic Programming โ value-iteration-style adaptive control without an explicit plant model. |
| IHDP | Incremental HDP โ actor-critic with online incremental linearisation of the plant. Adaptive without a pre-trained plant network. Strong baseline for online flight control. |
| NARX | Nonlinear AutoRegressive network โ used both as MPC plant model and as the critic in A2C-NARX. |
| Algorithm | Description |
|---|---|
| iADP | Incremental Approximate Dynamic Programming โ online RLS identification of a local incremental model (Fฬ, Gฬ) plus closed-form quadratic policy. Recovers from plant change in tens of milliseconds; no fault-detector required. |
| IM-GDHP | Incremental-Model GDHP โ online RLS plant identifier paired with a GDHP critic. Lightweight (no plant network), interpretable, with explicit (F, G) matrices. |
| ET-DHP | Event-Triggered Dual HDP โ Lipschitz event-trigger fires actor/critic updates only when the tracking error crosses a threshold. Bandwidth-aware, embedded-friendly. |
| AIDI | Adaptive Incremental Dynamic Inversion โ INDI with per-channel VFF-RLS adapting a multiplicative scaling ฮ of a known on-board control-effectiveness matrix. Fault-tolerant, model-agnostic. |
| AA-INDI | Adaptive Augmented INDI โ incremental nonlinear dynamic inversion with online RLS adaptation; designed for asymmetric actuator faults and flying-wing layouts with coupled control surfaces. |
| Airframe | Class | Aerodynamic source | Speciality |
|---|---|---|---|
| F-16 Fighting Falcon | Fighter | NASA / Stevens-Lewis | Cubic-spline aero, full damage subsystem (linear longitudinal ยท nonlinear longitudinal ยท 6-DoF angular) |
| Boeing 747-100 | Heavy transport | NASA CR-2144 (Heffley & Jewell) | Per-engine asymmetric thrust + flap jam (3 configurations: NOMINAL, POWER_APPROACH, LANDING) |
| Boeing 737-100/800 | Mid-size transport | JSBSim + Roskam Vol VI | Coordinated-turn benchmarks, JT8D / CFM56-7B engines |
| X-15 | Hypersonic research | NASA TM X-1669 + Thompson 2000 | Mach 0.4โ6.7 tabulated, XLR99 rocket, variable mass |
| Skywalker X8 | Small UAV (3.4 kg) | CEAS Aeronautical Journal 2025 | Peer-reviewed flight-test ID, flying-wing |
| AAI RQ-7 Shadow | Class-II UAV (170 kg) | Beard & McLain + NASA TM-2014-218686 | V-tail mixed control, 4-channel |
- F-4C Phantom II (
LongitudinalF4C) โ military fighter-bomber, Roskam-derived linear longitudinal channel + improved env wrapper. - Other linear plants โ
LongitudinalF16,LongitudinalB747,LongitudinalX15,LongitudinalUAV,LongitudinalCessna170,LongitudinalSuperSonicโ live alongside their nonlinear counterparts; see ๐ State-space matrices for classical synthesis.
- LAPAN LSU-05 โ Indonesian surveillance UAV
- Ultrastick-25e โ RC airplane model
- Generic UAV โ customisable state-space dynamics
- Quadrotor โ full nonlinear 6-DoF + per-rotor damage subsystem + X-config allocator
- ELV (Expendable Launch Vehicle) โ booster dynamics
- Generic missile โ customisable simulation
- GeoSat โ geostationary orbital mechanics
- ComSat โ communication-satellite dynamics and control
- ๐ฎ 3D visualisation in real time
- ๐ Realistic training โ agents learn in physics-rich scenes
- ๐ Sensor suite โ camera, LiDAR, physical sensors
- ๐ Custom scenarios โ author your own aerospace tasks
๐ Example environment: UnityAirplaneEnvironment
What ships today:
- ๐ฆ Reference Simulink models under
tensoraerospace/aerospacemodel/simulinkModel/โ F-4C and X-15 plant models in.slxformat for cross-validating Python implementations. - ๐๏ธ MATLAB-style PID autotuning โ the
PID.tune_matlab_style()API extracts(A, B, C, D)from any linear env and runs differential-evolution gain optimisation. Seeexample/pid_controllers/pid_matlab_tuning.ipynb. - ๐ Hands-on lessons โ Lesson 4: MATLAB scripting and Lesson 5: Simulink models walk through the import / validation workflow.
Status: Simulink interop is community-maintained โ model parsing helpers live in the lessons rather than being a turnkey importer. PRs welcome.
Linear plant models expose (A, B, C, D) for direct use with classical-control workflows:
- ๐งฎ
LongitudinalF16(f16/linear/longitudinal/) โ F-16 short-period + phugoid - ๐ชถ
LongitudinalF4C,LongitudinalB747,LongitudinalX15,LongitudinalUAV,LongitudinalCessna170,LongitudinalSuperSonicโ extra peer-validated linear plants undertensoraerospace/aerospacemodel/ - ๐๏ธ
PID.tune_matlab_style(env)โ autotunes gains against the env's state-space matrices via differential-evolution against a step-response criterion
The example/ directory ships 100+ runnable notebooks, organised by controller class. The folder was recently restructured for predictable navigation โ see example/README.md for the full map.
| Category | Folder | Highlights |
|---|---|---|
| ๐ Quickstart | quickstart.ipynb |
Minimal end-to-end pipeline |
| ๐ฎ Environments | environments/ |
All bundled aircraft envs (no agent) |
| ๐๏ธ Classical | pid_controllers/, mpc_controllers/ |
PID + MPC (MLP / NARX / Transformer) |
| ๐ง Classical ADP | dynamic_programming/ |
HDP, DHP, GDHP, AD-HDP, AD-GDHP, AD-DHP |
| ๐ Online ADP | reinforcement_learning/incremental_adp/ |
IHDP, IM-GDHP, ET-DHP, iADP, AA-INDI, AIDI |
| ๐ค Deep RL | reinforcement_learning/deep_rl/ |
A2C, A3C, PPO, DQN, SAC, DSAC, DDPG, GAIL |
| ๐ Comparison | comparison/ |
PID vs RL head-to-head benchmarks |
| ๐ฅ Failure demos | failure_demos/ |
F-16 dogfight with damage, IHDP failure recovery |
| ๐ Cookbook | cookbook/ |
Step-by-step recipes from "hello world" to FTC |
| ๐ง Optimization | optimization/ |
Optuna hyperparameter search |
| Example | Aircraft | Result |
|---|---|---|
| ET-DHP heading hold under engine flameout | B-747 | ฯ-error 0.28ยฐ vs open-loop โ85.5ยฐ |
| MIMO IHDP 90ยฐ coordinated turn | B-737 | Final ฯ-error 0.98ยฐ, max sideslip 0.11ยฐ |
| IHDP ฮธ-step tracking on nonlinear B-747 | B-747 | Late-half MAE 0.043ยฐ |
| PPO on X-15 (improved env) | X-15 | End-to-end deep-RL training on the variable-mass hypersonic plant |
# Run pretrained SAC on B-747
poetry run python example/reinforcement_learning/deep_rl/sac-b747-render.py --render --dt 0.1
# Run pretrained DDPG
poetry run python example/reinforcement_learning/deep_rl/ddpg-b747-render.py --repo TensorAeroSpace/ddpg-b747
# Train DSAC step-response
poetry run python example/reinforcement_learning/deep_rl/train_dsac_b747_step_response.py๐ Detailed walkthroughs:
- Example SAC F-16
- B-737 coordinated turn (IHDP)
- B-747 engine-out heading hold (ET-DHP)
- Optuna optimisation
- Unity guide
We are deliberate about scope โ calling out what's intentionally not modelled prevents users wasting time on edge cases the project does not yet cover.
- ๐ X-15 โ atmospheric envelope (M = 0.4โ6.7, h โค 250 kft) only. Exoatmospheric attitude control via peroxide RCS thrusters is not modelled.
โ๏ธ B-737 โ clean cruise envelope only. High-lift devices (flaps, slats, gear) have coefficient hooks but values are not yet applied.- ๐ฅ Damage subsystem coverage:
- F-16 nonlinear โ fully covered (sections, surfaces, engine, structural).
- B-747 nonlinear โ engine flameout + flap-jam events; no section-loss or icing.
- Other airframes (B-737, X-15, Skywalker X8, AAI Shadow, Quadrotor) โ engine / per-rotor failures only; no aero / mass / inertia recomputation.
- ๐ง Simulink interop โ community-maintained: reference
.slxplants ship for cross-validation, but there is no turnkey Simulink โ Python importer yet. - ๐ฐ๏ธ Spacecraft envs (ELV, GeoSat, ComSat, Generic missile) โ basic dynamics only; no atmospheric re-entry, no orbit perturbations beyond two-body.
- ๐ฎ Unity ML-Agents bridge โ lives in a separate repo and requires manual scene setup; no automated CI for that interaction layer.
PRs filling any of these gaps are warmly welcome โ see CONTRIBUTING.md.
git clone https://github.com/tensoraerospace/tensoraerospace.git
cd tensoraerospace
poetry install --with dev
poetry run pytest # full suite
poetry run pytest tests/aerospacemodel # specific category
poetry run mkdocs serve -a 0.0.0.0:8000 # docs previewSee CONTRIBUTING.md for guidelines.
If TensorAeroSpace contributed to your research or product, please cite it:
@software{tensoraerospace,
title = {TensorAeroSpace: Open-source aerospace simulation toolkit and adaptive control catalogue},
author = {{TensorAeroSpace contributors}},
year = {2026},
url = {https://github.com/TensorAeroSpace/TensorAeroSpace},
note = {Pure-NumPy 6-DoF dynamics, Gymnasium-native environments, classical / ADP / Deep RL agents}
}Plain-text form: TensorAeroSpace contributors. (2026). TensorAeroSpace: Open-source aerospace simulation toolkit and adaptive control catalogue. https://github.com/TensorAeroSpace/TensorAeroSpace
- ๐ Full docs: tensoraerospace.readthedocs.io
- ๐ API reference: detailed module-by-module
- ๐ 16-recipe cookbook: from hello-world to FTC under damage
- ๐ก 11-lesson tutorial: state-space โ controllability โ RL fundamentals โ XFLR5 / Simulink hands-on
- ๐ค Pretrained agents on Hugging Face: huggingface.co/TensorAeroSpace โ SAC / DDPG / PPO checkpoints. Load via
Agent.from_pretrained("TensorAeroSpace/<repo>")in Python, or pass--repo TensorAeroSpace/<name>to the bundled render scripts (e.g.ddpg-b747-render.py). - โ Q&A: DeepWiki AI assistant
- ๐ฌ GitHub Discussions
- ๐ Issue tracker
MIT โ see LICENSE.
- The Gymnasium / OpenAI Gym team for the canonical RL environment API
- The Unity ML-Agents team for 3D simulation infrastructure
- The aerospace research community for decades of open published derivative data (sources cited inline in the aircraft library)
- Every contributor who has made this project possible

