Skip to main content

CopterStabilizerConfig

Struct CopterStabilizerConfig 

Source
pub struct CopterStabilizerConfig {
    pub body_rate: BodyRateControllerConfig,
    pub attitude: AttitudeControllerConfig,
    pub yaw: YawControllerConfig,
    pub full_scale_rates_radps: Vec3,
    pub thrust_curve_exponent: f32,
    pub gyro_cutoff_hz: f32,
    pub gyro_notch: NotchConfig,
}
Expand description

Configuration for the CopterStabilizer: gains and limits for the inner control loops and the thrust mapping.

Plain data: CopterStabilizer::new validates it, and the stabilizer passes it to its controllers every tick.

Fields§

§body_rate: BodyRateControllerConfig

Body-rate (inner) loop.

§attitude: AttitudeControllerConfig

Roll/pitch attitude loop (Setpoint::Attitude only).

§yaw: YawControllerConfig

Heading-hold loop (Setpoint::Attitude only).

§full_scale_rates_radps: Vec3

Body rates (roll, pitch, yaw) in rad/s that a full-scale RateSetpoint maps to. Each component must be non-negative and finite: an infinite or NaN scale makes even a neutral stick a non-finite rate, which zeroes that axis’s moment.

§thrust_curve_exponent: f32

Exponent of the thrust curve applied to the linear thrust setpoint. Must be positive and finite: a negative exponent maps zero throttle to full thrust.

§gyro_cutoff_hz: f32

Cutoff of the low-pass on the body rates the rate loop flies, in Hz; 0 turns it off, and so does one at or past Nyquist. Non-negative and finite. Lower: less gyro noise and vibration in the moments, more lag in the loop (about 5.6 ms at 40 Hz). The default is PX4’s IMU_GYRO_CUTOFF; on the sim’s 0.1 rad/s vibration at 90 Hz, 40 Hz passed the most robustness rows, 20 Hz (ArduPilot’s INS_GYRO_FILTER) and 50 Hz and up lost clean rows (#373).

§gyro_notch: NotchConfig

A notch on the roll and pitch rates before the low-pass, for one vibration tone (a motor’s); off by default. The autotune’s design models it with the low-pass. On the sim’s 0.1 rad/s at 90 Hz under racer’s 75 Hz low-pass, a notch at the tone (90 Hz, 45 Hz wide, 40 dB) passed the robustness noise row, and flown on every row it changed none. The yaw rate stays unnotched, though ArduPilot and PX4 notch all three axes: with yaw notched too, quad_x’s yaw search overshot the step spec on one noise seed of five from both starts (peaks 1.052 and 1.066 against 1.05), which roll and pitch alone pass (#597).

Implementations§

Source§

impl CopterStabilizerConfig

Source

pub fn validate(&self) -> Result<(), InvalidConfig>

Checks every controller config (BodyRateControllerConfig::validate, AttitudeControllerConfig::validate, YawControllerConfig::validate; errors carry the loop as their section), that each full_scale_rates_radps component is non-negative and finite, that thrust_curve_exponent is positive and finite, and that gyro_cutoff_hz is non-negative and finite.

§Examples
use stable_flight::stabilizers::copter::CopterStabilizerConfig;

let mut config = CopterStabilizerConfig::default();
assert!(config.validate().is_ok());
config.yaw.max_rate_radps = -1.0;
assert!(config.validate().is_err());
Source

pub fn gyro_filters_on(&self, axis: usize) -> GyroFilters

The gyro filters body axis (0 roll, 1 pitch, 2 yaw) flies through: on roll and pitch, gyro_notch then the low-pass at gyro_cutoff_hz; on yaw, the low-pass alone.

Trait Implementations§

Source§

impl Clone for CopterStabilizerConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CopterStabilizerConfig

Source§

impl Debug for CopterStabilizerConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CopterStabilizerConfig

Source§

fn default() -> Self

Untuned starting values; airframes override them with flight-checked sets.

Source§

impl ParamMetadata for CopterStabilizerConfig

Source§

const METADATA: &'static [ParamMeta]

One entry per param: the same names, in the same order, as PARAMS.
Source§

impl ParamTable for CopterStabilizerConfig

Source§

const PARAMS: &'static [Param<Self>]

Every param, in a stable order.
Source§

impl PartialEq for CopterStabilizerConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl SideConfig<CopterSide> for CopterStabilizerConfig

Source§

fn side(&self) -> &CopterStabilizerConfig

The side’s config.
Source§

fn side_mut(&mut self) -> &mut CopterStabilizerConfig

The side’s config, to change it.
Source§

impl StructuralPartialEq for CopterStabilizerConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.