Mr8bit commited on
Commit
b615abb
·
verified ·
1 Parent(s): 5345888

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +277 -0
README.md ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - reinforcement-learning
7
+ - pytorch
8
+ - dsac
9
+ - aerospace
10
+ - flight-control
11
+ - boeing-747
12
+ - continuous-control
13
+ - gymnasium
14
+ library_name: tensoraerospace
15
+ pipeline_tag: reinforcement-learning
16
+ model-index:
17
+ - name: DSAC-B747-PitchControl
18
+ results:
19
+ - task:
20
+ type: reinforcement-learning
21
+ name: Pitch Angle Tracking Control
22
+ dataset:
23
+ type: custom
24
+ name: Boeing 747 Longitudinal Dynamics Simulation
25
+ metrics:
26
+ - type: overshoot
27
+ value: 0.99
28
+ name: Overshoot (%)
29
+ - type: settling_time
30
+ value: 0.40
31
+ name: Settling Time (s)
32
+ - type: rise_time
33
+ value: 0.40
34
+ name: Rise Time (s)
35
+ - type: peak_time
36
+ value: 10.50
37
+ name: Peak Time (s)
38
+ - type: static_error
39
+ value: 0.0002
40
+ name: Static Error
41
+ - type: performance_index
42
+ value: 0.269
43
+ name: Performance Index
44
+ ---
45
+
46
+ # DSAC Agent for Boeing 747 Pitch Angle Control
47
+
48
+ <div align="center">
49
+
50
+ ![TensorAeroSpace](https://raw.githubusercontent.com/TensorAeroSpace/TensorAeroSpace/main/img/logo-no-background.png)
51
+
52
+ **Distributional Soft Actor-Critic (DSAC) for Longitudinal Aircraft Control**
53
+
54
+ [![TensorAeroSpace](https://img.shields.io/badge/%F0%9F%9A%80-TensorAeroSpace-blue)](https://github.com/TensorAeroSpace/TensorAeroSpace)
55
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
56
+ [![PyTorch](https://img.shields.io/badge/PyTorch-2.0+-red.svg)](https://pytorch.org/)
57
+
58
+ </div>
59
+
60
+ ## Model Description
61
+
62
+ This model is a **Distributional Soft Actor-Critic (DSAC)** agent trained to control the pitch angle (θ) of a **Boeing 747** aircraft in a longitudinal flight dynamics simulation. The agent receives normalized state observations and outputs continuous elevator deflection commands to track reference pitch angle signals.
63
+
64
+
65
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/602bf7c9c4f8038e9a1e0a65/7QBAzPCcRlo6KNcTe58J2.png)
66
+
67
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/602bf7c9c4f8038e9a1e0a65/6udlxWC573gza2EdoXEhv.png)
68
+
69
+ ### Intended Uses
70
+
71
+ - **Primary Use**: Automatic pitch angle tracking and stabilization for Boeing 747 aircraft simulation
72
+ - **Research Applications**: Benchmarking RL algorithms for aerospace control systems
73
+ - **Educational**: Learning reinforcement learning concepts in aerospace applications
74
+ - **Hybrid Control**: Can be combined with PID/MPC controllers for robust flight control
75
+
76
+ ### Model Architecture
77
+
78
+ The DSAC agent consists of separate **Actor** and **Critic** neural networks with distributional value estimation:
79
+
80
+ #### Actor Network (Policy)
81
+ | Layer | Configuration |
82
+ |-------|--------------|
83
+ | Input | 5 (observation dim with reference) |
84
+ | Hidden 1 | Linear(5, 256) + ReLU |
85
+ | Hidden 2 | Linear(256, 256) + ReLU |
86
+ | Output (μ) | Linear(256, 1) + Tanh |
87
+ | Output (log σ) | Linear(256, 1), clamped |
88
+
89
+ #### Twin Critic Networks (Distributional Q-Function)
90
+ | Layer | Configuration |
91
+ |-------|--------------|
92
+ | Input | 5 (obs) + 1 (action) |
93
+ | Hidden 1 | Linear(6, 256) + ReLU |
94
+ | Hidden 2 | Linear(256, 256) + ReLU |
95
+ | Output | Linear(256, 1) |
96
+
97
+ ### State Space
98
+
99
+ The observation vector consists of 5 normalized states representing the longitudinal dynamics (with `include_reference_in_obs=True`):
100
+
101
+ | Index | State | Description | Units |
102
+ |-------|-------|-------------|-------|
103
+ | 0 | u | Forward velocity perturbation | normalized |
104
+ | 1 | w | Vertical velocity perturbation | normalized |
105
+ | 2 | q | Pitch rate | normalized |
106
+ | 3 | θ | Pitch angle (tracking target) | normalized |
107
+ | 4 | θ_ref | Reference pitch angle | normalized |
108
+
109
+ ### Action Space
110
+
111
+ | Dimension | Description | Range |
112
+ |-----------|-------------|-------|
113
+ | 1 | Elevator deflection | [-1.0, 1.0] (normalized) |
114
+
115
+ The normalized action is scaled to physical elevator deflection in degrees by the environment.
116
+
117
+ ## Training Details
118
+
119
+ ### Environment Configuration
120
+
121
+ | Parameter | Value |
122
+ |-----------|-------|
123
+ | Environment | `ImprovedB747Env` |
124
+ | Time Step (dt) | 0.1 s |
125
+ | Episode Duration | 20 s |
126
+ | Initial State | [0, 0, 0, 0] |
127
+ | Reference Signal | Step function |
128
+ | Step Amplitude | 1.0° |
129
+ | Step Time | 5.0 s |
130
+ | Reward Mode | `step_response` |
131
+ | Include Reference in Obs | True |
132
+
133
+ ### Training Infrastructure
134
+
135
+ - **Hardware**: CPU / GPU / MPS (auto-select)
136
+ - **Framework**: PyTorch 2.0+
137
+
138
+ ## Evaluation Results
139
+
140
+ ### Performance Metrics
141
+
142
+ | Metric | Value |
143
+ |--------|-------|
144
+ | **Overshoot** | 0.99% |
145
+ | **Settling Time (±5%)** | 0.40 s |
146
+ | **Rise Time** | 0.40 s |
147
+ | **Peak Time** | 10.50 s |
148
+ | **Static Error** | -0.0002 |
149
+ | **Oscillation Count** | 0 |
150
+ | **Performance Index** | 0.269 |
151
+
152
+ ### Integral Criteria
153
+
154
+ | Criterion | Value |
155
+ |-----------|-------|
156
+ | IAE (Integral Absolute Error) | 0.05 |
157
+ | ISE (Integral Squared Error) | 0.00 |
158
+ | ITAE (Integral Time-weighted Absolute Error) | 0.18 |
159
+
160
+ ### Step Response Characteristics
161
+
162
+ The agent demonstrates excellent step tracking performance with:
163
+ - ✅ Minimal overshoot (~1%)
164
+ - ✅ Fast settling time (0.4s)
165
+ - ✅ Quick rise time (0.4s)
166
+ - ✅ Near-zero static error
167
+ - ✅ No oscillations
168
+
169
+ ## Usage
170
+
171
+ ### Installation
172
+
173
+ ```bash
174
+ pip install tensoraerospace
175
+ ```
176
+
177
+ ### Quick Start
178
+
179
+ ```python
180
+ import numpy as np
181
+ import torch
182
+ from tensoraerospace.agent import DSAC
183
+ from tensoraerospace.envs.b747 import ImprovedB747Env
184
+ from tensoraerospace.signals.standart import unit_step
185
+
186
+ def pick_device() -> str:
187
+ if torch.cuda.is_available():
188
+ return "cuda"
189
+ if getattr(torch.backends, "mps", None) is not None and torch.backends.mps.is_available():
190
+ return "mps"
191
+ return "cpu"
192
+
193
+ # Setup environment
194
+ dt = 0.1
195
+ tn = 20.0
196
+ step_deg = 1.0
197
+ step_time_sec = 5.0
198
+ t = np.arange(0.0, tn + dt, dt, dtype=np.float32)
199
+
200
+ # Create step reference signal (1 degree step at t=5s)
201
+ ref = unit_step(t, degree=step_deg, time_step=step_time_sec, output_rad=True).reshape(1, -1)
202
+
203
+ env = ImprovedB747Env(
204
+ initial_state=np.array([0.0, 0.0, 0.0, 0.0], dtype=float),
205
+ reference_signal=ref,
206
+ number_time_steps=ref.shape[1],
207
+ dt=dt,
208
+ include_reference_in_obs=True,
209
+ reward_mode="step_response",
210
+ )
211
+
212
+ # Load pretrained agent
213
+ agent = DSAC.from_pretrained("TensorAeroSpace/dsac-b747-step-response")
214
+ agent.env = env
215
+ agent.to_device(pick_device())
216
+ agent.eval()
217
+
218
+ # Run evaluation
219
+ obs, _ = env.reset()
220
+ done = False
221
+ total_reward = 0.0
222
+
223
+ while not done:
224
+ action = agent.select_action(obs, evaluate=True)
225
+ obs, reward, terminated, truncated, info = env.step(action)
226
+ done = bool(terminated or truncated)
227
+ total_reward += float(reward)
228
+
229
+ print(f"Episode reward: {total_reward}")
230
+ ```
231
+
232
+ ### Load from Local Checkpoint
233
+
234
+ ```python
235
+ from tensoraerospace.agent import DSAC
236
+
237
+ # Load from local directory
238
+ agent = DSAC.from_pretrained("./path/to/checkpoint")
239
+ ```
240
+
241
+ ## Limitations
242
+
243
+ - **Fixed Aircraft Model**: Trained specifically on Boeing 747 longitudinal dynamics; may not generalize to other aircraft
244
+ - **Step Reference Only**: Optimized for step reference tracking; performance on other signal types (sine, ramp) may vary
245
+ - **Simulation Gap**: Trained in simulation; real-world deployment would require additional validation
246
+ - **State Observability**: Assumes all longitudinal states are observable
247
+ - **Linear Dynamics**: Based on linearized aircraft model around trim conditions
248
+
249
+ ## Ethical Considerations
250
+
251
+ - **Not for Real Flight Control**: This model is for research and educational purposes only. It should NOT be used for actual aircraft control systems without extensive testing, certification, and regulatory approval.
252
+ - **Simulation Only**: All training and evaluation performed in simulation environments.
253
+
254
+ ## Citation
255
+
256
+ If you use this model in your research, please cite:
257
+
258
+ ```bibtex
259
+ @software{tensoraerospace2024,
260
+ title = {TensorAeroSpace: Advanced Aerospace Control Systems \& Reinforcement Learning Framework},
261
+ author = {TensorAeroSpace Team},
262
+ year = {2024},
263
+ url = {https://github.com/TensorAeroSpace/TensorAeroSpace},
264
+ license = {MIT}
265
+ }
266
+ ```
267
+
268
+ ## Model Card Authors
269
+
270
+ TensorAeroSpace Team
271
+
272
+ ## Model Card Contact
273
+
274
+ - **GitHub**: [TensorAeroSpace/TensorAeroSpace](https://github.com/TensorAeroSpace/TensorAeroSpace)
275
+ - **Documentation**: [tensoraerospace.readthedocs.io](https://tensoraerospace.readthedocs.io/)
276
+ - **Hugging Face**: [TensorAeroSpace](https://huggingface.co/TensorAeroSpace)
277
+