Expand description
Flight-control core for the Stable Flight controller: the pipeline traits (Commander,
StateSource + Actuator = Vehicle, Guidance, Stabilizer, Mixer,
TelemetryPublisher), the data passed between them, copter guidance, the cascaded-PID
stabilizers, the mixers, and FlightLoop, which sequences one control tick.
This crate is no_std and has no simulator, I/O, or timing dependencies, so the same code
runs in software-in-the-loop simulation
(stable-flight-sitl) and, later, on flight
hardware. See the
architecture overview.
Re-exports§
pub use view::View;pub use estimation::wind::WindEstimate;pub use nalgebra;
Modules§
- commanders
- Hardware-independent
Commanderimplementations. - composition
- Combinators that build one pipeline component out of several.
- controllers
- Flight Control Controllers
- estimation
- Estimates built from the vehicle state, beyond what the backend reports:
wind. - flight_
loop - One control-loop tick, independent of how ticks are scheduled.
- guidance
- Outer-loop
Guidanceimplementations, which turn commands into the setpoints aStabilizertracks, and their building blocks (vtol’s transition state machine). - mixers
- Provides functionality to translate generalized control outputs (thrust and moments) into specific actuator commands tailored to the vehicle configuration.
- params
- A flat name →
f32view over the config tree, for live tuning from a ground station. - stabilizers
- Inner-loop control: track a
Setpointfrom guidance against vehicle state feedback. - testing
- Test doubles for the pipeline traits. Enabled by the
testingfeature (and in this crate’s own tests); off by default. - timing
- Fixed-rate scheduling driven by the flight loop’s
dt, for streams (telemetry, heartbeats) that run slower than the loop. - tuning
- PID autotune: measure a loop, turn the measurement into gains, and run it per loop.
- view
View: runs aGuidanceorStabilizerin a body frame rotated by a constant, so a tailsitter hovers nose up on the copter controllers.
Macros§
- conformance_
tests - Generates a backend’s conformance tests: one
#[test]per listed scenario, plusconformance_covers_every_scenario, which fails if any scenario inSCENARIOShas no test.
Structs§
- Absolute
Attitude Command - An absolute attitude and collective thrust, for
ControlInput::AbsoluteAttitude: what an offboard app (e.g. MAVLinkSET_ATTITUDE_TARGET) asks for, as opposed to the normalized stick positions of anAttitudeCommand. - Absolute
Rate Command - Absolute body rates and collective thrust, for
ControlInput::AbsoluteRate: what a maneuver or an offboard app (e.g. MAVLinkSET_ATTITUDE_TARGETbody rates) asks for, as opposed to the stick fractions of aRateCommand. - Actuator
Command - One tick’s actuator outputs: motors and servos, as generic slots.
- Attitude
Command - Represents direct manual control of an aircraft’s attitude (orientation).
- Attitude
Setpoint - Attitude target for the
Stabilizer; seeSetpoint. - Blend
Setpoint - A hover and a wing-borne target flown together, for
Setpoint::Blend: a lift+cruise VTOL (quadplane) in transition, its lift rotors flyinghoverand its surfaces and pusher flyingplane. - Body
Rate Setpoint - Absolute body-rate target, for
Setpoint::BodyRate(copter) andSetpoint::PlaneRate(plane). The stabilizer saturates each rate to its limit (NaN as zero). - Command
- One tick’s command from a
Commander: whether the vehicle should be armed, whichFlightRegimeto fly in, and what to fly. - Composed
Vehicle - A
Vehiclemade of a separate state source and actuator. - Control
Output - Represents the high-level control outputs from the stabilization system.
- Cruise
Output - A lift+cruise VTOL’s cruise output (
ControlOutput::cruise): what its pusher and control surfaces fly while the lift rotors flyControlOutput::thrustandControlOutput::moments. - Flight
Loop - Sequences one control tick: commander → estimate → guide → stabilize → mix → actuate → telemetry.
- Flight
Mode Report - The flight mode guidance is flying, and why it isn’t the requested regime when it can’t
be. From
Guidance::flight_mode(orcopter_only);FlightLoopputs it inTelemetryRecord::flight_mode. - Land
Command - Where to land, for
ControlInput::Land: guidance holdsposition_mwhile it descends. - Plane
Setpoint - Wing-borne attitude target for a plane stabilizer, for
Setpoint::Plane, in the frame contract’s body frame (a tailsitter’s airplane frame). Turns are coordinated, so there is no heading: the stabilizer derives the yaw rate from bank and airspeed. The stabilizer saturates roll and pitch to its limits; NaN means level. - Rate
Command - Represents direct manual control of an aircraft’s rotational rates.
- Rate
Setpoint - Body-rate target for the
Stabilizer; seeSetpoint. - Saturation
- Which limits the pipeline hit on one tick, as reported by
Guidance::saturation,Stabilizer::saturation, andMixer::saturation, merged byFlightLoopintoTelemetryRecord::saturation. - Telemetry
Record - One control-loop tick, as handed to a
TelemetryPublisher. - Vehicle
State - Represents the physical state of a vehicle in 3D space.
- Waypoint
Command - Represents a navigational waypoint for autonomous flight.
Enums§
- Control
Input - The control input part of a
Command: what the flight system should fly. - Control
Mode - The kind of a
ControlInput, one variant per input variant: the flight mode, compact enough for a heartbeat. FromControlInput::mode. - Failsafe
State - Which commander a
FailsafeCommanderlet fly: its link-fed primary, or the fallback after the link went stale. - Flight
Mode - The regime guidance is actually flying, including the transitions between regimes. Owned
by
Guidanceand reported in aFlightModeReport. - Flight
Regime - How the vehicle flies: hovering on its rotors, or wing-borne. Requested by a
Command; what is actually flown, including transitions, is aFlightMode. - Mode
Refusal - Why guidance isn’t flying, or stopped moving toward, the requested
FlightRegime. - Setpoint
- What the
Stabilizershould hold this tick, as produced by aGuidance.
Constants§
- GRAVITY
- Standard gravity, in m/s².
Traits§
- Actuator
- Component responsible for controlling the vehicle’s actuators.
- Commander
- Represents an entity that produces flight control commands.
- Configurable
- A pipeline component whose gains and limits can be read and replaced between ticks.
- Guidance
- Turns the commander’s
ControlInputinto an inner-loopSetpoint, in the requestedFlightRegime. - Mixer
- Component responsible for converting control outputs to actuator commands.
- Stabilizer
- Component responsible for flight control and stabilization: the inner loop.
- State
Source - Where the flight loop’s vehicle state comes from.
- Telemetry
Publisher - Component responsible for publishing telemetry data from the flight system.
- Vehicle
- Represents a physical vehicle that can be controlled by the flight system.
Functions§
- euler_
angles - ZYX Euler angles
(roll, pitch, yaw)in radians of an attitude quaternion, in the frame contract’s convention (the same asUnitQuaternion::euler_angles). Use this rather than nalgebra’s method to read Euler angles fromVehicleState::attitude. - wrap_
angle - Wraps an angle in radians to [-π, π); non-finite input gives NaN.