diff --git a/docs/assets/config/fw/autotune.png b/docs/assets/config/fw/autotune.png index 768d26787d..6ceb2ed3ba 100644 Binary files a/docs/assets/config/fw/autotune.png and b/docs/assets/config/fw/autotune.png differ diff --git a/docs/assets/config/fw/gain_compression_diagram.png b/docs/assets/config/fw/gain_compression_diagram.png new file mode 100644 index 0000000000..e2ea2f09f7 Binary files /dev/null and b/docs/assets/config/fw/gain_compression_diagram.png differ diff --git a/docs/en/SUMMARY.md b/docs/en/SUMMARY.md index 5cf35ff858..5548b8dd56 100644 --- a/docs/en/SUMMARY.md +++ b/docs/en/SUMMARY.md @@ -56,6 +56,8 @@ - [DJI F450 (CUAV v5 nano)](frames_multicopter/dji_f450_cuav_5nano.md) - [Planes (Fixed-Wing)](frames_plane/index.md) + - [Features](features_fw/index.md) + - [Gain compression](features_fw/gain_compression.md) - [Assembly](assembly/assembly_fw.md) - [Config/Tuning](config_fw/index.md) - [Auto-tune](config/autotune_fw.md) diff --git a/docs/en/config_fw/pid_tuning_guide_fixedwing.md b/docs/en/config_fw/pid_tuning_guide_fixedwing.md index 0eb1005a49..df7db1ea00 100644 --- a/docs/en/config_fw/pid_tuning_guide_fixedwing.md +++ b/docs/en/config_fw/pid_tuning_guide_fixedwing.md @@ -17,6 +17,8 @@ Manual tuning is recommended for frames where autotuning does not work, or where - Excessive gains (and rapid servo motion) can violate the maximum forces of your airframe - increase gains carefully. - Roll and pitch tuning follow the same sequence. The only difference is that pitch is more sensitive to trim offsets, so [trimming](../config_fw/trimming_guide_fixedwing.md) has to be done carefully and integrator gains need more attention to compensate this. +- Disable automatic [gain compression](../features_fw/gain_compression.md) ([FW_GC_EN](../advanced_config/parameter_reference.md#FW_GC_EN)) to avoid over-tuning. + Remember to re-enable it when tuning is done. ## Establishing the Airframe Baseline diff --git a/docs/en/features_fw/gain_compression.md b/docs/en/features_fw/gain_compression.md new file mode 100644 index 0000000000..7efb48f59c --- /dev/null +++ b/docs/en/features_fw/gain_compression.md @@ -0,0 +1,24 @@ +# Gain compression + + + +Automatic gain compression reduces the gains of the angular-rate PID whenever oscillations are detected. +It monitors the angular-rate controller output through a band-pass filter to identify these oscillations. + +This approach is a safe adaptive mechanism for stable aircraft: the PID gains remain unchanged when no oscillations are present, they are never increased beyond their nominal values, and they are bounded by a minimum limit. + +Gain compression can help prevent actuator damage and even loss of the vehicle in cases such as airspeed-sensor failure (loss of airspeed scaling) or in-flight changes in dynamics (e.g.: CG shifts, inertia changes), or other failures that could cause the angular-rate loop to become oscillatory. + +![Gain compression diagram](../../assets/config/fw/gain_compression_diagram.png) + +## Usage + +Gain compression is enabled by default ([FW_GC_EN](../advanced_config/parameter_reference.md#FW_GC_EN)). + +It should be disabled during fixed wing [manual tuning](../config_fw/pid_tuning_guide_fixedwing.md) to avoid over-tuning. +It does not need to be disabled when autotuning. + +## Parameters + +- [FW_GC_EN](../advanced_config/parameter_reference.md#FW_GC_EN) +- [FW_GC_GAIN_MIN](../advanced_config/parameter_reference.md#FW_GC_GAIN_MIN) diff --git a/docs/en/features_fw/index.md b/docs/en/features_fw/index.md new file mode 100644 index 0000000000..7eab8e9c6c --- /dev/null +++ b/docs/en/features_fw/index.md @@ -0,0 +1,5 @@ +# Fixedwing-Specific Features + +This section lists features that are specific to (or customised for) fixed-wings: + +- [Gain Compression](../features_fw/gain_compression.md) diff --git a/docs/en/releases/main.md b/docs/en/releases/main.md index a8c1805fbb..70f5a2860f 100644 --- a/docs/en/releases/main.md +++ b/docs/en/releases/main.md @@ -93,6 +93,7 @@ Please continue reading for [upgrade instructions](#upgrade-guide). - [Fixed Wing Takeoff mode](../flight_modes_fw/takeoff.md) will now keep climbing with level wings on position loss. A target takeoff waypoint can be set to control takeoff course and loiter altitude. ([PX4-Autopilot#25083](https://github.com/PX4/PX4-Autopilot/pull/25083)). +- Automatically suppress angular rate oscillations using [Gain compression](../features_fw/gain_compression.md). ([PX4-Autopilot#25840: FW rate control: add gain compression algorithm](https://github.com/PX4/PX4-Autopilot/pull/25840)) ### Rover diff --git a/msg/GainCompression.msg b/msg/GainCompression.msg index cd04535556..b7d6735007 100644 --- a/msg/GainCompression.msg +++ b/msg/GainCompression.msg @@ -1,6 +1,5 @@ uint64 timestamp # Time since system start (microseconds) -float32[3] compression_gains # [-] Multiplicative gain to modify the output of the controller per axis [@frame FRD], [@range 0, 1] -float32[3] spectral_damper_hpf # Squared output of the spectral damper’s high-pass filter [@frame FRD] -float32[3] spectral_damper_out # Spectral damper's output squared [@frame FRD] -float32[3] input # Torque input [@frame FRD] +float32[3] compression_gains # [-] [@frame FRD] [@range 0, 1] Multiplicative gain to modify the output of the controller per axis +float32[3] spectral_damper_hpf # [-] [@frame FRD] Squared output of spectral damper high-pass filter +float32[3] spectral_damper_out # [-] [@frame FRD] Spectral damper output squared diff --git a/src/lib/rate_control/gain_compression.cpp b/src/lib/rate_control/gain_compression.cpp index 220d3768b1..7e1e172de4 100644 --- a/src/lib/rate_control/gain_compression.cpp +++ b/src/lib/rate_control/gain_compression.cpp @@ -88,7 +88,6 @@ void GainCompression3d::update(const Vector3f &input, const float dt) _gains.copyTo(msg.compression_gains); hpf.copyTo(msg.spectral_damper_hpf); lpf.copyTo(msg.spectral_damper_out); - input.copyTo(msg.input); _gain_compression_pub.publish(msg); _time_last_publication = now;