Самолёт Boeing‑747 — продольная динамика¶
Boeing‑747 — двухпалубный широкофюзеляжный пассажирский самолёт. В данной библиотеке реализован продольный канал полёта в виде линейной модели пространства состояний и совместимой среды Gymnasium для обучения агентов управления.
ЛТХ (справочно)¶
| Параметр | Значение |
|---|---|
| Длина, м | 70.7 |
| Размах крыла, м | 64.4 |
| Высота самолёта, м | 19.4 |
| Площадь крыла, м² | 541.2 |
| Нормальная взлётная масса, кг | 11467 |
Как устроен объект управления¶
Модель задана в пространстве состояний и описывает эволюцию переменных продольного движения при управлении рулём высоты.
Где вектор состояния и управляющее воздействие:
Типовая структура матриц:
- u: продольная скорость, м/с
- w: нормальная скорость, м/с
- q: угловая скорость тангажа, рад/с
- θ: тангаж, рад
- η: управляющее отклонение стабилизатора, рад
- x_u, x_w, x_q, x_θ — частные производные продольной силы \(X\) по переменным \(u, w, q, \theta\) соответственно
- z_u, z_w, z_q, z_θ — частные производные нормальной силы \(Z\) по переменным \(u, w, q, \theta\)
- m_u, m_w, m_q, m_θ — частные производные момента тангажа \(M\) по переменным \(u, w, q, \theta\)
- x_η, z_η, m_η — частные производные по управляющему воздействию \(\eta\) (отклонение стабилизатора)
О единицах измерения
Внутри моделей углы и угловые скорости — в радианах. Методы API позволяют получить данные в градусах.
Математическая модель¶
Так как объект управления без внутренних возмущений, выход \(y\) не используется (\(C\) — диагональная, \(D\) — нулевая).
Численные матрицы (пример линеаризации):
Ограничения привода
По умолчанию применяются предельные значения управления:
- Максимальная величина: \(\pm 25^\circ\)
- Максимальная скорость изменения: \(60^\circ/\text{s}\)
Внутренние вычисления — в радианах; ограничения переводятся эквивалентно.
Источники¶
- Heffley R. K., Jewell W. F. Aircraft handling qualities data. – NASA, 1972. – № AD‑A277031. Ссылка
- Abd Elwahab S. et al. Evaluation of Boeing 747‑E lateral autopilot using flying and handling qualities specifications // ICCCCEE 2017. IEEE. Ссылка
Быстрый старт¶
import gymnasium as gym
import numpy as np
from tensoraerospace.envs import LinearLongitudinalB747
from tensoraerospace.utils import generate_time_period
from tensoraerospace.signals.standard import unit_step
dt = 0.01
tp = generate_time_period(tn=20, dt=dt)
number_time_steps = len(tp)
reference_signals = unit_step(degree=5, tp=tp, time_step=10, output_rad=True).reshape(1, -1)
env = gym.make(
'LinearLongitudinalB747-v0',
number_time_steps=number_time_steps,
initial_state=[[0],[0],[0],[0]], # u, w, q, theta (будет сопоставлено)
reference_signal=reference_signals,
)
state, info = env.reset()
for _ in range(200):
action = np.array([[0.1]])
state, reward, terminated, truncated, info = env.step(action)
if terminated or truncated:
break
import numpy as np
from tensoraerospace.aerospacemodel import LongitudinalB747
dt = 0.01
number_time_steps = 200
x0 = np.array([0.0, 0.0, 0.0, 0.0]) # [u, w, q, theta]
model = LongitudinalB747(
x0=x0,
number_time_steps=number_time_steps,
selected_state_output=["u", "w", "q", "theta"],
dt=dt,
)
for t in range(number_time_steps - 1):
u = np.array([[0.05]]) # отклонение стабилизатора (рад)
x_next = model.run_step(u)
Python API¶
LongitudinalB747(x0, number_time_steps, selected_state_output=None, t0=0, dt=0.01)
¶
Bases: ModelBase
Boeing 747 in longitudinal control channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x0
|
ndarray
|
Initial state of the control object. |
required |
number_time_steps
|
int
|
Number of time steps. |
required |
selected_state_output
|
optional
|
Selected states of the control object. Defaults to None. |
None
|
t0
|
int
|
Initial time. Defaults to 0. |
0
|
dt
|
float
|
Discretization frequency. Defaults to 0.01. |
0.01
|
Action space
ele: elevator [deg]
State space
u: Longitudinal aircraft velocity [m/s] w: Normal aircraft velocity [m/s] q: Pitch angular velocity [deg/s] theta: Pitch [deg]
Output space
u: Longitudinal aircraft velocity [m/s] w: Normal aircraft velocity [m/s] q: Pitch angular velocity [deg/s] theta: Pitch [deg]
import_linear_system()
¶
Load (set) stored linearized system matrices.
Sets A, B, C, D matrices for the Boeing 747 longitudinal linear model.
initialise_system(x0, number_time_steps)
¶
Initialize the system and allocate history buffers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x0
|
ndarray
|
Initial state. |
required |
number_time_steps
|
int
|
Number of simulation steps. |
required |
run_step(ut_0)
¶
Run one discrete-time simulation step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ut_0
|
ndarray
|
Control vector. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Next state at time t+1. |
update_system_attributes()
¶
Update internal state and step counter after each simulation step.
get_state(state_name, to_deg=False, to_rad=False)
¶
Return the time history of a state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_name
|
str
|
State name. |
required |
to_deg
|
bool
|
Convert radians to degrees. |
False
|
to_rad
|
bool
|
Convert degrees to radians. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: State history array. |
get_control(control_name, to_deg=False, to_rad=False)
¶
Return the time history of a control input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_name
|
str
|
Control signal name. |
required |
to_deg
|
bool
|
Convert radians to degrees. |
False
|
to_rad
|
bool
|
Convert degrees to radians. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Control history array. |
get_output(state_name, to_deg=False, to_rad=False)
¶
Return output time history for the specified output name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_name
|
str
|
Output name. |
required |
to_deg
|
bool
|
Convert radians to degrees. |
False
|
to_rad
|
bool
|
Convert degrees to radians. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Output history array. |
plot_output(output_name, time, lang='rus', to_deg=False, to_rad=False, figsize=(10, 10))
¶
Plot an output signal over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_name
|
str
|
Output name. |
required |
time
|
ndarray
|
Time vector. |
required |
lang
|
str
|
Axis label language ('rus' or 'eng'). |
'rus'
|
to_deg
|
bool
|
Convert radians to degrees. |
False
|
to_rad
|
bool
|
Convert degrees to radians. |
False
|
figsize
|
tuple
|
Figure size. |
(10, 10)
|
Returns:
| Type | Description |
|---|---|
Figure
|
matplotlib.figure.Figure: Figure object. |
Raises:
| Type | Description |
|---|---|
Exception
|
If invalid formatting is requested or the signal is not found. |
LinearLongitudinalB747(initial_state, reference_signal, number_time_steps, tracking_states=None, state_space=None, control_space=None, output_space=None, reward_func=None, use_reward=True, dt=0.01, render_mode=None)
¶
Bases: Env
Simulation of LongitudinalB747 control object in Gym for training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_state
|
ndarray
|
Initial state. |
required |
reference_signal
|
ndarray
|
Reference signal. |
required |
number_time_steps
|
int
|
Number of simulation steps. |
required |
tracking_states
|
list[str] | None
|
Tracked states. |
None
|
state_space
|
list[str] | None
|
State space. |
None
|
control_space
|
list[str] | None
|
Control space. |
None
|
output_space
|
list[str] | None
|
Full output space (including noise). |
None
|
reward_func
|
Callable | None
|
Reward function (WIP status). |
None
|
use_reward
|
bool
|
Whether to use reward. |
True
|
dt
|
float
|
Discretization frequency. |
0.01
|
Notes
- Action units expected by the environment are degrees (deg).
- Actions are converted to radians (rad) before being passed to the underlying model.
Initialize LinearLongitudinalB747 environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_state
|
ndarray
|
Initial state. |
required |
reference_signal
|
ndarray
|
Reference signal. |
required |
number_time_steps
|
int
|
Number of simulation steps. |
required |
tracking_states
|
list[str] | None
|
Tracked states. Defaults to ["theta", "q"]. |
None
|
state_space
|
list[str] | None
|
State space. Defaults to ["theta", "q"]. |
None
|
control_space
|
list[str] | None
|
Control space. Defaults to ["stab"]. |
None
|
output_space
|
list[str] | None
|
Full output space. Defaults to ["theta", "q"]. |
None
|
reward_func
|
Callable | None
|
Reward function. Defaults to None. |
None
|
use_reward
|
bool
|
Whether to use reward. Defaults to True. |
True
|
dt
|
float
|
Discretization frequency. Defaults to 0.01. |
0.01
|
render_mode
|
str | None
|
|
None
|
reward(state, ref_signal, ts, action=None)
staticmethod
¶
Control evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
ndarray
|
Current state. |
required |
ref_signal
|
ndarray
|
Reference state. |
required |
ts
|
int
|
Time step. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Control evaluation (negative MSE). |
step(action)
¶
Execute simulation step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
ndarray
|
Control signal array for selected actuators in degrees. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
next_state |
ndarray
|
Next state of control object. |
reward |
ndarray
|
Evaluation of control algorithm actions. |
done |
bool
|
Simulation status, completed or not. |
logging |
any
|
Additional information (not used). |
reset(seed=None, options=None)
¶
Reset simulation environment to initial conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int
|
Seed for random number generator. |
None
|
options
|
dict
|
Additional initialization options. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Tuple[ndarray, Dict[str, Any]]
|
Observation array and info dictionary. |
render(mode=None)
¶
Render a lightweight telemetry snapshot.
The legacy B747 environment does not have a graphical viewer. To keep
render_mode="human" usable, human mode prints one concise state line;
ansi returns the same line as a string for tests and logs.
