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_) 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)
| Name | Field |
|---|---|
STAB_RATE_P, _I, _D | body_rate.gains |
STAB_RATE_YAW_P, _I, _D | body_rate.yaw_gains |
STAB_RATE_IMAX | body_rate.max_integral |
STAB_ATT_P, _I, _D | attitude.gains |
STAB_ATT_AMAX_X, _Y | attitude.max_angles_rad |
STAB_ATT_IMAX | attitude.max_integral |
STAB_ATT_RMAX_X, _Y | attitude.max_rate_radps |
STAB_YAW_P, _I, _D | yaw.gains |
STAB_YAW_IMAX | yaw.max_integral |
STAB_YAW_RMAX | yaw.max_rate_radps |
STAB_FS_RATE_X, _Y, _Z | full_scale_rates_radps |
STAB_THR_EXPO | thrust_curve_exponent |
§Copter guidance (CopterGuidanceConfig)
| Name | Field |
|---|---|
GUID_ALT_P, _I, _D | altitude.gains |
GUID_ALT_IMAX | altitude.max_integral |
GUID_ALT_HOVER | altitude.hover_thrust |
GUID_LAT_POS_P | lateral.position_p |
GUID_LAT_VEL_P, _I, _D | lateral.velocity |
GUID_LAT_IMAX | lateral.max_integral |
GUID_NAV_PERIOD | navigation_period_s |
GUID_TILT_MAX | max_tilt_rad |
GUID_DESC_MAX | max_descent_mps |
GUID_LAND_SPD | land_speed_mps |
GUID_STICK_X, _Y | max_stick_angles_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_P", 0.2).expect("valid value");
assert_eq!(stabilizer.param("STAB_RATE_P"), Some(0.2));
assert_eq!(stabilizer.config().body_rate.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, 24);Modules§
- metadata
- Descriptions, units, grouping, and valid ranges for params, for ground stations
(
param-metadatafeature): a host-side companion to eachParamTable, so flight-controller firmware, which never enables the feature, carries none of it.
Structs§
- Param
- One named
f32field of a configC: how to read it and how to write it, unvalidated.
Enums§
- Param
Error - 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_idfield.
Traits§
- Param
Table - A config that exposes its fields as named params.
- Params
- Read, write, and list a component’s tunable values by index or by name.