pub struct WaypointCommand {
pub position_m: Vec2,
pub velocity_mps: Option<Vec2>,
pub altitude_m: f32,
pub cruise_speed_mps: f32,
pub heading_rad: Option<f32>,
}Expand description
Represents a navigational waypoint for autonomous flight.
A WaypointCommand instructs the aircraft to navigate to a specific position
in 2D space at a given altitude, at up to a cruise speed, optionally flying through it
with a given velocity. This struct is
typically used within a ControlInput::Waypoint variant to issue autonomous navigation
commands to the flight system.
§Value Ranges
position_m: X, Y coordinates in 2D space (units and coordinate system depend on the flight system, typically meters in world coordinates)velocity_mps: Optional velocity vector in meters per second (north, east), fed forward while flying to the waypointaltitude_m: Target altitude in meters (typically non-negative; negative values may be interpreted as ground level or cause undefined behavior)cruise_speed_mps: Speed cap in meters per second while flying to the waypoint; zero, negative, or NaN means no capheading_rad: Optional heading in radians from north; any angle, wrapped by guidance
Note: The specified ranges are conventional and recommended for typical use. Values outside these ranges may be clamped, ignored, or cause undefined behavior depending on the flight system’s implementation.
§Examples
Creating a WaypointCommand to navigate to a position with a specific altitude and speed:
use stable_flight::{Vec2, WaypointCommand};
let cmd = WaypointCommand {
position_m: Vec2::new(1000.0, 2000.0), // Target position (X=1000m, Y=2000m)
velocity_mps: Some(Vec2::new(15.0, 0.0)), // Fly through it northward at 15 m/s
altitude_m: 500.0, // Target altitude of 500 meters
cruise_speed_mps: 25.0, // At most 25 m/s on the way
heading_rad: Some(0.5), // Face 0.5 rad east of north
};§Behavior of Optional Fields
- If
velocity_mpsisNone, the aircraft stops on the waypoint.WaypointFollowerfills it in along each leg so a route is flown at cruise speed.
§Default Implementation
The Default trait is implemented for WaypointCommand, providing the following
default values:
position_m: zerovelocity_mps:Nonealtitude_m:0.0cruise_speed_mps:0.0heading_rad:None
Fields§
§position_m: Vec2The target position in 2D space (X, Y coordinates).
The coordinate system and units depend on the flight system implementation (typically meters in world coordinates).
velocity_mps: Option<Vec2>Optional velocity, in meters per second (north, east), to fly through the waypoint with.
Guidance feeds it forward while flying to the waypoint (added to the position loop’s
demand, then capped at cruise_speed_mps), so the aircraft passes the waypoint
instead of stopping on it. None stops on the waypoint.
WaypointFollower fills it in along each leg
when it’s None.
altitude_m: f32Target altitude in meters.
Typically non-negative; negative values may be interpreted as ground level or cause undefined behavior depending on the flight system.
cruise_speed_mps: f32Cruise speed in meters per second: the most guidance asks for while flying to the waypoint. Zero, negative, or NaN means no cap (the guidance’s tilt limit still bounds the speed).
heading_rad: Option<f32>Optional heading to hold, in radians from north.
Copter guidance turns its heading-hold target to it at
heading_rate_radps,
instead of along the leg, and never yields it; on a tailsitter it is the hover frame’s
heading, the direction the belly faces. None (or NaN) leaves the heading to guidance.
Plane guidance ignores it.
Trait Implementations§
Source§impl Clone for WaypointCommand
impl Clone for WaypointCommand
impl Copy for WaypointCommand
Source§impl Debug for WaypointCommand
impl Debug for WaypointCommand
Source§impl Default for WaypointCommand
impl Default for WaypointCommand
Source§impl<'de> Deserialize<'de> for WaypointCommand
impl<'de> Deserialize<'de> for WaypointCommand
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for WaypointCommand
impl PartialEq for WaypointCommand
Source§impl Serialize for WaypointCommand
impl Serialize for WaypointCommand
impl StructuralPartialEq for WaypointCommand
Auto Trait Implementations§
impl Freeze for WaypointCommand
impl RefUnwindSafe for WaypointCommand
impl Send for WaypointCommand
impl Sync for WaypointCommand
impl Unpin for WaypointCommand
impl UnsafeUnpin for WaypointCommand
impl UnwindSafe for WaypointCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.