Typical Rocket — Longitudinal Dynamics¶
Canonical missile model in the longitudinal channel. The page mirrors the ELV layout: quick start, math model, derivative tables, and API.
-
Quick start
Launch the environment or the model within minutes.
-
Model API
Python class documentation for the typical rocket.
-
Gymnasium environment
Ready environment for RL agents.
-
Theory
State equations and numerical parameters.
Control object structure¶
The model is defined in the state space:
where:
The typical matrix structure is:
- u: longitudinal speed, m/s
- w: vertical speed, m/s
- q: pitch rate, rad/s
- θ: pitch angle, rad
- η: stabilizer control deflection, rad
- x_u, x_w, x_q, x_θ — partial derivatives of longitudinal force \(X\) with respect to \(u, w, q, \theta\)
- z_u, z_w, z_q, z_θ — partial derivatives of normal force \(Z\)
- m_u, m_w, m_q, m_θ — partial derivatives of pitch moment \(M\)
- x_η, z_η, m_η — derivatives with respect to the control \(\eta\)
Units
Angles and angular rates are in radians. API methods can return values in degrees.
Mathematical model¶
Numerical matrices (example linearization):
Derivatives (numerical values)¶
- Matrix A (derivatives):
| Coefficient | Value |
|---|---|
| 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 |
- Input η (column B):
| Coefficient | Value |
|---|---|
| x_η | 9.748 |
| z_η | 3.77 |
| m_η | -0.034 |
| θ_η | 0.01 |
Actuator limits
The default control limits are:
- Maximum magnitude: \(\pm 25^\circ\)
- Maximum rate: \(60^\circ/\text{s\)
Internal computations use radians; the limits are converted accordingly.
Sources¶
- 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). Link
Reward¶
The default reward function returns the negative absolute tracking error for the pitch angle:
Higher reward (closer to 0) indicates better tracking performance. A custom reward function can be passed via the reward_func parameter.
Quick start¶
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. |
