Перейти к содержанию

Типичная ракета — продольная динамика

Типовая модель ракеты в продольном канале. Страница оформлена по аналогии с ELV: быстрый старт, математика, таблицы производных и API.

typical-rocket

  • Быстрый старт

    Запустите среду или модель за минуты.

    К примеру

  • API модели

    Документация Python‑класса типовой ракеты.

    К API

  • Среда Gymnasium

    Готовая среда для RL‑агентов.

    К среде

  • Теория

    Уравнения состояния и численные параметры.

    К модели

Как устроен объект управления

Модель задана в пространстве состояний:

\[\dot{x} = A x + B u, \quad y = C x + D u\]

Где:

\[ x = \begin{bmatrix} u & w & q & \theta \end{bmatrix}^{\top}, \quad u_{in} = \eta \]

Типовая структура матриц:

\[ \begin{bmatrix} \dot{u} \\ \dot{w} \\ \dot{q} \\ \dot{\theta} \end{bmatrix} = \begin{bmatrix} x_u & x_w & x_q & x_{\theta} \\ z_u & z_w & z_q & z_{\theta} \\ m_u & m_w & m_q & m_{\theta} \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} u \\ w \\ q \\ \theta \end{bmatrix} + \begin{bmatrix} x_{\eta} \\ z_{\eta} \\ m_{\eta} \\ 0 \end{bmatrix} \eta \]
  • 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_η — производные по управляющему \(\eta\)

О единицах измерения

Углы и угловые скорости — в радианах. Методы API позволяют получить значения в градусах.

Математическая модель

\[ \dot{x} = A x + B u, \qquad y = C x + D u \]

Численные матрицы (пример линеаризации):

\[ \begin{bmatrix} \dot{u} \\ \dot{w} \\ \dot{q} \\ \dot{\theta} \end{bmatrix} = \begin{bmatrix} -0.0089 & -0.1474 & 0 & -9.75 \\ -0.0216 & -0.3601 & 5.9470 & 0.01958 \\ 0 & -0.0015 & -0.0224 & 0.0006 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} u \\ w \\ q \\ \theta \end{bmatrix} + \begin{bmatrix} 9.748 \\ 3.77 \\ -0.034 \\ 0.01 \end{bmatrix} \eta \]

Производные (численные значения)

  • Матрица A (производные):
Коэффициент Значение
x_u -0.0089
x_w -0.1474
x_q 0
x_θ -9.75
z_u -0.0216
z_w -0.3601
z_q 5.9470
z_θ 0.01958
m_u 0.0
m_w -0.0015
m_q -0.0224
m_θ 0.0006
  • Вход η (столбец B):
Коэффициент Значение
x_η 9.748
z_η 3.77
m_η -0.034
θ_η 0.01

Ограничения привода

По умолчанию применяются предельные значения управления:

  • Максимальная величина: \(\pm 25^\circ\)
  • Максимальная скорость изменения: \(60^\circ/\text{s}\)

Внутренние вычисления — в радианах; ограничения переводятся эквивалентно.

Источники

  1. Arikapalli V. S. N. et al. Missile Longitudinal Dynamics Control Design using Pole Placement and LQR Methods — A Critical Analysis // Defence Science Journal. 2021. 71(5). Ссылка

Награда

Функция награды по умолчанию возвращает отрицательную абсолютную ошибку отслеживания угла тангажа:

\[r_t = -|\theta(t) - \theta_{\text{ref}}(t)|\]

Чем выше награда (ближе к 0), тем лучше качество отслеживания. Пользовательская функция награды может быть передана через параметр reward_func.

Быстрый старт

import gymnasium as gym 
import numpy as np

from tensoraerospace.envs import LinearLongitudinalMissileModel
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(
    'LinearLongitudinalMissileModel-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 MissileModel

dt = 0.01
number_time_steps = 200

x0 = np.array([0.0, 0.0, 0.0, 0.0])

model = MissileModel(
    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

MissileModel(x0, number_time_steps, selected_state_output=None, t0=0, dt=0.01)

Bases: ModelBase

Missile 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 [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]

Initialize MissileModel 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 stored linearized matrices.

initialise_system(x0, number_time_steps)

Initialize the system.

Parameters:

Name Type Description Default
x0 ndarray | list[float]

Initial state of the control object.

required
number_time_steps int

Number of time steps in the iteration.

required

run_step(ut_0)

Execute one time step iteration.

Parameters:

Name Type Description Default
ut_0 ndarray

Control vector.

required

Returns:

Name Type Description
xt1 ndarray

Control object state at step t+1.

update_system_attributes()

Update attributes that change with each time step.

get_state(state_name, to_deg=False, to_rad=False)

Get state array history.

Parameters:

Name Type Description Default
state_name str

State name.

required
to_deg bool

Convert to degrees. Defaults to False.

False
to_rad bool

Convert to radians. Defaults to False.

False

Returns:

Type Description
ndarray

np.ndarray: Array of selected state history.

Example

state_hist = model.get_state('alpha', to_deg=True)

get_control(control_name, to_deg=False, to_rad=False)

Get control signal array history.

Parameters:

Name Type Description Default
control_name str

Control signal name.

required
to_deg bool

Convert to degrees. Defaults to False.

False
to_rad bool

Convert to radians. Defaults to False.

False

Returns:

Type Description
ndarray

np.ndarray: Array of selected control signal history.

Example

control_hist = model.get_control('stab', to_deg=True)

get_output(state_name, to_deg=False, to_rad=False)

Get output signal array history.

Parameters:

Name Type Description Default
state_name str

Output signal name.

required
to_deg bool

Convert to degrees. Defaults to False.

False
to_rad bool

Convert to radians. Defaults to False.

False

Returns:

Type Description
ndarray

np.ndarray: Array of selected output signal history.

Example

output_hist = model.get_output('alpha', to_deg=True)

plot_output(output_name, time, lang='rus', to_deg=False, to_rad=False, figsize=(10, 10))

Plot output signal.

Parameters:

Name Type Description Default
output_name str

Output signal name.

required
time ndarray

Time array.

required
lang str

Label language ('rus' or 'eng'). Defaults to "rus".

'rus'
to_deg bool

Convert to degrees. Defaults to False.

False
to_rad bool

Convert to radians. Defaults to False.

False
figsize tuple

Figure size. Defaults to (10, 10).

(10, 10)

Returns:

Name Type Description
Figure Figure

Matplotlib figure object.

Raises:

Type Description
Exception

If both to_rad and to_deg are specified, or if output_name is invalid.

Example

fig = model.plot_output('alpha', time_array, lang='rus', to_deg=True)

LinearLongitudinalMissileModel(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 MissileModel in Gym 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 linear missile model 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.