Skip to main content

GuidedSetpoint

Struct GuidedSetpoint 

Source
pub struct GuidedSetpoint {
Show 14 fields pub kind: SetpointKind, pub coordinate_frame: u8, pub type_mask: u16, pub x: f64, pub y: f64, pub z: f64, pub vx: f32, pub vy: f32, pub vz: f32, pub afx: f32, pub afy: f32, pub afz: f32, pub yaw: f32, pub yaw_rate: f32,
}
Expand description

A single guided-mode setpoint to send to the autopilot.

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 is responsible for the policy around it:

  • The autopilot accepts these only while it is in its guided/offboard mode; the caller must put the vehicle there and confirm it. Building a setpoint does not change the mode and does not check it.
  • A guided setpoint stream is a heartbeat: most autopilots brake (and then fail-safe, e.g. RTL) roughly three seconds after the last setpoint, so the caller must re-send at well above that rate (about 3 Hz or faster) to hold a commanded velocity. One frame on its own decays.

The *_value numeric fields are interpreted only where the corresponding type_mask ignore bit is clear; an ignored axis still serializes (as its stored value) but the autopilot disregards it. The builder validates that every field that the mask does NOT ignore is finite, so a NaN/inf can never reach the wire on an active axis.

Fields§

§kind: SetpointKind

Which message (local vs global) to build.

§coordinate_frame: u8

The coordinate frame (MAV_FRAME_*). Validated against the small set of frames that are meaningful for the chosen message kind.

§type_mask: u16

The type_mask ignore bits (POSITION_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.

§x: f64

Position: x/y/z metres for SetpointKind::LocalNed. For SetpointKind::GlobalInt the x field carries the latitude and y the longitude, both already scaled by 1e7 (the wire integer); z is the altitude in metres. The builder maps them to the correct wire fields.

§y: f64§z: f64§vx: f32

Velocity m/s in the chosen frame.

§vy: f32§vz: f32§afx: f32

Acceleration / force m/s^2 (or N when the force bit is set) in the frame.

§afy: f32§afz: f32§yaw: f32

Yaw setpoint (rad) and yaw rate (rad/s).

§yaw_rate: f32

Implementations§

Source§

impl GuidedSetpoint

Source

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

Validate the setpoint, returning the first problem found. Checks:

  • the type_mask carries no bit outside the defined field, and
  • the coordinate frame is one of the frames meaningful for the message kind (local frames for the local message, global frames for the global message), and
  • every numeric field on an axis the mask does NOT ignore is finite.

An ignored axis is not range-checked (the autopilot disregards it), so a pure-velocity setpoint with a NaN left in an ignored position field is accepted — but a NaN 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; the global integer fields are clamped from the f64 inputs into i32 range so an out-of-range coordinate saturates rather than wrapping. The time_boot_ms is fixed at 0 (the autopilot does not require a monotonic stamp on a setpoint; ArduPilot ignores it on the inbound path).

Trait Implementations§

Source§

impl Clone for GuidedSetpoint

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 GuidedSetpoint

Source§

impl Debug for GuidedSetpoint

Source§

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

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

impl PartialEq for GuidedSetpoint

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 GuidedSetpoint

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