Skip to main content

Crate stable_flight

Crate stable_flight 

Source
Expand description

github crates-io license


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 nalgebra;

Modules§

commanders
Hardware-independent Commander implementations.
composition
Combinators that build one pipeline component out of several.
controllers
Flight Control Controllers
flight_loop
One control-loop tick, independent of how ticks are scheduled.
guidance
Outer-loop Guidance implementations: turn commands into the setpoints a Stabilizer tracks.
mixers
Provides functionality to translate generalized control outputs (thrust and moments) into specific actuator commands tailored to the vehicle configuration.
params
A flat name → f32 view over the config tree, for live tuning from a ground station.
stabilizers
Inner-loop control: track a Setpoint from guidance against vehicle state feedback.
testing
Test doubles for the pipeline traits. Enabled by the testing feature (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.

Macros§

conformance_tests
Generates a backend’s conformance tests: one #[test] per listed scenario, plus conformance_covers_every_scenario, which fails if any scenario in SCENARIOS has no test.

Structs§

AbsoluteAttitudeCommand
An absolute attitude and collective thrust, for ControlInput::AbsoluteAttitude: what an offboard app (e.g. MAVLink SET_ATTITUDE_TARGET) asks for, as opposed to the normalized stick positions of an AttitudeCommand.
ActuatorCommand
One tick’s actuator outputs: motors and servos, as generic slots.
AttitudeCommand
Represents direct manual control of an aircraft’s attitude (orientation).
AttitudeSetpoint
Attitude target for the Stabilizer; see Setpoint.
Command
One tick’s command from a Commander: whether the vehicle should be armed, and what to fly.
ComposedVehicle
A Vehicle made of a separate state source and actuator.
ControlOutput
Represents the high-level control outputs from the stabilization system.
FlightLoop
Sequences one control tick: commander → estimate → guide → stabilize → mix → actuate → telemetry.
LandCommand
Where to land, for ControlInput::Land: guidance holds position_m while it descends.
RateCommand
Represents direct manual control of an aircraft’s rotational rates.
RateSetpoint
Body-rate target for the Stabilizer; see Setpoint.
Saturation
Which limits the pipeline hit on one tick, as reported by Guidance::saturation, Stabilizer::saturation, and Mixer::saturation, merged by FlightLoop into TelemetryRecord::saturation.
TelemetryRecord
One control-loop tick, as handed to a TelemetryPublisher.
VehicleState
Represents the physical state of a vehicle in 3D space.
WaypointCommand
Represents a navigational waypoint for autonomous flight.

Enums§

ControlInput
The control input part of a Command: what the flight system should fly.
ControlMode
The kind of a ControlInput, one variant per input variant: the flight mode, compact enough for a heartbeat. From ControlInput::mode.
FailsafeState
Which commander a FailsafeCommander let fly: its link-fed primary, or the fallback after the link went stale.
Setpoint
What the Stabilizer should hold this tick, as produced by a Guidance.

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 ControlInput into an inner-loop Setpoint.
Mixer
Component responsible for converting control outputs to actuator commands.
Stabilizer
Component responsible for flight control and stabilization: the inner loop.
StateSource
Where the flight loop’s vehicle state comes from.
TelemetryPublisher
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 as UnitQuaternion::euler_angles). Use this rather than nalgebra’s method to read Euler angles from VehicleState::attitude.
wrap_angle
Wraps an angle in radians to [-π, π); non-finite input gives NaN.

Type Aliases§

Vec2
2D vector used throughout the pipeline (waypoint positions, tilt, controller limits).
Vec3
3D vector used throughout the pipeline (state vectors, moments, rates). Element-wise products are component_mul; * between two vectors is a matrix product.