Skip to main content

Mixer

Trait Mixer 

Source
pub trait Mixer {
    // Required method
    fn mix(&mut self, controls: &ControlOutput) -> ActuatorCommand;

    // Provided method
    fn saturation(&self) -> Saturation { ... }
}
Expand description

Component responsible for converting control outputs to actuator commands.

The Mixer trait defines the interface for components that translate generalized control outputs (thrust and moments) into specific actuator commands appropriate for the vehicle configuration. It maps abstract control concepts to physical actuator movements.

Implementors of this trait may include:

  • Quadcopter mixers: Map controls to four motors in different configurations (X, +)
  • Hexacopter mixers: Map controls to six motors
  • Fixed-wing mixers: Map controls to a throttle motor and control-surface servos

Required Methods§

Source

fn mix(&mut self, controls: &ControlOutput) -> ActuatorCommand

Transforms abstract control outputs into specific actuator commands.

This method is the core functionality of the Mixer trait, providing the critical translation layer between the stabilization system’s desired control effects and the actual physical actuator settings needed to achieve those effects.

§Parameters
  • controls - Reference to a ControlOutput struct containing normalized thrust and moment values that represent the desired control effect.
§Returns

An ActuatorCommand containing specific actuator settings appropriate for the vehicle’s physical configuration. The mixer assigns each motors and servos slot its meaning; slots it doesn’t use stay at their default:

  • For multicopters: the motors array
  • For fixed-wing: a throttle motor, with control surfaces on servos
  • For tilting or hybrid vehicles: both
§Examples
use stable_flight::{ControlOutput, Mixer, Vec3};
use stable_flight::mixers::TableMixer;

let mut mixer = TableMixer::quad_x();

// Create control output with 70% thrust and slight roll right
let control_output = ControlOutput::new(
    0.7,                    // 70% thrust
    Vec3::new(0.1, 0.0, 0.0)     // slight roll right, no pitch, no yaw
);

// Convert abstract controls into specific motor commands
let actuator_command = mixer.mix(&control_output);

// Now actuator_command contains specific motor values for a quadcopter

Provided Methods§

Source

fn saturation(&self) -> Saturation

What the last mix call couldn’t deliver in full. 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§

Source§

impl<const N: usize> Mixer for TableMixer<N>