Skip to main content

Module params

Module params 

Source
Expand description

A flat name → f32 view over the config tree, for live tuning from a ground station.

The config is the only store: Params::param reads a field of the component’s config, and Params::set_param writes a copy and commits it through Configurable::set_config, which validates it (an invalid value is rejected and the config unchanged) and applies the integrator policy. Any Configurable whose config implements ParamTable gets Params; FlightLoop combines its guidance’s and stabilizer’s.

Names are uppercase ASCII of at most MAX_NAME_LEN bytes (MAVLink’s param_id), prefixed by component (STAB_, GUID_, PSTAB_, PGUID_, TRAN_) and loop. Vector components end in _X/_Y/_Z (roll/pitch/yaw for angles and rates). Angles and angular rates are in degrees and deg/s, as ground stations show them, and convert to the config’s radians at this boundary; everything else is in the config field’s own unit.

Params are addressed by index, 0..param_count(), in a stable table order; name lookup scans the names. Index access is what paced output uses (a cursor that sends a few params per tick).

Units, descriptions, groups, and valid ranges are in the metadata module (feature param-metadata), one table per config next to its ParamTable. The tables below map names to config fields.

§Copter stabilizer (CopterStabilizerConfig)

NameField
STAB_RATE_RLL_P, _I, _Dbody_rate.roll_gains
STAB_RATE_PIT_P, _I, _Dbody_rate.pitch_gains
STAB_RATE_YAW_P, _I, _Dbody_rate.yaw_gains
STAB_RATE_IMAXbody_rate.max_integral
STAB_RATE_IMAX_Zbody_rate.yaw_max_integral
STAB_ATT_RLL_P, _I, _Dattitude.roll_gains
STAB_ATT_PIT_P, _I, _Dattitude.pitch_gains
STAB_ATT_AMAX_X, _Yattitude.max_angles_rad
STAB_ATT_IMAXattitude.max_integral
STAB_ATT_RMAX_X, _Yattitude.max_rate_radps
STAB_YAW_P, _I, _Dyaw.gains
STAB_YAW_IMAXyaw.max_integral
STAB_YAW_RMAXyaw.max_rate_radps
STAB_FS_RATE_X, _Y, _Zfull_scale_rates_radps
STAB_THR_EXPOthrust_curve_exponent
STAB_GYRO_FLTgyro_cutoff_hz
STAB_NTCH_HZgyro_notch.center_hz
STAB_NTCH_BWgyro_notch.bandwidth_hz
STAB_NTCH_ATTgyro_notch.attenuation_db

§Copter guidance (CopterGuidanceConfig)

NameField
GUID_ALT_P, _I, _Daltitude.gains
GUID_ALT_IMAXaltitude.max_integral
GUID_ALT_HOVERaltitude.hover_thrust
GUID_ALT_IBANDaltitude.integration_band_m
GUID_LAT_POS_Plateral.position_p
GUID_LAT_VEL_P, _I, _Dlateral.velocity
GUID_LAT_IMAXlateral.max_integral
GUID_LAT_ACClateral.max_accel_mps2
GUID_LAT_BRKlateral.brake_mps2
GUID_LAT_BRK_SHRlateral.braking_share
GUID_NAV_PERIODnavigation_period_s
GUID_TILT_MAXmax_tilt_rad
GUID_DESC_MAXmax_descent_mps
GUID_DESC_ACCdescent_accel_mps2
GUID_CLIMB_DECclimb_decel_mps2
GUID_LAND_SPDland_speed_mps
GUID_YAW_SLEWwaypoint_yaw_radps
GUID_HDG_RATEheading_rate_radps
GUID_YAW_MIN_LEGwaypoint_yaw_min_leg_m
GUID_YAW_YLD_ERRheading_yield_rad
GUID_YAW_YLD_RTheading_yield_rate_radps
GUID_YAW_YLD_Sheading_yield_s
GUID_WND_HDG_SPDwind_heading_min_mps
GUID_THR_MINthrust.min_thrust
GUID_SINK_LIMthrust.sink_limit_mps
GUID_SINK_GAINthrust.sink_gain
GUID_BOOST_MAXthrust.max_boost_thrust
GUID_STICK_X, _Ymax_stick_angles_rad
GUID_STICK_YAWstick_yaw_rate_radps
GUID_THR_IDLEidle_throttle
GUID_ALT_LEASHaltitude_leash_m
GUID_WND_HDG_OFFwind_heading_from_wind_rad
GUID_WND_HDG_SDwind_heading_max_sd_rad
GUID_WND_HDG_DBwind_heading_deadband_rad
GUID_WND_AIR_HTairborne_height_m
GUID_WND_FF_BANDfeedforward_hold_band_mps
GUID_WND_BCOEF_X, _Ywind.ballistic_kgpm2
GUID_WND_MCOEF_X, _Ywind.momentum_per_s
GUID_WND_F_NSEwind.force_noise_mps2
GUID_WND_P_NSEwind.process_noise_mps_per_rt_s
GUID_WND_INIT_SD, GUID_WND_GATE, GUID_WND_AX_SPDwind.initial_sd_mps, wind.gate_sigma, wind.max_axial_speed_mps

§Plane stabilizer (PlaneStabilizerConfig)

NameField
PSTAB_RLL_P, _I, _FFrate.roll
PSTAB_PIT_P, _I, _FFrate.pitch
PSTAB_YAW_P, _I, _FFrate.yaw
PSTAB_IMAXrate.max_integral
PSTAB_RLL_TRIM, PSTAB_PIT_TRIM, PSTAB_YAW_TRIMrate.trim
PSTAB_TC_X, _Ytime_constant_s
PSTAB_RMAX_X, _Ymax_attitude_rate_radps
PSTAB_BRATE_X, _Y, _Zmax_body_rate_radps
PSTAB_BANK_MAXmax_bank_rad
PSTAB_PIT_MAXmax_pitch_rad
PSTAB_ASPD_TRIM, _MIN, _MAXtrim_airspeed_mps, min_airspeed_mps, max_airspeed_mps
PSTAB_THR_EXPOthrust_curve_exponent

