McDonnell Douglas F‑4C — продольная динамика¶
F‑4C Phantom II — американский истребитель‑бомбардировщик 3‑го поколения. Страница оформлена по аналогии с ELV: быстрый старт, математика, производные и API.
Как устроен объект управления¶
Модель задана в пространстве состояний:
Где:
Типовая структура матриц:
- u: продольная скорость, м/с
- w: нормальная скорость, м/с
- q: угловая скорость тангажа, рад/с
- θ: тангаж, рад
- δₑ: отклонение руля высоты, рад
- x_u, x_w, x_q, x_θ — частные производные продольной силы \(X\) по \(u, w, q, \theta\)
- z_u, z_w, z_q, z_θ — частные производные нормальной силы \(Z\)
- m_u, m_w, m_q, m_θ — частные производные момента тангажа \(M\)
- x_δₑ, z_δₑ, m_δₑ — производные по управляющему \(\delta_e\)
О единицах измерения
Углы и угловые скорости — в радианах. Методы API позволяют получить значения в градусах.
Математическая модель¶
Модель описывается стандартным уравнением состояния:
где:
- x — вектор состояния, \(x = [u, w, q, \theta]^{\top}\), представляющий отклонения продольной скорости, вертикальной скорости, скорости тангажа и угла тангажа.
- u — вектор управления, в данном случае \(u = [\delta_e]\), где \(\delta_e\) — отклонение руля высоты.
- A — матрица состояния (или системная матрица).
- B — матрица управления.
Единицы измерения¶
Вектор состояния \(x = [u, w, q, \theta]^{\top}\):
- u, w: м/с (скорости)
- q: рад/с (угловая скорость)
- θ: рад (угол)
Вектор управления \(u = [\delta_e]\):
- δₑ: рад (отклонение руля высоты)
Условия полета¶
Вычисленные матрицы A и B для F-4C представлены для следующих условий полета:
- Число Маха: 0.6
- Высота: 35 000 футов
Численные матрицы¶
Производные (численные значения)¶
- Матрица A (производные):
| Коэффициент | Значение |
|---|---|
| x_u | 7.6180 × 10⁻⁴ |
| x_w | 4.7612 × 10⁻³ |
| x_q | 0.0 |
| x_θ | -9.8100 |
| z_u | -6.6657 × 10⁻² |
| z_w | -2.8567 × 10⁻¹ |
| z_q | 1.8000 × 10² |
| z_θ | 0 |
| m_u | 1.5124 × 10⁻³ |
| m_w | -1.0083 × 10⁻² |
| m_q | -1.6384 × 10⁻¹ |
| m_θ | 0 |
- Вход δₑ (столбец B):
| Коэффициент | Значение |
|---|---|
| x_δₑ | 2.6533 × 10⁻³ |
| z_δₑ | -6.8562 |
| m_δₑ | -5.4446 |
Ограничения привода
По умолчанию применяются предельные значения управления:
- Максимальная величина: \(\pm 25^\circ\)
- Максимальная скорость изменения: \(60^\circ/\text{s}\)
Внутренние вычисления — в радианах; ограничения переводятся эквивалентно.
Источники¶
- Heffley R. K., Jewell W. F. Aircraft handling qualities data. – NASA, 1972. № AD‑A277031.
- Etkin B., Reid L. D. Dynamics of flight. – New York : Wiley, 1959. – Т. 2
Награда¶
Функция награды по умолчанию возвращает отрицательную абсолютную ошибку отслеживания угла тангажа:
Чем выше награда (ближе к 0), тем лучше качество отслеживания. Пользовательская функция награды может быть передана через параметр reward_func.
Быстрый старт¶
import gymnasium as gym
import numpy as np
from tensoraerospace.envs import LinearLongitudinalF4C
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(
'LinearLongitudinalF4C-v0',
number_time_steps=number_time_steps,
initial_state=[[0],[0],[0],[0]],
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 LongitudinalF4C
dt = 0.01
number_time_steps = 200
x0 = np.array([0.0, 0.0, 0.0, 0.0]) # [u, w, q, theta]
model = LongitudinalF4C(
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¶
LongitudinalF4C(x0, number_time_steps, selected_state_output=None, t0=0, dt=0.01)
¶
Bases: ModelBase
McDonnell Douglas F-4C in longitudinal control channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x0
|
ndarray | list[float]
|
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 [rad]
State space
u: Longitudinal aircraft velocity [ft/s] w: Normal aircraft velocity [ft/s] q: Pitch angular velocity [rad/s] theta: Pitch angle [rad]
Output space
u: Longitudinal aircraft velocity [ft/s] w: Normal aircraft velocity [ft/s] q: Pitch angular velocity [rad/s] theta: Pitch angle [rad]
Initialize LongitudinalF4C instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x0
|
ndarray | list[float]
|
Initial state of the control object. |
required |
number_time_steps
|
int
|
Number of time steps. |
required |
selected_state_output
|
list[int] | None
|
Selected states of the control object. Defaults to None. |
None
|
t0
|
float
|
Initial time. Defaults to 0. |
0
|
dt
|
float
|
Discretization frequency. Defaults to 0.01. |
0.01
|
import_linear_system()
¶
Load (set) stored linearized system matrices.
initialise_system(x0, number_time_steps)
¶
Initialize the system and allocate history buffers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x0
|
ndarray | list[float]
|
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 time-dependent attributes 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 the time history of an output signal.
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'). Defaults to 'rus'. |
'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. |
LinearLongitudinalF4C(initial_state, reference_signal, number_time_steps, tracking_states=None, state_space=None, control_space=None, output_space=None, reward_func=None)
¶
Bases: Env
Simulation of LongitudinalF4C control object in OpenAI Gym environment for training AI agents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
initial_state
|
Union[ndarray, list[float]]
|
Initial state. |
required |
reference_signal
|
Union[ndarray, Callable]
|
Reference signal. |
required |
number_time_steps
|
int
|
Number of simulation steps. |
required |
tracking_states
|
Optional[list[str]]
|
Tracked states. |
None
|
state_space
|
Optional[list[str]]
|
State space. |
None
|
control_space
|
Optional[list[str]]
|
Control space. |
None
|
output_space
|
Optional[list[str]]
|
Full output space (including noise). |
None
|
reward_func
|
Optional[Callable]
|
Reward function (WIP status). |
None
|
Initialize F-4C longitudinal environment.
reward(state, ref_signal, ts)
staticmethod
¶
Evaluate control performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
_type_
|
Current state. |
required |
ref_signal
|
_type_
|
Reference state. |
required |
ts
|
_type_
|
Time step. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
reward |
float
|
Control performance evaluation. |
step(action)
¶
Execute a simulation step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action
|
ndarray
|
Array of control signals for selected control surfaces. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
next_state |
ndarray
|
Next state of the control object. |
reward |
ndarray
|
Evaluation of control algorithm actions. |
done |
bool
|
Simulation status, whether 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 options for initialization. |
None
|
render()
¶
Visual display of actions in the environment. Status: WIP.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Rendering is not implemented for this environment. |