From 026f8d1fa8e52009185ee8d507b258316e44c80c Mon Sep 17 00:00:00 2001 From: Silvan Date: Sun, 4 Oct 2026 14:35:55 +0200 Subject: [PATCH] docs(fw): define the fixed-wing pitch angle and FW_PSP_OFF PX4 never said in which frame fixed-wing pitch angles are given, and FW_PSP_OFF was described as an offset added to the pitch setpoint and as the angle of attack, which holds only for TECS and Stabilized mode, and only in level flight measured from the body x-axis. - Trimming guide: a side-view diagram of the body frame, the pitch angle and FW_PSP_OFF, and where FW_PSP_OFF is used. - Messages: state that pitch setpoints and limits are absolute, drop the FRD frame tag on an Euler angle, correct the pitch range to +-pi/2, and describe the TECS pitch integrator as a correction term. Comment-only, so no message version change. - Parameters: describe FW_PSP_OFF as the level-flight pitch, mark the absolute pitch parameters as such, and describe the asymmetric FW_MAN_P_MAX range with a non-zero FW_PSP_OFF. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Silvan --- .../config/fw/fw_pitch_angle_definition.svg | 71 +++++++++++++++++++ docs/en/config_fw/trimming_guide_fixedwing.md | 31 ++++++-- msg/TecsStatus.msg | 4 +- msg/versioned/AirspeedValidated.msg | 2 +- .../FixedWingLongitudinalSetpoint.msg | 3 +- .../LongitudinalControlConfiguration.msg | 5 +- .../fw_att_control/fw_att_control_params.yaml | 16 +++-- .../fw_mode_manager_params.yaml | 10 +-- .../runway_takeoff/runway_takeoff_params.yaml | 2 +- 9 files changed, 123 insertions(+), 21 deletions(-) create mode 100644 docs/assets/config/fw/fw_pitch_angle_definition.svg diff --git a/docs/assets/config/fw/fw_pitch_angle_definition.svg b/docs/assets/config/fw/fw_pitch_angle_definition.svg new file mode 100644 index 00000000000..66985a10d35 --- /dev/null +++ b/docs/assets/config/fw/fw_pitch_angle_definition.svg @@ -0,0 +1,71 @@ + + + + Fixed-wing pitch angle θ and FW_PSP_OFF + Side view, nose to the right. Angles are exaggerated. + + + + Horizon + + + + + Velocity in level flight + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + x + forward + z + down + y + right wing, out of the page + + + + + θ + + + θ (pitch): angle of the body x-axis above the horizon. PX4 pitch setpoints and pitch limits are θ. + FW_PSP_OFF: θ in level flight at trim airspeed. TECS adds the commanded climb angle to it. + diff --git a/docs/en/config_fw/trimming_guide_fixedwing.md b/docs/en/config_fw/trimming_guide_fixedwing.md index 78cea918f59..da6d025c39a 100644 --- a/docs/en/config_fw/trimming_guide_fixedwing.md +++ b/docs/en/config_fw/trimming_guide_fixedwing.md @@ -17,8 +17,8 @@ An overview of those parameters and their use case is shown below: These parameters are set automatically during [RC calibration](../config/radio.md). - [CA_SV_CSx_TRIM](../advanced_config/parameter_reference.md#CA_SV_CS0_TRIM) applies trim to a control surfaces channel. These are used to finely align the control surfaces to default angles before flying. -- [FW_PSP_OFF](../advanced_config/parameter_reference.md#FW_PSP_OFF) applies an offset to the pitch setpoint. - This is used to set the angle of attack at which your aircraft needs to fly at cruise speed. +- [FW_PSP_OFF](../advanced_config/parameter_reference.md#FW_PSP_OFF) is the pitch angle at which your aircraft flies level at trim airspeed. + See [Level-Flight Pitch](#level-flight-pitch) for how PX4 defines and uses it. - [FW_AIRSPD_TRIM](../advanced_config/parameter_reference.md#FW_AIRSPD_TRIM) is used by the rate controllers to scale their output depending on the measured airspeed. See [Airspeed Scaling](../flight_stack/controller_diagrams.md#airspeed-scaling) for more details. - [TRIM_ROLL](../advanced_config/parameter_reference.md#TRIM_ROLL), [TRIM_PITCH](../advanced_config/parameter_reference.md#TRIM_PITCH) and [TRIM_YAW](../advanced_config/parameter_reference.md#TRIM_YAW) apply trim to the control signals _before_ mixing. @@ -28,8 +28,7 @@ An overview of those parameters and their use case is shown below: The correct order to set the above parameters is: 1. Trim the servos by physically adjusting the linkages lengths if possible and fine tune by trimming the PWM channels (use `PWM_MAIN/AUX_TRIMx`) on the bench to properly set the control surfaces to their theoretical position. -1. Fly in stabilized mode at cruise speed and set the pitch setpoint offset (`FW_PSP_OFF`) to desired angle of attack. - The required angle of attack at cruise speed corresponds to the pitch angle that the airplane needs to fly at in order to keep constant altitude during wing-leveled flight. +1. Fly in stabilized mode at cruise speed and set `FW_PSP_OFF` to the pitch angle that the airplane needs to fly at in order to keep constant altitude during wing-leveled flight. If you are using an airspeed sensor, also set the correct cruise airspeed (`FW_AIRSPD_TRIM`). 1. Look at the actuator controls in the log file (upload it to [Flight Review](https://logs.px4.io) and check the _Actuator Controls_ plot for example) and set the pitch trim (`TRIM_PITCH`). Set that value to the average offset of the pitch signal during wing-leveled flight. @@ -37,6 +36,30 @@ The correct order to set the above parameters is: Step 3 can be performed before step 2 if you don't want to have to look at the log, or if you feel comfortable flying in manual mode. You can then trim your remote (with the trim switches) and report the values to `TRIM_PITCH` (and remove the trims from your transmitter) or update `TRIM_PITCH` directly during flight via telemetry and QGC. +## Level-Flight Pitch + +PX4 measures the fixed-wing pitch angle θ between the body x-axis and the horizon. +The body frame is fixed to the vehicle: x points forward through the nose, y along the right wing and z down. +Its orientation follows the mounting of the flight controller (see [Flight Controller Orientation](../config/flight_controller_orientation.md)), not the wing chord. +For tailsitters, the fixed-wing body frame is the multicopter body frame rotated by 90° in pitch. + +![Side view of a fixed-wing aircraft pitched up: the body x-axis points forward, z down and y along the right wing out of the page; the pitch angle θ is the angle between the body x-axis and the horizon, and in level flight at trim airspeed it equals FW_PSP_OFF](../../assets/config/fw/fw_pitch_angle_definition.svg) + +[FW_PSP_OFF](../advanced_config/parameter_reference.md#FW_PSP_OFF) is θ in level flight at trim airspeed ([FW_AIRSPD_TRIM](../advanced_config/parameter_reference.md#FW_AIRSPD_TRIM)). +In level flight the velocity is horizontal, so this is also the angle of attack measured from the body x-axis. +It differs from the angle of attack of the wing by the angle between the wing chord and the body x-axis. + +Pitch setpoints and pitch limits in PX4 are absolute pitch angles θ, and `FW_PSP_OFF` is not added to them. +This applies for example to [FW_P_LIM_MIN](../advanced_config/parameter_reference.md#FW_P_LIM_MIN), [FW_P_LIM_MAX](../advanced_config/parameter_reference.md#FW_P_LIM_MAX), [FW_TKO_PITCH_MIN](../advanced_config/parameter_reference.md#FW_TKO_PITCH_MIN), [FW_LND_FL_PMIN](../advanced_config/parameter_reference.md#FW_LND_FL_PMIN), [FW_LND_FL_PMAX](../advanced_config/parameter_reference.md#FW_LND_FL_PMAX) and [RWTO_PSP](../advanced_config/parameter_reference.md#RWTO_PSP). + +`FW_PSP_OFF` itself is used in these places: + +- The altitude and airspeed controller (TECS) uses `FW_PSP_OFF` as the pitch at zero climb angle: its pitch setpoint is `FW_PSP_OFF` plus the commanded climb angle plus an integrator correction. + The logged TECS pitch setpoint (`tecs_status.pitch_sp_rad`) is absolute, while the logged pitch integrator (`tecs_status.pitch_integ`) is a correction added to it rather than a pitch angle. +- In [Stabilized mode](../flight_modes_fw/stabilized.md), the centred pitch stick commands `FW_PSP_OFF`. +- During the front transition, standard VTOLs ramp their pitch setpoint to `FW_PSP_OFF`, and tailsitters end their pitch-down rotation at it. +- The first principle check of the [airspeed validation](../advanced_config/airspeed_validation.md) considers the vehicle to be pitching down when θ is below `FW_PSP_OFF`. + ## Advanced Trimming Given that the downward pitch moment induced by an asymmetric airfoil increases with airspeed and when the flaps are deployed, the aircraft needs to be re-trimmed according to the current measured airspeed and flaps position. diff --git a/msg/TecsStatus.msg b/msg/TecsStatus.msg index 9b16ea16671..38e3a070110 100644 --- a/msg/TecsStatus.msg +++ b/msg/TecsStatus.msg @@ -21,10 +21,10 @@ float32 total_energy_balance_rate_sp # Energy balance rate setpoint [m^2/s^3] float32 total_energy_balance_rate # Energy balance rate estimate [m^2/s^3] float32 throttle_integ # Throttle integrator value [-] -float32 pitch_integ # Pitch integrator value [rad] +float32 pitch_integ # Pitch integrator value [rad], a correction added to the pitch setpoint rather than a pitch angle float32 throttle_sp # Current throttle setpoint [-] -float32 pitch_sp_rad # Current pitch setpoint [rad] +float32 pitch_sp_rad # Current pitch setpoint [rad], absolute: angle of the fixed-wing body x-axis above the horizon, FW_PSP_OFF included float32 throttle_trim # estimated throttle value [0,1] required to fly level at equivalent_airspeed_sp in the current atmospheric conditions float32 underspeed_ratio # 0: no underspeed, 1: maximal underspeed. Controller takes measures to avoid stall proportional to ratio if >0. diff --git a/msg/versioned/AirspeedValidated.msg b/msg/versioned/AirspeedValidated.msg index d49b6f76cbe..7fe9a9a688e 100644 --- a/msg/versioned/AirspeedValidated.msg +++ b/msg/versioned/AirspeedValidated.msg @@ -23,4 +23,4 @@ float32 calibrated_ground_minus_wind_m_s # [m/s] [@invalid NaN] CAS calculated f float32 calibraded_airspeed_synth_m_s # [m/s] [@invalid NaN] Synthetic airspeed float32 airspeed_derivative_filtered # [m/s^2] Filtered indicated airspeed derivative float32 throttle_filtered # [-] Filtered fixed-wing throttle -float32 pitch_filtered # [rad] Filtered pitch +float32 pitch_filtered # [rad] Filtered absolute pitch angle of the fixed-wing body x-axis above the horizon diff --git a/msg/versioned/FixedWingLongitudinalSetpoint.msg b/msg/versioned/FixedWingLongitudinalSetpoint.msg index ff4b27e84e7..345d9bf82d4 100644 --- a/msg/versioned/FixedWingLongitudinalSetpoint.msg +++ b/msg/versioned/FixedWingLongitudinalSetpoint.msg @@ -3,6 +3,7 @@ # Used by the fw_lateral_longitudinal_control module # If pitch_direct and throttle_direct are not both finite, then the controller relies on altitude/height_rate and equivalent_airspeed to control vertical motion. # If both altitude and height_rate are NAN, the controller maintains the current altitude. +# Pitch angles are absolute: the angle of the fixed-wing body x-axis above the horizon, without FW_PSP_OFF applied. uint32 MESSAGE_VERSION = 0 @@ -11,5 +12,5 @@ uint64 timestamp # [us] Time since system start float32 altitude # [m] Altitude setpoint AMSL, not controlled directly if NAN or if height_rate is finite float32 height_rate # [m/s] [@frame ENU] Scalar height rate setpoint. NAN if not controlled directly float32 equivalent_airspeed # [m/s] [@range 0, inf] Scalar equivalent airspeed setpoint. NAN if system default should be used -float32 pitch_direct # [rad] [@range -pi, pi] [@frame FRD] NAN if not controlled, overrides total energy controller +float32 pitch_direct # [rad] [@range -pi/2, pi/2] Absolute pitch angle setpoint. NAN if not controlled, overrides total energy controller float32 throttle_direct # [norm] [@range 0,1] NAN if not controlled, overrides total energy controller diff --git a/msg/versioned/LongitudinalControlConfiguration.msg b/msg/versioned/LongitudinalControlConfiguration.msg index 1ee0f7ccc98..ce59593b60e 100644 --- a/msg/versioned/LongitudinalControlConfiguration.msg +++ b/msg/versioned/LongitudinalControlConfiguration.msg @@ -2,13 +2,14 @@ # # Used by the fw_lateral_longitudinal_control module and TECS to constrain FixedWingLongitudinalSetpoint messages # and configure the resultant setpoints. +# Pitch angles are absolute: the angle of the fixed-wing body x-axis above the horizon, without FW_PSP_OFF applied. uint32 MESSAGE_VERSION = 0 uint64 timestamp # [us] Time since system start -float32 pitch_min # [rad] [@range -pi, pi] Defaults to FW_P_LIM_MIN if NAN. -float32 pitch_max # [rad] [@range -pi, pi] Defaults to FW_P_LIM_MAX if NAN. +float32 pitch_min # [rad] [@range -pi/2, pi/2] Minimum absolute pitch angle setpoint. Defaults to FW_P_LIM_MIN if NAN. +float32 pitch_max # [rad] [@range -pi/2, pi/2] Maximum absolute pitch angle setpoint. Defaults to FW_P_LIM_MAX if NAN. float32 throttle_min # [norm] [@range 0,1] Defaults to FW_THR_MIN if NAN. float32 throttle_max # [norm] [@range 0,1] Defaults to FW_THR_MAX if NAN. float32 climb_rate_target # [m/s] Target climbrate to change altitude. Defaults to FW_T_CLMB_R_SP if NAN. Not used if height_rate is directly set in FixedWingLongitudinalSetpoint. diff --git a/src/modules/fw_att_control/fw_att_control_params.yaml b/src/modules/fw_att_control/fw_att_control_params.yaml index a258cbcbc8e..cb5e3d8c11d 100644 --- a/src/modules/fw_att_control/fw_att_control_params.yaml +++ b/src/modules/fw_att_control/fw_att_control_params.yaml @@ -138,9 +138,12 @@ parameters: description: short: Pitch setpoint offset (pitch at level flight) long: |- - An airframe specific offset of the pitch setpoint in degrees, the value is - added to the pitch setpoint and should correspond to the pitch at - typical cruise speed of the airframe. + Pitch angle of the body x-axis above the horizon in level flight at trim airspeed (FW_AIRSPD_TRIM). + + The altitude and airspeed controller (TECS) uses it as the pitch at zero climb angle, + and in Stabilized mode the centred pitch stick commands it. + Pitch setpoints and pitch limits set elsewhere, for example FW_P_LIM_MIN and FW_P_LIM_MAX, + are absolute and do not include it. type: float default: 0.0 unit: deg @@ -174,8 +177,11 @@ parameters: FW_MAN_P_MAX: description: short: Maximum manual pitch angle - long: Applies to both directions in all manual modes with attitude stabilization - but without altitude control + long: |- + Pitch angle commanded by full stick deflection, relative to FW_PSP_OFF (the centred-stick pitch). + The resulting pitch setpoint is additionally limited to this angle around level, + so with a non-zero FW_PSP_OFF the range is not symmetric. + Applies in all manual modes with attitude stabilization but without altitude control. type: float default: 30.0 unit: deg diff --git a/src/modules/fw_mode_manager/fw_mode_manager_params.yaml b/src/modules/fw_mode_manager/fw_mode_manager_params.yaml index 52a4cfbc11d..34955f71175 100644 --- a/src/modules/fw_mode_manager/fw_mode_manager_params.yaml +++ b/src/modules/fw_mode_manager/fw_mode_manager_params.yaml @@ -98,7 +98,7 @@ parameters: default: 0 FW_LND_FL_PMIN: description: - short: Flare, minimum pitch + short: Flare, minimum absolute pitch long: Minimum pitch during landing flare. type: float default: 2.5 @@ -109,7 +109,7 @@ parameters: increment: 0.5 FW_LND_FL_PMAX: description: - short: Flare, maximum pitch + short: Flare, maximum absolute pitch long: Maximum pitch during landing flare. type: float default: 15.0 @@ -262,7 +262,7 @@ parameters: definitions: FW_TKO_PITCH_MIN: description: - short: Minimum pitch during takeoff + short: Minimum absolute pitch during takeoff type: float default: 10.0 unit: deg @@ -350,7 +350,7 @@ parameters: definitions: FW_P_LIM_MIN: description: - short: Minimum pitch angle setpoint + short: Minimum absolute pitch angle setpoint long: Applies in any altitude controlled flight mode. type: float default: -30.0 @@ -361,7 +361,7 @@ parameters: increment: 0.5 FW_P_LIM_MAX: description: - short: Maximum pitch angle setpoint + short: Maximum absolute pitch angle setpoint long: Applies in any altitude controlled flight mode. type: float default: 30.0 diff --git a/src/modules/fw_mode_manager/runway_takeoff/runway_takeoff_params.yaml b/src/modules/fw_mode_manager/runway_takeoff/runway_takeoff_params.yaml index c5cc8f5b9c5..8fe13159a75 100644 --- a/src/modules/fw_mode_manager/runway_takeoff/runway_takeoff_params.yaml +++ b/src/modules/fw_mode_manager/runway_takeoff/runway_takeoff_params.yaml @@ -19,7 +19,7 @@ parameters: increment: 0.01 RWTO_PSP: description: - short: Pitch setpoint during taxi / before rotation + short: Absolute pitch setpoint during taxi / before rotation long: |- Pitch setpoint during taxi / before takeoff rotation airspeed is reached