§Plane guidance (PlaneGuidanceConfig)

NameField
PGUID_BANK_MAXmax_bank_rad
PGUID_PIT_UP, PGUID_PIT_DNmax_pitch_up_rad, max_pitch_down_rad
PGUID_ACRO_X, _Y, _Zmax_rate_radps
PGUID_TRIM_PITtrim_pitch_rad
PGUID_CRUISEcruise_thrust
PGUID_L1_PERIOD, PGUID_L1_DAMPl1_period_s, l1_damping
PGUID_LOIT_RADloiter_radius_m
PGUID_ALT_P, _I, _IMAXaltitude_p, altitude_i, altitude_max_integral
PGUID_TCONSTtecs.time_constant_s
PGUID_CLMB_MAX, PGUID_SINK_MIN, PGUID_SINK_MAXtecs.max_climb_mps, tecs.min_sink_mps, tecs.max_sink_mps
PGUID_THR_DAMP, PGUID_INTEG, PGUID_PTCH_DAMP, PGUID_PTCH_INTEGtecs.thrust_damping, tecs.integrator_gain, tecs.pitch_damping, tecs.pitch_integrator_gain
PGUID_SPDWEIGHTtecs.speed_weight
PGUID_RLL2THRtecs.roll_compensation
PGUID_ASPD_MIN, PGUID_ASPD_MAXtecs.min_airspeed_mps, tecs.max_airspeed_mps
PGUID_USPD_SHAREtecs.underspeed_share
PGUID_HDEM_TC, PGUID_ASPD_RT_TC, PGUID_KE_HPF_TCtecs.height_demand_time_constant_s, tecs.airspeed_rate_time_constant_s, tecs.kinetic_rate_high_pass_s
PGUID_THR_MIN, PGUID_THR_MAXmin_thrust, max_thrust
PGUID_CLMB_THRclimb_thrust_per_rad

§Transition (TransitionConfig)

NameField
TRAN_FW_RATE, TRAN_FW_DONE, TRAN_FW_MAXforward_rate_radps, forward_done_rad, forward_max_tilt_rad
TRAN_ASPD_MINmin_airspeed_mps
TRAN_VT_RATE, TRAN_VT_DONEback_rate_radps, back_done_rad
TRAN_TIMEOUTtimeout_s
TRAN_MIN_HGT, TRAN_FW_MIN_HGTmin_height_m, plane_min_height_m
TRAN_FW_THR, TRAN_VT_THRforward_thrust, back_thrust
TRAN_VT_SINK_LIM, TRAN_VT_SINK_GNback_sink_limit_mps, back_sink_gain
TRAN_HANDOFFhandoff_s
TRAN_ROLL_MAXroll_limit_rad

§Lift transition (LiftTransitionConfig)

A lift+cruise VTOL’s; names shared with the tailsitter’s table mean the same.

NameField
TRAN_ASPD_MINmin_airspeed_mps
TRAN_FW_RAMPlift_ramp_s
TRAN_TIMEOUTtimeout_s
TRAN_MIN_HGT, TRAN_FW_MIN_HGTmin_height_m, plane_min_height_m
TRAN_VT_RAMP, TRAN_VT_SPD, TRAN_VT_TIMEOUTback_ramp_s, back_speed_mps, back_timeout_s
TRAN_VT_DEC, TRAN_VT_DEC_Iback_decel_mps2, back_decel_i
TRAN_FW_THR, TRAN_PSH_SLEWforward_thrust, pusher_slew_per_s
TRAN_FW_PIT_MAXforward_pitch_max_rad
TRAN_HANDOFFhandoff_s
TRAN_ROLL_MAXroll_limit_rad

§Examples

use stable_flight::params::Params;
use stable_flight::stabilizers::copter::{CopterStabilizer, CopterStabilizerConfig};
use stable_flight::Configurable;

let mut stabilizer = CopterStabilizer::new(CopterStabilizerConfig::default());

stabilizer.set_param("STAB_RATE_RLL_P", 0.2).expect("valid value");
assert_eq!(stabilizer.param("STAB_RATE_RLL_P"), Some(0.2));
assert_eq!(stabilizer.config().body_rate.roll_gains.p, 0.2);

stabilizer.set_param("STAB_ATT_AMAX_X", 30.0).expect("valid value"); // degrees
assert!((stabilizer.config().attitude.max_angles_rad.x - 30f32.to_radians()).abs() < 1e-6);

assert!(stabilizer.set_param("STAB_RATE_IMAX", -1.0).is_err()); // fails validation
assert!(stabilizer.set_param("NO_SUCH_PARAM", 1.0).is_err());

let mut count = 0;
stabilizer.visit_params(&mut |_name, _value| count += 1);
assert_eq!(count, 35);

Modules§

metadata
Descriptions, units, grouping, and valid ranges for params, for ground stations (param-metadata feature): a host-side companion to each ParamTable, so flight-controller firmware, which never enables the feature, carries none of it.

Structs§

Param
One named f32 field of a config C: how to read it and how to write it, unvalidated.

Enums§

ParamError
Why a param write (Params::set_param, Params::set_param_at) was rejected.

Constants§

MAX_NAME_LEN
Longest param name in bytes: MAVLink’s param_id field.

Traits§

ParamTable
A config that exposes its fields as named params.
Params
Read, write, and list a component’s tunable values by index or by name.