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- f16
|
| 11 |
+
- gymnasium
|
| 12 |
+
- tensorflow
|
| 13 |
+
- keras
|
| 14 |
+
pipeline_tag: reinforcement-learning
|
| 15 |
+
model-index:
|
| 16 |
+
- name: IHDP-F16 (TensorAeroSpace)
|
| 17 |
+
results:
|
| 18 |
+
- task:
|
| 19 |
+
type: reinforcement-learning
|
| 20 |
+
name: F-16 longitudinal alpha tracking
|
| 21 |
+
dataset:
|
| 22 |
+
name: Synthetic 5° step reference
|
| 23 |
+
type: simulation
|
| 24 |
+
metrics:
|
| 25 |
+
- name: MAE (alpha)
|
| 26 |
+
type: mae
|
| 27 |
+
value: 0.042348
|
| 28 |
+
unit: rad
|
| 29 |
+
- name: RMSE (alpha)
|
| 30 |
+
type: rmse
|
| 31 |
+
value: 0.069442
|
| 32 |
+
unit: rad
|
| 33 |
+
- name: Max error (alpha)
|
| 34 |
+
type: max_error
|
| 35 |
+
value: 0.204428
|
| 36 |
+
unit: rad
|
| 37 |
+
- name: Settling time (95%)
|
| 38 |
+
type: settling_time
|
| 39 |
+
value: 2.87
|
| 40 |
+
unit: s
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
# IHDP Agent for F-16 Longitudinal Control (TensorAeroSpace)
|
| 44 |
+
|
| 45 |
+
This repository contains an Incremental Heuristic Dynamic Programming (IHDP) agent trained for longitudinal control of the F-16, implemented with TensorAeroSpace.
|
| 46 |
+
|
| 47 |
+
The agent tracks a step reference in angle of attack (alpha). It uses two neural networks (Actor and Critic) and an online incremental model to adapt features during rollout.
|
| 48 |
+
|
| 49 |
+
## Model architecture and files
|
| 50 |
+
|
| 51 |
+
Saved artifacts (see this repository files):
|
| 52 |
+
|
| 53 |
+
- `config.json`: environment and agent configuration (IO, actor/critic/incremental settings, optional reference signal snapshot)
|
| 54 |
+
- `actor.h5`: Keras weights for the Actor network
|
| 55 |
+
- `critic.h5`: Keras weights for the Critic network
|
| 56 |
+
- `incremental_model/`:
|
| 57 |
+
- `F.npy`, `G.npy`: incremental model matrices
|
| 58 |
+
- `delta_xt.npy`, `delta_ut.npy` (if available): last gradients windows used during identification
|
| 59 |
+
|
| 60 |
+
## How to use
|
| 61 |
+
|
| 62 |
+
```python
|
| 63 |
+
import os
|
| 64 |
+
import numpy as np
|
| 65 |
+
import gymnasium as gym
|
| 66 |
+
from tensoraerospace.agent.ihdp.model import IHDPAgent
|
| 67 |
+
|
| 68 |
+
# Load pretrained IHDP agent (either from local folder or HF Hub repo ID)
|
| 69 |
+
repo_id = "<username>/<repo_name>" # or path to a local saved folder
|
| 70 |
+
agent = IHDPAgent.from_pretrained(repo_id, access_token=os.getenv("HF_TOKEN"))
|
| 71 |
+
|
| 72 |
+
# Create F-16 longitudinal environment (must match config.json IO/params)
|
| 73 |
+
env = gym.make(
|
| 74 |
+
"LinearLongitudinalF16-v0",
|
| 75 |
+
number_time_steps=2002,
|
| 76 |
+
initial_state=[[0], [0], [0]],
|
| 77 |
+
reference_signal=np.zeros((1, 2002)), # replace with your reference
|
| 78 |
+
use_reward=False,
|
| 79 |
+
state_space=["theta", "alpha", "q"],
|
| 80 |
+
output_space=["theta", "alpha", "q"],
|
| 81 |
+
control_space=["ele"],
|
| 82 |
+
tracking_states=["alpha"],
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
# Example rollout (reference must be shaped [1, T])
|
| 86 |
+
obs, info = env.reset()
|
| 87 |
+
reference = env.unwrapped.reference_signal
|
| 88 |
+
for t in range(reference.shape[1] - 3):
|
| 89 |
+
u = agent.predict(obs, reference, t)
|
| 90 |
+
obs, r, terminated, truncated, info = env.step(np.array(u))
|
| 91 |
+
if terminated or truncated:
|
| 92 |
+
break
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
## Reproduce the training/evaluation
|
| 96 |
+
|
| 97 |
+
This model card is based on the notebook `example/general_examples/example_ihdp_beautiful.ipynb` with the following settings:
|
| 98 |
+
|
| 99 |
+
- Simulation time: 20 s, dt: 0.01 s → 2002 steps
|
| 100 |
+
- Tracking variable: alpha (angle of attack)
|
| 101 |
+
- Reference: step of 5° (converted to radians)
|
| 102 |
+
- Initial state: `[theta=0, alpha=0, q=0]`
|
| 103 |
+
|
| 104 |
+
## Results
|
| 105 |
+
|
| 106 |
+
From the evaluation run in the notebook:
|
| 107 |
+
|
| 108 |
+
- MAE (alpha): 0.042348 rad (2.426°)
|
| 109 |
+
- RMSE (alpha): 0.069442 rad (3.979°)
|
| 110 |
+
- Max error (alpha): 0.204428 rad (11.713°)
|
| 111 |
+
- Settling time (95%): 2.87 s
|
| 112 |
+
|
| 113 |
+
Control (elevator) statistics depend on limits and units used in the environment. Ensure your environment configuration matches `config.json`.
|
| 114 |
+
|
| 115 |
+
## Intended use and limitations
|
| 116 |
+
|
| 117 |
+
- Intended for research and educational use on aircraft longitudinal control tasks.
|
| 118 |
+
- This is a simulation-trained controller; it is not validated for real-world flight.
|
| 119 |
+
- Performance is sensitive to environment configuration and reference signals. Always align your env settings with the provided config.
|
| 120 |
+
|
| 121 |
+
## How this repository was created
|
| 122 |
+
|
| 123 |
+
Artifacts were saved using `IHDPAgent.save(...)`/`save_pretrained(...)` and uploaded with `IHDPAgent.push_to_hub(...)` in TensorAeroSpace.
|
| 124 |
+
|
| 125 |
+
## Citation
|
| 126 |
+
|
| 127 |
+
If you use this work, please cite TensorAeroSpace.
|
| 128 |
+
|
| 129 |
+
```
|
| 130 |
+
@software{TensorAeroSpace,
|
| 131 |
+
title = {TensorAeroSpace: Open source deep learning framework for aerospace objects},
|
| 132 |
+
author = {Mazaev, Artemiy and Davydov, Vasily and Li, Yakov},
|
| 133 |
+
year = {2025},
|
| 134 |
+
url = {https://github.com/mr8bit/TensorAeroSpace},
|
| 135 |
+
}
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
|