Skip to content

Ultrastick‑25e — Longitudinal Dynamics

The Ultrastick‑25e UAV is a lightweight experimental platform. This page mirrors the ELV layout: quick start, math model, derivatives, and API.

  • Quick start

    Launch the environment or the model within minutes.

    See example

  • Model API

    Python class documentation for the Ultrastick.

    Go to API

  • Gymnasium environment

    Ready environment for RL agents.

    Explore

  • Theory

    State equations and numerical parameters.

    Learn more

Control object structure

The model is defined in the state space:

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

where:

\[ x = \begin{bmatrix} u & w & \theta & q & h \end{bmatrix}^{\top}, \quad u_{in} = \begin{bmatrix} \eta & \delta_t \end{bmatrix}^{\top} \]
  • u: longitudinal speed, m/s
  • w: vertical speed, m/s
  • θ: pitch angle, rad
  • q: pitch rate, rad/s
  • h: altitude, m
  • η: stabilizer deflection, rad
  • δ_t: throttle deflection, rad

Units

Angles and angular rates are in radians. API methods can expose values in degrees.

Mathematical model

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

Numerical matrices (example linearization):

\[ \begin{bmatrix} \dot{u} \\ \dot{w} \\ \dot{\theta} \\ \dot{q} \\ \dot{h} \end{bmatrix} = \begin{bmatrix} -0.5944 & 0.8008 & -9.791 & -0.8747 & 5.077\times 10^{-5} \\ -0.744 & -7.56 & -0.5294 & 15.72 & -0.000939 \\ 0 & 0 & 0 & 1 & 0 \\ 1.041 & -7.406 & 0 & -15.81 & -7.284\times 10^{-18} \\ -0.05399 & 0.9985 & -17 & 0 & 0 \end{bmatrix} \begin{bmatrix} u \\ w \\ \theta \\ q \\ h \end{bmatrix} + \begin{bmatrix} 0.4669 & 0 \\ -2.703 & 0 \\ 0 & 0 \\ -133.7 & 0 \\ 0 & 0 \end{bmatrix} \begin{bmatrix} \eta \\ \delta_t \end{bmatrix} \]

Key derivatives

  • \(\dot{\theta} = q\) (element A[3,4] = 1)
  • Influence of \(\eta\) on \(\dot{q}\): A[4,*], B[4,1] = −133.7
  • Influence of \(\eta\) on \(\dot{u}\), \(\dot{w}\): B[1,1] = 0.4669, B[2,1] = −2.703

Sources

  1. Ahmed EA, Hafez A, Ouda AN, Ahmed HEH, Abd‑Elkader HM. Modelling of a Small Unmanned Aerial Vehicle. Adv Robot Autom 4:126, 2015.

Reward

The default reward function returns the negative absolute tracking error for the pitch angle:

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

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 LinearLongitudinalUltrastick
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(
    'LinearLongitudinalUltrastick-v0',
    number_time_steps=number_time_steps, 
    initial_state=[[0],[0],[0],[0],[0]],
    reference_signal=reference_signals,
)
state, info = env.reset()
for _ in range(200):
    action = np.array([[1.0, 0.1]])  # [η, δ_t]
    state, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        break
import numpy as np
from tensoraerospace.aerospacemodel import Ultrastick

dt = 0.01
number_time_steps = 200

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

model = Ultrastick(
    x0=x0,
    number_time_steps=number_time_steps,
    selected_state_output=["u", "w", "q", "theta", "h"],
    dt=dt,
)

for t in range(number_time_steps - 1):
    u = np.array([1.0, 0.1])  # [η, δ_t]
    x_next = model.run_step(u)

Python API

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

Bases: ModelBase

UAV Ultrastick-25e 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] delta_t: Dimensionless value, 0 — off, 1 — max thrust

State space

u: Longitudinal aircraft velocity [m/s] w: Normal aircraft velocity [m/s] q: Pitch angular velocity [rad/s] theta: Pitch [rad] h: Altitude [m]

Output space

u: Longitudinal aircraft velocity [m/s] w: Normal aircraft velocity [m/s] q: Pitch angular velocity [rad/s] theta: Pitch [rad] h: Altitude [m]

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: System output at the current step (via C/D).

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').

'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.

LinearLongitudinalUltrastick(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 Ultrastick-25e in 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 legacy Ultrastick environment.

reward(state, ref_signal, ts) 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.

step(action)

Execute simulation step.

Parameters:

Name Type Description Default
action ndarray

Control signal array for selected actuators.

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 options for initialization.

None

render()

Visual display of actions in environment (not implemented).