pub struct GuidedSetpoint {}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: SetpointKindWhich message (local vs global) to build.
coordinate_frame: u8The coordinate frame (MAV_FRAME_*). Validated against the small set of
frames that are meaningful for the chosen message kind.
type_mask: u16The 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: f64Position: 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: f32Velocity m/s in the chosen frame.
vy: f32§vz: f32§afx: f32Acceleration / force m/s^2 (or N when the force bit is set) in the frame.
afy: f32§afz: f32§yaw: f32Yaw setpoint (rad) and yaw rate (rad/s).
yaw_rate: f32Implementations§
Source§impl GuidedSetpoint
impl GuidedSetpoint
Sourcepub fn validate(&self) -> Result<(), SetpointError>
pub fn validate(&self) -> Result<(), SetpointError>
Validate the setpoint, returning the first problem found. Checks:
- the
type_maskcarries 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.
Sourcepub fn build_message(
&self,
target_system: u8,
target_component: u8,
) -> Result<MavMessage, SetpointError>
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).