#[non_exhaustive]pub enum ControlInput {
Attitude(AttitudeCommand),
Rate(RateCommand),
Waypoint(WaypointCommand),
AbsoluteAttitude(AbsoluteAttitudeCommand),
Land(LandCommand),
AbsoluteRate(AbsoluteRateCommand),
}Expand description
The control input part of a Command: what the flight system should fly.
The ControlInput enum encapsulates different types of commands that can be issued
to control an aircraft:
Manual- Low-level direct control inputs typically generated from user input devices. This includes:Attitude: Controls the aircraft’s orientation (roll, pitch, yaw).Rate: Controls the aircraft’s rotational rates (rate of change of roll, pitch, yaw).
AbsoluteAttitude- An absolute roll, pitch, and heading with collective thrust, from an offboard app (e.g. MAVLinkSET_ATTITUDE_TARGET).AbsoluteRate- Absolute body rates with collective thrust, from an offboard app or a maneuver script.Waypoint- High-level navigational commands used for autonomous flight.Land- Descend in place until touchdown.
This separation allows the flight control system to handle both manual piloting and automated navigation with a unified command interface.
§Examples
Creating a manual attitude command:
use stable_flight::{ControlInput, AttitudeCommand};
let manual_cmd = ControlInput::Attitude(AttitudeCommand {
throttle: 0.75, // 75% throttle
roll: 0.1, // Slight right bank
pitch: -0.05, // Slight nose down
yaw: 0.0, // No yaw input
..Default::default()
});Creating a manual rate command:
use stable_flight::{ControlInput, RateCommand};
let rate_cmd = ControlInput::Rate(RateCommand {
throttle: 0.5, // 50% throttle
roll_rate: 0.2, // Moderate roll rate
pitch_rate: 0.1, // Moderate pitch rate
yaw_rate: 0.0, // No yaw rate
..Default::default()
});Creating a waypoint command:
use stable_flight::{ControlInput, Vec2, WaypointCommand};
let waypoint_cmd = ControlInput::Waypoint(WaypointCommand {
position_m: Vec2::new(1000.0, 2000.0), // Target position in world coordinates
velocity_mps: Some(Vec2::new(15.0, 0.0)), // Optional velocity to fly through it with
altitude_m: 500.0, // Target altitude in meters
cruise_speed_mps: 25.0, // Speed cap on the way
heading_rad: None, // Heading as guidance picks it
});§Notes
- A
WaypointCommandwithvelocity_mps: Nonestops on the waypoint. #[non_exhaustive]: new command kinds (e.g. fixed-wing) can be added without a breaking change. AGuidancethat can’t fly a variant must fall back to neutral, not panic (seeGuidance::guide).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Attitude(AttitudeCommand)
Direct manual control inputs for the aircraft’s attitude (orientation).
These values typically range from -1.0 to 1.0 (or 0.0 to 1.0 for throttle) and directly influence the aircraft’s roll, pitch, and yaw orientation. The ranges are conventional and may not be enforced by the system.
Rate(RateCommand)
Direct manual control inputs for the aircraft’s rotational rate.
These values typically range from -1.0 to 1.0 (or 0.0 to 1.0 for throttle) and directly influence the rate of change of roll, pitch, and yaw. The ranges are conventional and may not be enforced by the system.
Waypoint(WaypointCommand)
Autonomous navigation command specifying a destination point.
This command provides high-level navigational instructions that are translated into appropriate control surface and throttle settings by the flight controller.
AbsoluteAttitude(AbsoluteAttitudeCommand)
An absolute attitude in radians and collective thrust, typically from an offboard app.
Unlike ControlInput::Attitude, the angles are not stick positions: roll and pitch
are flown as given (the stabilizer saturates them to its maximum tilt), and the heading
is an angle, not a rate.
Land(LandCommand)
Hold a horizontal position and descend at a steady rate until the ground stops the
vehicle. Guidance only descends; deciding it has touched down and disarming is the
commander’s job (TouchdownDetector).
AbsoluteRate(AbsoluteRateCommand)
Absolute body rates in rad/s and collective thrust, typically from an offboard app or a
maneuver script (a flip, a roll, a loop). Unlike ControlInput::Rate, the rates are
not stick fractions: they are flown as given, at any attitude.
Implementations§
Source§impl ControlInput
impl ControlInput
Sourcepub fn is_sticks(&self) -> bool
pub fn is_sticks(&self) -> bool
Whether this is pilot stick input (attitude or rate). After a link outage, the failsafe hands an armed vehicle back to sticks only once they move, so a stick left deflected can’t take over unattended. Sticks are also a stream.
§Examples
use stable_flight::ControlInput;
assert!(ControlInput::Attitude(Default::default()).is_sticks());
assert!(ControlInput::Rate(Default::default()).is_sticks());
assert!(!ControlInput::AbsoluteAttitude(Default::default()).is_sticks());
assert!(!ControlInput::Waypoint(Default::default()).is_sticks());
assert!(!ControlInput::Land(Default::default()).is_sticks());Sourcepub fn is_stream(&self) -> bool
pub fn is_stream(&self) -> bool
Whether this input is a stream that must keep arriving to stay valid (sticks and absolute attitudes and rates), unlike a waypoint or a land, which stays valid until replaced. A link-fed commander treats a stream as stale once commands stop, even if other messages arrive.
§Examples
use stable_flight::ControlInput;
assert!(ControlInput::Attitude(Default::default()).is_stream());
assert!(ControlInput::Rate(Default::default()).is_stream());
assert!(ControlInput::AbsoluteAttitude(Default::default()).is_stream());
assert!(ControlInput::AbsoluteRate(Default::default()).is_stream());
assert!(!ControlInput::Waypoint(Default::default()).is_stream());
assert!(!ControlInput::Land(Default::default()).is_stream());Sourcepub fn mode(&self) -> ControlMode
pub fn mode(&self) -> ControlMode
Which kind of input this is, without its values: the flight mode a ground station shows.
§Examples
use stable_flight::{ControlInput, ControlMode};
assert_eq!(ControlInput::Attitude(Default::default()).mode(), ControlMode::Attitude);
assert_eq!(ControlInput::Rate(Default::default()).mode(), ControlMode::Rate);
assert_eq!(ControlInput::Waypoint(Default::default()).mode(), ControlMode::Waypoint);
assert_eq!(
ControlInput::AbsoluteAttitude(Default::default()).mode(),
ControlMode::AbsoluteAttitude,
);
assert_eq!(ControlInput::Land(Default::default()).mode(), ControlMode::Land);
assert_eq!(
ControlInput::AbsoluteRate(Default::default()).mode(),
ControlMode::AbsoluteRate,
);Trait Implementations§
Source§impl Clone for ControlInput
impl Clone for ControlInput
impl Copy for ControlInput
Source§impl Debug for ControlInput
impl Debug for ControlInput
Source§impl Default for ControlInput
Zero-throttle, centered-stick ControlInput::Attitude.
impl Default for ControlInput
Zero-throttle, centered-stick ControlInput::Attitude.
Source§impl<'de> Deserialize<'de> for ControlInput
impl<'de> Deserialize<'de> for ControlInput
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 ControlInput
impl PartialEq for ControlInput
Source§impl Serialize for ControlInput
impl Serialize for ControlInput
impl StructuralPartialEq for ControlInput
Auto Trait Implementations§
impl Forget for ControlInput
impl Freeze for ControlInput
impl Move for ControlInput
impl RefUnwindSafe for ControlInput
impl Send for ControlInput
impl Sync for ControlInput
impl Unpin for ControlInput
impl UnsafeUnpin for ControlInput
impl UnwindSafe for ControlInput
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.