Skip to main content

Open source deep learning framework that focuses on aerospace objects (rockets, planes, UAVs)

Project description

๐Ÿš€ TensorAeroSpace

en ru PyPI version PyPI downloads Quick Check Coverage Status Documentation Status Ask DeepWiki Python License GitHub stars

TensorAeroSpace logo

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


๐Ÿ“‘ Contents


๐ŸŒŸ Overview

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 DamageProfile instances.
  • ๐Ÿงช 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_hub from tensoraerospace.agent.base โ€” pretrained checkpoints live at huggingface.co/TensorAeroSpace.

๐Ÿ“Š How it compares

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.

๐Ÿงญ Application areas

  1. Automatic flight control โ€” stabilisation, trajectory tracking, attitude control for aircraft, UAVs, experimental vehicles.
  2. Rocket / spacecraft control โ€” launch vehicles, satellites in different orbital classes, ascent-trajectory optimisation.
  3. Hybrid control synthesis โ€” designing and tuning loops that combine classical and intelligent methods.
  4. Algorithm benchmarking โ€” automated hyperparameter search, head-to-head comparisons, metric visualisation.
  5. Simulator integration โ€” game engines (Unity ML-Agents), CAD/CAE (Simulink, SimInTech), bidirectional model exchange.
  6. Reliability and FTC research โ€” failure-mode studies, controller-reconfiguration assessment, dataset preparation.

Each area has working examples and documentation (see ๐Ÿ“š Examples & guides).

๐Ÿš€ Quickstart

๐Ÿ’ก Interactive walkthrough: open quickstart.ipynb to run a SAC benchmark on the B-747 end-to-end in Jupyter / VS Code.

โœ… System requirements

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

๐Ÿ“ฆ Installation

Poetry (recommended)

git clone https://github.com/tensoraerospace/tensoraerospace.git
cd tensoraerospace
poetry install
poetry shell        # activate the venv
poetry run pytest   # quick smoke test

pip

pip install tensoraerospace                  # core (NumPy, gymnasium, PyTorch)
pip install 'tensoraerospace[ray]'           # + Ray RLlib for distributed training

Additional 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,jupyter reproduces the CI environment used by notebooks-smoke.yml.

๐Ÿณ Docker

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:latest

๐Ÿƒโ€โ™‚๏ธ Quick example โ€” PID + linear F-16

import 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))

๐Ÿ’ฅ In-flight damage modelling

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

๐Ÿค– Supported algorithms

Classical control

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.

Deep RL โ€” on-policy

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).

Deep RL โ€” off-policy

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.

Imitation learning

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.

Adaptive Dynamic Programming (model-based critics)

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.

Online adaptive critics for fault-tolerant flight

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.

โœˆ๏ธ Aircraft & spacecraft library

๐Ÿ›ฉ๏ธ Fixed-wing (nonlinear 6-DoF, peer-reviewed source data)

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

๐Ÿชถ Linear longitudinal models

  • 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.

๐Ÿš UAVs and drones

  • 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

๐Ÿš€ Rockets and satellites

  • ELV (Expendable Launch Vehicle) โ€” booster dynamics
  • Generic missile โ€” customisable simulation
  • GeoSat โ€” geostationary orbital mechanics
  • ComSat โ€” communication-satellite dynamics and control

๐ŸŽฎ Simulation environments

๐ŸŽฏ Unity ML-Agents integration

Unity demo

  • ๐ŸŽฎ 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

๐Ÿ”ง MATLAB / Simulink integration (experimental)

Simulink model

What ships today:

Status: Simulink interop is community-maintained โ€” model parsing helpers live in the lessons rather than being a turnkey importer. PRs welcome.

๐Ÿ“Š State-space matrices for classical synthesis

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 under tensoraerospace/aerospacemodel/
  • ๐ŸŽ›๏ธ PID.tune_matlab_style(env) โ€” autotunes gains against the env's state-space matrices via differential-evolution against a step-response criterion

๐Ÿ“š Examples & guides

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

๐ŸŒŸ Featured examples

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

Quick run commands

# 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:

โš ๏ธ Known limitations

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 .slx plants 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.

๐Ÿ› ๏ธ Development

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 preview

See CONTRIBUTING.md for guidelines.

๐ŸŽ“ How to cite

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

๐Ÿ“– Documentation

  • ๐Ÿ“š 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

๐Ÿค Community & support

โญ Star history

TensorAeroSpace star history

๐Ÿ“„ License

MIT โ€” see LICENSE.

๐Ÿ™ Acknowledgements

  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensoraerospace-0.3.16.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tensoraerospace-0.3.16-py3-none-any.whl (3.6 MB view details)

Uploaded Python 3

File details

Details for the file tensoraerospace-0.3.16.tar.gz.

File metadata

  • Download URL: tensoraerospace-0.3.16.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for tensoraerospace-0.3.16.tar.gz
Algorithm Hash digest
SHA256 08f2588752dde56c48305478f64b85a59c755e9f7b316459138743e7cdd7b1f4
MD5 8c19616b9f91a2ccf963785fbece83a9
BLAKE2b-256 078c5a34edbe4c2fa85a6166576e9b9d2cda98b0ef67b11e43c3b16169f7777d

See more details on using hashes here.

File details

Details for the file tensoraerospace-0.3.16-py3-none-any.whl.

File metadata

File hashes

Hashes for tensoraerospace-0.3.16-py3-none-any.whl
Algorithm Hash digest
SHA256 798b83d2c9373fb2c034494b59f9933aaa4d23b80bd81f956c727d7ade7c5d6c
MD5 48186013a7640f6458960bb431b25e52
BLAKE2b-256 eb247d05cd79455cc3b3496e2eb328fad593cd2f3228435e957fe081acbb3cbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page