Skip to main content

Stabilizer

Trait Stabilizer 

Source
pub trait Stabilizer {
    // Required method
    fn stabilize(
        &mut self,
        dt: f32,
        setpoint: &Setpoint,
        state: &VehicleState,
    ) -> ControlOutput;

    // Provided methods
    fn prime(&mut self, _state: &VehicleState) { ... }
    fn saturation(&self) -> Saturation { ... }
}
Expand description

Component responsible for flight control and stabilization: the inner loop.

The Stabilizer trait defines the interface for components that implement control algorithms to track a Setpoint from Guidance, producing the thrust and moments that the Mixer turns into actuator commands.

Implementors of this trait may include:

  • PID controllers: Simple feedback control for attitude stability
  • LQR controllers: Optimal control for complex flight dynamics
  • Model predictive controllers: Advanced control with future prediction
  • Cascaded control systems: Hierarchical controllers for different aspects of flight

Required Methods§

Source

fn stabilize( &mut self, dt: f32, setpoint: &Setpoint, state: &VehicleState, ) -> ControlOutput

Generates control outputs based on the current setpoint and vehicle state.

§Parameters
  • dt: Time elapsed since the last control step in seconds. Must be positive and finite; implementations may assert it (runners guarantee it).
  • setpoint: The attitude or rate target to track.
  • state: The current estimated state of the vehicle.
§Returns

A ControlOutput containing the desired thrust and control moments.

§Unsupported setpoints

Setpoint is #[non_exhaustive]. For a variant it can’t fly, an implementation returns a neutral output — zero thrust and moments (ControlOutput::default) — and must not panic.

Provided Methods§

Source

fn prime(&mut self, _state: &VehicleState)

Resets the stabilizer and primes it from a known-good vehicle state.

Clears runtime state (integrators, derivative history) and warms any filters so control starts from where the vehicle is. FlightLoop calls it before the first tick and again each time the Command arms, after Guidance::prime. The default does nothing.

Source

fn saturation(&self) -> Saturation

What the last stabilize call clipped to a limit. FlightLoop merges it into the tick’s TelemetryRecord::saturation. The default reports nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§