Skip to content

Signal types

from nexus_uav import SimTime, PoseTwist, PositionGoal, Waypoints, ReferenceTrajectory
from nexus_uav import ImuSample, MagSample, BaroSample, GpsSample, Image, PointCloud

A signal carries one of these types between components, and a component's stage declares its signals with them: Signal("estimate", PoseTwist, shape=(1,)). A Warp struct lives on the device, and a host stage reads it as an instance of its type, read().accel. The controls a controller writes are a plain device row of wp.float32, one per actuator, so they have no type here.

SimTime dataclass

SimTime(time_ns: int = 0, step_index: int = 0)

Sim-time and step index for the current tick.

The single authoritative time source for HIL_* MAVLink timestamps and the sensors' due times, so every component shares one consistent clock derived from the simulation. The time is a whole number of nanoseconds, as gz-sim keeps it, so a time that falls on a tick compares exactly; a stage reads it in seconds.

time_ns class-attribute instance-attribute

time_ns: int = 0

Elapsed simulation time since reset, in whole nanoseconds.

step_index class-attribute instance-attribute

step_index: int = 0

Zero-based index of the current simulation step (integer tick counter).

sim_time property

sim_time: float

Elapsed simulation time since reset, in seconds.

time_usec property

time_usec: int

Simulation time in integer microseconds, the HIL_* timestamp unit.

PoseTwist

The pose and twist of one body in world axes: what the plant writes per body, as the signal body/<label> of shape (1,), and the estimate an estimator writes, as the signal estimate, which the guidance and the controllers read.

position instance-attribute

position: vec3

The body's origin, metres.

orientation instance-attribute

orientation: quat

The body's orientation, a quaternion in (x, y, z, w) order.

linear_velocity instance-attribute

linear_velocity: vec3

The velocity of the body's center of mass, m/s.

angular_velocity instance-attribute

angular_velocity: vec3

The body's angular velocity, rad/s.

PositionGoal dataclass

PositionGoal(
    pos: tuple[float, float, float],
    yaw: float | None = None,
)

A single move-to / hold goal in the world frame, Newton FLU / Z-up. Consumed by the state-feedback controllers, policy and pid: the guidance feeds one PositionGoal at a time and sequences a mission by advancing it on arrival; the controller is goal-relative, so each is a fresh single-goal problem. yaw is the optional heading [rad]; None = don't command yaw.

The signal setpoint carries it on the device as one wp.vec3 of the position, since no controller reads yaw.

pos instance-attribute

pos: tuple[float, float, float]

yaw class-attribute instance-attribute

yaw: float | None = None

Waypoints dataclass

Waypoints(
    points: list[tuple[float, float, float]] = list(),
)

An ordered list of world-frame positions the controller holds and advances internally. Distinct from a mission the guidance sequences with PositionGoal: here the whole path is the setpoint.

points class-attribute instance-attribute

points: list[tuple[float, float, float]] = field(
    default_factory=list
)

ReferenceTrajectory dataclass

ReferenceTrajectory(reference: Any = None)

A full flat-state reference over time, for the acados NMPC: the guidance plans it, ruckig → differential-flatness, from waypoints and feeds it to the controller, which tracks it. The payload is a queryable reference object, for example the guidance's FlatnessReference, the controller samples per horizon node, kept opaque here so core imports no controller backend.

reference class-attribute instance-attribute

reference: Any = None

ImuSample

The sample of an Inertial Measurement Unit (IMU), in the axes of its mount: body Forward Right Down (FRD) on an unturned mount. The signal imu carries it, of shape (1,).

time instance-attribute

time: float64

The sim time of the sample, seconds.

accel instance-attribute

accel: vec3

The specific force, m/s^2.

gyro instance-attribute

gyro: vec3

The angular rate, rad/s.

MagSample

A magnetometer's sample, in body Forward Right Down (FRD) axes. The signal mag carries it, of shape (1,).

time instance-attribute

time: float64

The sim time of the sample, seconds.

field instance-attribute

field: vec3

The magnetic field, gauss.

BaroSample

A barometer's sample. The signal baro carries it, of shape (1,).

time instance-attribute

time: float64

The sim time of the sample, seconds.

pressure instance-attribute

pressure: float32

The static pressure, hPa.

altitude instance-attribute

altitude: float32

The pressure altitude, metres.

temperature instance-attribute

temperature: float32

The sensor's temperature, degrees Celsius.

GpsSample

A Global Positioning System (GPS) receiver's sample, on WGS84. The signal gps carries it, of shape (1,). Latitude, longitude and altitude are 64-bit: a 32-bit latitude loses about a metre.

time instance-attribute

time: float64

The sim time of the sample, seconds.

lat instance-attribute

lat: float64

The latitude, degrees.

lon instance-attribute

lon: float64

The longitude, degrees.

alt instance-attribute

alt: float64

The altitude over mean sea level, metres.

velocity instance-attribute

velocity: vec3

The velocity in North East Down (NED) axes, m/s.

ground_speed instance-attribute

ground_speed: float32

The horizontal speed, m/s.

fix_type instance-attribute

fix_type: int32

The fix, as MAVLink's GPS_FIX_TYPE numbers it: 3 is a 3D fix.

Image dataclass

Image(time: float, pixels: ndarray)

A camera's frame, the host signal a camera writes when a frame arrives.

time instance-attribute

time: float

The sim time the frame shows, seconds.

pixels instance-attribute

pixels: ndarray

The image, (height, width, 3) 8-bit RGB.

PointCloud dataclass

PointCloud(time: float, points: ndarray)

A lidar's scan, the host signal a lidar writes when a scan arrives.

time instance-attribute

time: float

The sim time the scan shows, seconds.

points instance-attribute

points: ndarray

The points, (n, 3), in the frame the Kit peer sends: world axes.