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).
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.
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.
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.
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,).
MagSample
¶
BaroSample
¶
A barometer's sample. The signal baro carries it, of shape (1,).
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.
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)
PointCloud
dataclass
¶
PointCloud(time: float, points: ndarray)