Skip to main content

AttitudeSetpoint

Struct AttitudeSetpoint 

Source
pub struct AttitudeSetpoint {
    pub type_mask: u8,
    pub q: [f32; 4],
    pub body_roll_rate: f32,
    pub body_pitch_rate: f32,
    pub body_yaw_rate: f32,
    pub thrust: f32,
}
Expand description

A single SET_ATTITUDE_TARGET payload, frame-independent.

This is a transport-agnostic data value, NOT a controller: building one and sending it is one fire-and-forget MAVLink frame. It owns no flight state, mode, or schedule — the caller owns the policy around it (the autopilot accepts these only in its attitude/offboard mode, and a command stream is a heartbeat the caller must re-send well above the decay rate). The builder validates that every field the type_mask does NOT ignore is finite, that a commanded attitude is a unit quaternion, and that a commanded thrust is within the normalized range, so a NaN / out-of-range command can never reach the wire on an active axis.

Fields§

§type_mask: u8

The type_mask ignore bits (ATTITUDE_TARGET_TYPEMASK_*). A set bit ignores that axis. The high bits above the defined field are rejected so a malformed mask cannot smuggle unknown semantics to the autopilot.

§q: [f32; 4]

Attitude quaternion (w, x, y, z), MAVLink order; zero rotation is (1, 0, 0, 0). Meaningful only while ATTITUDE_IGNORE is clear.

§body_roll_rate: f32

Body roll rate, rad/s. Ignored when BODY_ROLL_RATE_IGNORE is set.

§body_pitch_rate: f32

Body pitch rate, rad/s. Ignored when BODY_PITCH_RATE_IGNORE is set.

§body_yaw_rate: f32

Body yaw rate, rad/s. Ignored when BODY_YAW_RATE_IGNORE is set.

§thrust: f32

Collective thrust, normalized 0..1 (-1..1 for reverse-thrust vehicles). Ignored when THROTTLE_IGNORE is set.

Implementations§

Source§

impl AttitudeSetpoint

Source

pub fn validate(&self) -> Result<(), SetpointError>

Validate the setpoint, returning the first problem found. Mirrors GuidedSetpoint::validate so an out-of-range command is refused at construction:

  • the type_mask carries no bit outside the defined field, and
  • every numeric field on an axis the mask does NOT ignore is finite, and
  • a commanded attitude is a unit quaternion, and
  • a commanded thrust is within the normalized -1..=1 range.

An ignored axis is not checked (the autopilot disregards it), so a pure body-rate command with a NaN left in the (ignored) quaternion is accepted — but a NaN or out-of-range value on an active axis is rejected.

Source

pub fn build_message( &self, target_system: u8, target_component: u8, ) -> Result<MavMessage, SetpointError>

Validate, then build the typed MavMessage for this setpoint. The target_system / target_component address the vehicle; time_boot_ms is fixed at 0 (the autopilot does not require a monotonic stamp on an attitude setpoint; ArduPilot ignores it on the inbound path). The actual X.25 CRC is folded with ATTITUDE_TARGET_CRC_EXTRA (49) by the typed serializer, identical to what this builder’s own encoder would emit.

Trait Implementations§

Source§

impl Clone for AttitudeSetpoint

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AttitudeSetpoint

Source§

impl Debug for AttitudeSetpoint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AttitudeSetpoint

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AttitudeSetpoint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more