From 0a332354f411966551a64abe03d888228a275955 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 17 Mar 2026 21:55:35 -0800 Subject: [PATCH] refactor(spacecraft): convert params.c to module.yaml Convert 3 parameter file(s) from legacy C format to YAML module configuration. --- src/modules/spacecraft/CMakeLists.txt | 4 + .../spacecraft/spacecraft_attitude_params.c | 183 -------- .../spacecraft_attitude_params.yaml | 131 ++++++ .../spacecraft/spacecraft_position_params.c | 293 ------------ .../spacecraft_position_params.yaml | 224 ++++++++++ .../spacecraft/spacecraft_rate_params.c | 421 ------------------ .../spacecraft/spacecraft_rate_params.yaml | 326 ++++++++++++++ 7 files changed, 685 insertions(+), 897 deletions(-) delete mode 100644 src/modules/spacecraft/spacecraft_attitude_params.c create mode 100644 src/modules/spacecraft/spacecraft_attitude_params.yaml delete mode 100644 src/modules/spacecraft/spacecraft_position_params.c create mode 100644 src/modules/spacecraft/spacecraft_position_params.yaml delete mode 100644 src/modules/spacecraft/spacecraft_rate_params.c create mode 100644 src/modules/spacecraft/spacecraft_rate_params.yaml diff --git a/src/modules/spacecraft/CMakeLists.txt b/src/modules/spacecraft/CMakeLists.txt index 7d39e24ece..429829ea29 100644 --- a/src/modules/spacecraft/CMakeLists.txt +++ b/src/modules/spacecraft/CMakeLists.txt @@ -46,6 +46,10 @@ px4_add_module( SRCS SpacecraftHandler.cpp SpacecraftHandler.hpp + MODULE_CONFIG + spacecraft_attitude_params.yaml + spacecraft_position_params.yaml + spacecraft_rate_params.yaml DEPENDS mathlib px4_work_queue diff --git a/src/modules/spacecraft/spacecraft_attitude_params.c b/src/modules/spacecraft/spacecraft_attitude_params.c deleted file mode 100644 index 6e2c27b192..0000000000 --- a/src/modules/spacecraft/spacecraft_attitude_params.c +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name PX4 nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/** - * @file sc_att_control_params.c - * Parameters for spacecraft attitude controller. - * - * @author Pedro Roque, - */ - -/** - * Roll P gain - * - * Roll proportional gain, i.e. desired angular speed in rad/s for error 1 rad. - * - * @min 0.0 - * @max 12 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Attitude Control - */ -PARAM_DEFINE_FLOAT(SC_ROLL_P, 6.5f); - -/** - * Pitch P gain - * - * Pitch proportional gain, i.e. desired angular speed in rad/s for error 1 rad. - * - * @min 0.0 - * @max 12 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Attitude Control - */ -PARAM_DEFINE_FLOAT(SC_PITCH_P, 6.5f); - -/** - * Yaw P gain - * - * Yaw proportional gain, i.e. desired angular speed in rad/s for error 1 rad. - * - * @min 0.0 - * @max 5 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Attitude Control - */ -PARAM_DEFINE_FLOAT(SC_YAW_P, 2.8f); - -/** - * Yaw weight - * - * A fraction [0,1] deprioritizing yaw compared to roll and pitch in non-linear attitude control. - * Deprioritizing yaw is necessary because multicopters have much less control authority - * in yaw compared to the other axes and it makes sense because yaw is not critical for - * stable hovering or 3D navigation. - * - * For yaw control tuning use SC_YAW_P. This ratio has no impact on the yaw gain. - * - * @min 0.0 - * @max 1.0 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Attitude Control - */ -PARAM_DEFINE_FLOAT(SC_YAW_WEIGHT, 0.4f); - -/** - * Max roll rate - * - * Limit for roll rate in manual and auto modes (except acro). - * Has effect for large rotations in autonomous mode, to avoid large control - * output and mixer saturation. - * - * This is not only limited by the vehicle's properties, but also by the maximum - * measurement rate of the gyro. - * - * @unit deg/s - * @min 0.0 - * @max 1800.0 - * @decimal 1 - * @increment 5 - * @group Spacecraft Attitude Control - */ -PARAM_DEFINE_FLOAT(SC_ROLLRATE_MAX, 220.0f); - -/** - * Max pitch rate - * - * Limit for pitch rate in manual and auto modes (except acro). - * Has effect for large rotations in autonomous mode, to avoid large control - * output and mixer saturation. - * - * This is not only limited by the vehicle's properties, but also by the maximum - * measurement rate of the gyro. - * - * @unit deg/s - * @min 0.0 - * @max 1800.0 - * @decimal 1 - * @increment 5 - * @group Spacecraft Attitude Control - */ -PARAM_DEFINE_FLOAT(SC_PITCHRATE_MAX, 220.0f); - -/** - * Max yaw rate - * - * @unit deg/s - * @min 0.0 - * @max 1800.0 - * @decimal 1 - * @increment 5 - * @group Spacecraft Attitude Control - */ -PARAM_DEFINE_FLOAT(SC_YAWRATE_MAX, 200.0f); - -/** - * Manual tilt input filter time constant - * - * Setting this parameter to 0 disables the filter - * - * @unit s - * @min 0.0 - * @max 2.0 - * @decimal 2 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SC_MAN_TILT_TAU, 0.0f); - -/** - * Max manual yaw rate for Stabilized, Altitude, Position mode - * - * @unit deg/s - * @min 0 - * @max 400 - * @decimal 0 - * @increment 10 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SC_MAN_Y_SCALE, 150.f); - -/** - * Maximal tilt angle in Stabilized or Manual mode - * - * @unit deg - * @min 0 - * @max 90 - * @decimal 0 - * @increment 1 - * @group Multicopter Position Control - */ -PARAM_DEFINE_FLOAT(SC_MAN_TILT_MAX, 90.f); diff --git a/src/modules/spacecraft/spacecraft_attitude_params.yaml b/src/modules/spacecraft/spacecraft_attitude_params.yaml new file mode 100644 index 0000000000..97f57e067c --- /dev/null +++ b/src/modules/spacecraft/spacecraft_attitude_params.yaml @@ -0,0 +1,131 @@ +module_name: spacecraft +parameters: +- group: Multicopter Position Control + definitions: + SC_MAN_TILT_MAX: + description: + short: Maximal tilt angle in Stabilized or Manual mode + type: float + default: 90.0 + unit: deg + min: 0 + max: 90 + decimal: 0 + increment: 1 +- group: Spacecraft Attitude Control + definitions: + SC_ROLL_P: + description: + short: Roll P gain + long: Roll proportional gain, i.e. desired angular speed in rad/s for error + 1 rad. + type: float + default: 6.5 + min: 0.0 + max: 12 + decimal: 2 + increment: 0.1 + SC_PITCH_P: + description: + short: Pitch P gain + long: Pitch proportional gain, i.e. desired angular speed in rad/s for error + 1 rad. + type: float + default: 6.5 + min: 0.0 + max: 12 + decimal: 2 + increment: 0.1 + SC_YAW_P: + description: + short: Yaw P gain + long: Yaw proportional gain, i.e. desired angular speed in rad/s for error + 1 rad. + type: float + default: 2.8 + min: 0.0 + max: 5 + decimal: 2 + increment: 0.1 + SC_YAW_WEIGHT: + description: + short: Yaw weight + long: |- + A fraction [0,1] deprioritizing yaw compared to roll and pitch in non-linear attitude control. + Deprioritizing yaw is necessary because multicopters have much less control authority + in yaw compared to the other axes and it makes sense because yaw is not critical for + stable hovering or 3D navigation. + + For yaw control tuning use SC_YAW_P. This ratio has no impact on the yaw gain. + type: float + default: 0.4 + min: 0.0 + max: 1.0 + decimal: 2 + increment: 0.1 + SC_ROLLRATE_MAX: + description: + short: Max roll rate + long: |- + Limit for roll rate in manual and auto modes (except acro). + Has effect for large rotations in autonomous mode, to avoid large control + output and mixer saturation. + + This is not only limited by the vehicle's properties, but also by the maximum + measurement rate of the gyro. + type: float + default: 220.0 + unit: deg/s + min: 0.0 + max: 1800.0 + decimal: 1 + increment: 5 + SC_PITCHRATE_MAX: + description: + short: Max pitch rate + long: |- + Limit for pitch rate in manual and auto modes (except acro). + Has effect for large rotations in autonomous mode, to avoid large control + output and mixer saturation. + + This is not only limited by the vehicle's properties, but also by the maximum + measurement rate of the gyro. + type: float + default: 220.0 + unit: deg/s + min: 0.0 + max: 1800.0 + decimal: 1 + increment: 5 + SC_YAWRATE_MAX: + description: + short: Max yaw rate + type: float + default: 200.0 + unit: deg/s + min: 0.0 + max: 1800.0 + decimal: 1 + increment: 5 +- group: Spacecraft Position Control + definitions: + SC_MAN_TILT_TAU: + description: + short: Manual tilt input filter time constant + long: Setting this parameter to 0 disables the filter + type: float + default: 0.0 + unit: s + min: 0.0 + max: 2.0 + decimal: 2 + SC_MAN_Y_SCALE: + description: + short: Max manual yaw rate for Stabilized, Altitude, Position mode + type: float + default: 150.0 + unit: deg/s + min: 0 + max: 400 + decimal: 0 + increment: 10 diff --git a/src/modules/spacecraft/spacecraft_position_params.c b/src/modules/spacecraft/spacecraft_position_params.c deleted file mode 100644 index 6b9065f8e6..0000000000 --- a/src/modules/spacecraft/spacecraft_position_params.c +++ /dev/null @@ -1,293 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2024 PX4 Development Team. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name PX4 nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/** - * Proportional gain for position error - * - * Defined as corrective velocity in m/s per m position error - * - * @min 0 - * @max 2 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_POS_P, 0.2f); - -/** - * Integral gain for position error - * - * Defined as corrective velocity in m/s per m velocity error - * - * @min 0 - * @max 15 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_POS_I, 0.f); - -/** - * Integral limit for position error - * - * Defined as corrective velocity in m/s per m velocity error - * - * @min 0 - * @max 5 - * @decimal 2 - * @increment 0.01 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_POS_I_LIM, 1.f); - -/** - * Proportional gain for velocity error - * - * Defined as corrective acceleration in m/s^2 per m/s velocity error - * - * @min 0 - * @max 15 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VEL_P, 6.55f); - -/** - * Integral gain for velocity error - * - * Defined as corrective acceleration in m/s^2 per m/s velocity error - * - * @min 0 - * @max 15 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VEL_I, 0.f); - -/** - * Integral limit for velocity error - * - * Defined as corrective acceleration in m/s^2 per m/s velocity error - * - * @min 0 - * @max 5 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VEL_I_LIM, 1.f); - -/** - * Derivative gain for velocity error - * - * Defined as corrective acceleration in m/s^2 per m/s velocity error - * - * @min 0.0 - * @max 15 - * @decimal 2 - * @increment 0.1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VEL_D, 0.0f); - -/** - * Maximum velocity - * - * Absolute maximum for all velocity controlled modes. - * Any higher value is truncated. - * - * @unit m/s - * @min 0 - * @max 20 - * @decimal 1 - * @increment 1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VEL_MAX, 12.f); - -/** - * Overall Velocity Limit - * - * If set to a value greater than zero, other parameters are automatically set (such as - * MPC_VEL_MAX or MPC_VEL_MANUAL). - * If set to a negative value, the existing individual parameters are used. - * - * @min -20 - * @max 20 - * @decimal 1 - * @increment 1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VEL_ALL, -10.f); - -/** - * Cruising elocity setpoint in autonomous modes - * - * @unit m/s - * @min 3 - * @max 20 - * @increment 1 - * @decimal 1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VEL_CRUISE, 10.f); - -/** - * Maximum velocity setpoint in Position mode - * - * @unit m/s - * @min 3 - * @max 20 - * @increment 1 - * @decimal 1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VEL_MANUAL, 10.f); - -/** - * Maximum collective thrust - * - * Limit allowed thrust - * - * @unit norm - * @min 0 - * @max 1 - * @decimal 2 - * @increment 0.05 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_THR_MAX, 1.f); - -/** - * Acceleration for autonomous and for manual modes - * - * When piloting manually, this parameter is only used in MPC_POS_MODE 4. - * - * @unit m/s^2 - * @min 2 - * @max 15 - * @decimal 1 - * @increment 1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_ACC, 3.f); - -/** - * Maximum accelaration in autonomous modes - * - * - * @unit m/s^2 - * @min 2 - * @max 15 - * @decimal 1 - * @increment 1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_ACC_MAX, 5.f); - -/** - * Jerk limit in autonomous modes - * - * Limit the maximum jerk of the vehicle (how fast the acceleration can change). - * A lower value leads to smoother vehicle motions but also limited agility. - * - * @unit m/s^3 - * @min 1 - * @max 80 - * @decimal 1 - * @increment 1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_JERK_AUTO, 4.f); - -PARAM_DEFINE_FLOAT(SPC_VEHICLE_RESP, 0.5f); -/** - * Maximum jerk in Position/Altitude mode - * - * Limit the maximum jerk of the vehicle (how fast the acceleration can change). - * A lower value leads to smoother motions but limits agility - * (how fast it can change directions or break). - * - * Setting this to the maximum value essentially disables the limit. - * - * Only used with smooth MPC_POS_MODE 3 and 4. - * - * @unit m/s^3 - * @min 0.5 - * @max 500 - * @decimal 0 - * @increment 1 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_JERK_MAX, 8.f); - -/** - * Max manual yaw rate for Stabilized, Altitude, Position mode - * - * @unit deg/s - * @min 0 - * @max 400 - * @decimal 0 - * @increment 10 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_MAN_Y_MAX, 150.f); - -/** - * Manual yaw rate input filter time constant - * - * Not used in Stabilized mode - * Setting this parameter to 0 disables the filter - * - * @unit s - * @min 0 - * @max 5 - * @decimal 2 - * @increment 0.01 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_MAN_Y_TAU, 0.08f); - -/** - * Numerical velocity derivative low pass cutoff frequency - * - * @unit Hz - * @min 0 - * @max 10 - * @decimal 1 - * @increment 0.5 - * @group Spacecraft Position Control - */ -PARAM_DEFINE_FLOAT(SPC_VELD_LP, 5.0f); diff --git a/src/modules/spacecraft/spacecraft_position_params.yaml b/src/modules/spacecraft/spacecraft_position_params.yaml new file mode 100644 index 0000000000..aa1bde9081 --- /dev/null +++ b/src/modules/spacecraft/spacecraft_position_params.yaml @@ -0,0 +1,224 @@ +module_name: spacecraft +parameters: +- group: Spacecraft Position Control + definitions: + SPC_POS_P: + description: + short: Proportional gain for position error + long: Defined as corrective velocity in m/s per m position error + type: float + default: 0.2 + min: 0 + max: 2 + decimal: 2 + increment: 0.1 + SPC_POS_I: + description: + short: Integral gain for position error + long: Defined as corrective velocity in m/s per m velocity error + type: float + default: 0.0 + min: 0 + max: 15 + decimal: 2 + increment: 0.1 + SPC_POS_I_LIM: + description: + short: Integral limit for position error + long: Defined as corrective velocity in m/s per m velocity error + type: float + default: 1.0 + min: 0 + max: 5 + decimal: 2 + increment: 0.01 + SPC_VEL_P: + description: + short: Proportional gain for velocity error + long: Defined as corrective acceleration in m/s^2 per m/s velocity error + type: float + default: 6.55 + min: 0 + max: 15 + decimal: 2 + increment: 0.1 + SPC_VEL_I: + description: + short: Integral gain for velocity error + long: Defined as corrective acceleration in m/s^2 per m/s velocity error + type: float + default: 0.0 + min: 0 + max: 15 + decimal: 2 + increment: 0.1 + SPC_VEL_I_LIM: + description: + short: Integral limit for velocity error + long: Defined as corrective acceleration in m/s^2 per m/s velocity error + type: float + default: 1.0 + min: 0 + max: 5 + decimal: 2 + increment: 0.1 + SPC_VEL_D: + description: + short: Derivative gain for velocity error + long: Defined as corrective acceleration in m/s^2 per m/s velocity error + type: float + default: 0.0 + min: 0.0 + max: 15 + decimal: 2 + increment: 0.1 + SPC_VEL_MAX: + description: + short: Maximum velocity + long: |- + Absolute maximum for all velocity controlled modes. + Any higher value is truncated. + type: float + default: 12.0 + unit: m/s + min: 0 + max: 20 + decimal: 1 + increment: 1 + SPC_VEL_ALL: + description: + short: Overall Velocity Limit + long: |- + If set to a value greater than zero, other parameters are automatically set (such as + MPC_VEL_MAX or MPC_VEL_MANUAL). + If set to a negative value, the existing individual parameters are used. + type: float + default: -10.0 + min: -20 + max: 20 + decimal: 1 + increment: 1 + SPC_VEL_CRUISE: + description: + short: Cruising elocity setpoint in autonomous modes + type: float + default: 10.0 + unit: m/s + min: 3 + max: 20 + increment: 1 + decimal: 1 + SPC_VEL_MANUAL: + description: + short: Maximum velocity setpoint in Position mode + type: float + default: 10.0 + unit: m/s + min: 3 + max: 20 + increment: 1 + decimal: 1 + SPC_THR_MAX: + description: + short: Maximum collective thrust + long: Limit allowed thrust + type: float + default: 1.0 + unit: norm + min: 0 + max: 1 + decimal: 2 + increment: 0.05 + SPC_ACC: + description: + short: Acceleration for autonomous and for manual modes + long: When piloting manually, this parameter is only used in MPC_POS_MODE + 4. + type: float + default: 3.0 + unit: m/s^2 + min: 2 + max: 15 + decimal: 1 + increment: 1 + SPC_ACC_MAX: + description: + short: Maximum accelaration in autonomous modes + type: float + default: 5.0 + unit: m/s^2 + min: 2 + max: 15 + decimal: 1 + increment: 1 + SPC_JERK_AUTO: + description: + short: Jerk limit in autonomous modes + long: |- + Limit the maximum jerk of the vehicle (how fast the acceleration can change). + A lower value leads to smoother vehicle motions but also limited agility. + type: float + default: 4.0 + unit: m/s^3 + min: 1 + max: 80 + decimal: 1 + increment: 1 + SPC_JERK_MAX: + description: + short: Maximum jerk in Position/Altitude mode + long: |- + Limit the maximum jerk of the vehicle (how fast the acceleration can change). + A lower value leads to smoother motions but limits agility + (how fast it can change directions or break). + + Setting this to the maximum value essentially disables the limit. + + Only used with smooth MPC_POS_MODE 3 and 4. + type: float + default: 8.0 + unit: m/s^3 + min: 0.5 + max: 500 + decimal: 0 + increment: 1 + SPC_MAN_Y_MAX: + description: + short: Max manual yaw rate for Stabilized, Altitude, Position mode + type: float + default: 150.0 + unit: deg/s + min: 0 + max: 400 + decimal: 0 + increment: 10 + SPC_MAN_Y_TAU: + description: + short: Manual yaw rate input filter time constant + long: |- + Not used in Stabilized mode + Setting this parameter to 0 disables the filter + type: float + default: 0.08 + unit: s + min: 0 + max: 5 + decimal: 2 + increment: 0.01 + SPC_VELD_LP: + description: + short: Numerical velocity derivative low pass cutoff frequency + type: float + default: 5.0 + unit: Hz + min: 0 + max: 10 + decimal: 1 + increment: 0.5 +- group: Miscellaneous + definitions: + SPC_VEHICLE_RESP: + description: + short: SPC_VEHICLE_RESP + type: float + default: 0.5 diff --git a/src/modules/spacecraft/spacecraft_rate_params.c b/src/modules/spacecraft/spacecraft_rate_params.c deleted file mode 100644 index 4afb818a42..0000000000 --- a/src/modules/spacecraft/spacecraft_rate_params.c +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2013-2025 PX4 Development Team. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name PX4 nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/** - * @file spacecraft_params.c - * Parameters for spacecraft vehicle type. - * - * @author Pedro Roque - */ - -/** - * Roll rate P gain - * - * Roll rate proportional gain, i.e. control output for angular speed error 1 rad/s. - * - * @min 0.01 - * @max 0.5 - * @decimal 3 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ROLLRATE_P, 0.15f); - -/** - * Roll rate I gain - * - * Roll rate integral gain. Can be set to compensate static thrust difference or gravity center offset. - * - * @min 0.0 - * @decimal 3 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ROLLRATE_I, 0.2f); - -/** - * Roll rate integrator limit - * - * Roll rate integrator limit. Can be set to increase the amount of integrator available to counteract disturbances or reduced to improve settling time after large roll moment trim changes. - * - * @min 0.0 - * @decimal 2 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_RR_INT_LIM, 0.30f); - -/** - * Roll rate D gain - * - * Roll rate differential gain. Small values help reduce fast oscillations. If value is too big oscillations will appear again. - * - * @min 0.0 - * @max 0.01 - * @decimal 4 - * @increment 0.0005 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ROLLRATE_D, 0.003f); - -/** - * Roll rate feedforward - * - * Improves tracking performance. - * - * @min 0.0 - * @decimal 4 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ROLLRATE_FF, 0.0f); - -/** - * Roll rate controller gain - * - * Global gain of the controller. - * - * This gain scales the P, I and D terms of the controller: - * output = SC_ROLLRATE_K * (SC_ROLLRATE_P * error - * + SC_ROLLRATE_I * error_integral - * + SC_ROLLRATE_D * error_derivative) - * Set SC_ROLLRATE_P=1 to implement a PID in the ideal form. - * Set SC_ROLLRATE_K=1 to implement a PID in the parallel form. - * - * @min 0.01 - * @max 5.0 - * @decimal 4 - * @increment 0.0005 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ROLLRATE_K, 1.0f); - -/** - * Pitch rate P gain - * - * Pitch rate proportional gain, i.e. control output for angular speed error 1 rad/s. - * - * @min 0.01 - * @max 0.6 - * @decimal 3 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_PITCHRATE_P, 0.15f); - -/** - * Pitch rate I gain - * - * Pitch rate integral gain. Can be set to compensate static thrust difference or gravity center offset. - * - * @min 0.0 - * @decimal 3 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_PITCHRATE_I, 0.2f); - -/** - * Pitch rate integrator limit - * - * Pitch rate integrator limit. Can be set to increase the amount of integrator available to counteract disturbances or reduced to improve settling time after large pitch moment trim changes. - * - * @min 0.0 - * @decimal 2 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_PR_INT_LIM, 0.30f); - -/** - * Pitch rate D gain - * - * Pitch rate differential gain. Small values help reduce fast oscillations. If value is too big oscillations will appear again. - * - * @min 0.0 - * @decimal 4 - * @increment 0.0005 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_PITCHRATE_D, 0.003f); - -/** - * Pitch rate feedforward - * - * Improves tracking performance. - * - * @min 0.0 - * @decimal 4 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_PITCHRATE_FF, 0.0f); - -/** - * Pitch rate controller gain - * - * Global gain of the controller. - * - * This gain scales the P, I and D terms of the controller: - * output = SC_PITCHRATE_K * (SC_PITCHRATE_P * error - * + SC_PITCHRATE_I * error_integral - * + SC_PITCHRATE_D * error_derivative) - * Set SC_PITCHRATE_P=1 to implement a PID in the ideal form. - * Set SC_PITCHRATE_K=1 to implement a PID in the parallel form. - * - * @min 0.01 - * @max 5.0 - * @decimal 4 - * @increment 0.0005 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_PITCHRATE_K, 1.0f); - -/** - * Yaw rate P gain - * - * Yaw rate proportional gain, i.e. control output for angular speed error 1 rad/s. - * - * @min 0.0 - * @max 10.0 - * @decimal 2 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_YAWRATE_P, 10.0f); - -/** - * Yaw rate I gain - * - * Yaw rate integral gain. Can be set to compensate static thrust difference or gravity center offset. - * - * @min 0.0 - * @decimal 2 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_YAWRATE_I, 0.865f); - -/** - * Yaw rate integrator limit - * - * Yaw rate integrator limit. Can be set to increase the amount of integrator available to counteract disturbances or reduced to improve settling time after large yaw moment trim changes. - * - * @min 0.0 - * @decimal 2 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_YR_INT_LIM, 0.2f); - -/** - * Yaw rate D gain - * - * Yaw rate differential gain. Small values help reduce fast oscillations. If value is too big oscillations will appear again. - * - * @min 0.0 - * @decimal 2 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_YAWRATE_D, 0.0f); - -/** - * Yaw rate feedforward - * - * Improves tracking performance. - * - * @min 0.0 - * @decimal 4 - * @increment 0.01 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_YAWRATE_FF, 0.0f); - -/** - * Yaw rate controller gain - * - * Global gain of the controller. - * - * This gain scales the P, I and D terms of the controller: - * output = SC_YAWRATE_K * (SC_YAWRATE_P * error - * + SC_YAWRATE_I * error_integral - * + SC_YAWRATE_D * error_derivative) - * Set SC_YAWRATE_P=1 to implement a PID in the ideal form. - * Set SC_YAWRATE_K=1 to implement a PID in the parallel form. - * - * @min 0.0 - * @max 5.0 - * @decimal 4 - * @increment 0.0005 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_YAWRATE_K, 1.0f); - -/** - * Max acro roll rate - * - * default: 2 turns per second - * - * @unit deg/s - * @min 0.0 - * @max 1800.0 - * @decimal 1 - * @increment 5 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ACRO_R_MAX, 720.0f); - -/** - * Max acro pitch rate - * - * default: 2 turns per second - * - * @unit deg/s - * @min 0.0 - * @max 1800.0 - * @decimal 1 - * @increment 5 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ACRO_P_MAX, 720.0f); - -/** - * Max acro yaw rate - * - * default 1.5 turns per second - * - * @unit deg/s - * @min 0.0 - * @max 1800.0 - * @decimal 1 - * @increment 5 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ACRO_Y_MAX, 540.0f); - -/** - * Acro mode Expo factor for Roll and Pitch. - * - * Exponential factor for tuning the input curve shape. - * - * 0 Purely linear input curve - * 1 Purely cubic input curve - * - * @min 0 - * @max 1 - * @decimal 2 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ACRO_EXPO, 0.69f); - -/** - * Acro mode Expo factor for Yaw. - * - * Exponential factor for tuning the input curve shape. - * - * 0 Purely linear input curve - * 1 Purely cubic input curve - * - * @min 0 - * @max 1 - * @decimal 2 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ACRO_EXPO_Y, 0.69f); - -/** - * Acro mode SuperExpo factor for Roll and Pitch. - * - * SuperExpo factor for refining the input curve shape tuned using SC_ACRO_EXPO. - * - * 0 Pure Expo function - * 0.7 reasonable shape enhancement for intuitive stick feel - * 0.95 very strong bent input curve only near maxima have effect - * - * @min 0 - * @max 0.95 - * @decimal 2 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ACRO_SUPEXPO, 0.7f); - -/** - * Acro mode SuperExpo factor for Yaw. - * - * SuperExpo factor for refining the input curve shape tuned using SC_ACRO_EXPO_Y. - * - * 0 Pure Expo function - * 0.7 reasonable shape enhancement for intuitive stick feel - * 0.95 very strong bent input curve only near maxima have effect - * - * @min 0 - * @max 0.95 - * @decimal 2 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_ACRO_SUPEXPOY, 0.7f); - -/** - * Battery power level scaler - * - * This compensates for voltage drop of the battery over time by attempting to - * normalize performance across the operating range of the battery. The copter - * should constantly behave as if it was fully charged with reduced max acceleration - * at lower battery percentages. i.e. if hover is at 0.5 throttle at 100% battery, - * it will still be 0.5 at 60% battery. - * - * @boolean - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_INT32(SC_BAT_SCALE_EN, 0); - -/** - * Manual mode maximum force. - * - * * - * @min 0 - * @max 1.0 - * @decimal 2 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_MAN_F_MAX, 1.0f); - -/** - * Manual mode maximum torque. - * - * * - * @min 0 - * @max 1.0 - * @decimal 2 - * @group Spacecraft Rate Control - */ -PARAM_DEFINE_FLOAT(SC_MAN_T_MAX, 1.0f); diff --git a/src/modules/spacecraft/spacecraft_rate_params.yaml b/src/modules/spacecraft/spacecraft_rate_params.yaml new file mode 100644 index 0000000000..fc4caf2668 --- /dev/null +++ b/src/modules/spacecraft/spacecraft_rate_params.yaml @@ -0,0 +1,326 @@ +module_name: spacecraft +parameters: +- group: Spacecraft Rate Control + definitions: + SC_ROLLRATE_P: + description: + short: Roll rate P gain + long: Roll rate proportional gain, i.e. control output for angular speed error + 1 rad/s. + type: float + default: 0.15 + min: 0.01 + max: 0.5 + decimal: 3 + increment: 0.01 + SC_ROLLRATE_I: + description: + short: Roll rate I gain + long: Roll rate integral gain. Can be set to compensate static thrust difference + or gravity center offset. + type: float + default: 0.2 + min: 0.0 + decimal: 3 + increment: 0.01 + SC_RR_INT_LIM: + description: + short: Roll rate integrator limit + long: Roll rate integrator limit. Can be set to increase the amount of integrator + available to counteract disturbances or reduced to improve settling time + after large roll moment trim changes. + type: float + default: 0.3 + min: 0.0 + decimal: 2 + increment: 0.01 + SC_ROLLRATE_D: + description: + short: Roll rate D gain + long: Roll rate differential gain. Small values help reduce fast oscillations. + If value is too big oscillations will appear again. + type: float + default: 0.003 + min: 0.0 + max: 0.01 + decimal: 4 + increment: 0.0005 + SC_ROLLRATE_FF: + description: + short: Roll rate feedforward + long: Improves tracking performance. + type: float + default: 0.0 + min: 0.0 + decimal: 4 + SC_ROLLRATE_K: + description: + short: Roll rate controller gain + long: |- + Global gain of the controller. + + This gain scales the P, I and D terms of the controller: + output = SC_ROLLRATE_K * (SC_ROLLRATE_P * error + + SC_ROLLRATE_I * error_integral + + SC_ROLLRATE_D * error_derivative) + Set SC_ROLLRATE_P=1 to implement a PID in the ideal form. + Set SC_ROLLRATE_K=1 to implement a PID in the parallel form. + type: float + default: 1.0 + min: 0.01 + max: 5.0 + decimal: 4 + increment: 0.0005 + SC_PITCHRATE_P: + description: + short: Pitch rate P gain + long: Pitch rate proportional gain, i.e. control output for angular speed + error 1 rad/s. + type: float + default: 0.15 + min: 0.01 + max: 0.6 + decimal: 3 + increment: 0.01 + SC_PITCHRATE_I: + description: + short: Pitch rate I gain + long: Pitch rate integral gain. Can be set to compensate static thrust difference + or gravity center offset. + type: float + default: 0.2 + min: 0.0 + decimal: 3 + increment: 0.01 + SC_PR_INT_LIM: + description: + short: Pitch rate integrator limit + long: Pitch rate integrator limit. Can be set to increase the amount of integrator + available to counteract disturbances or reduced to improve settling time + after large pitch moment trim changes. + type: float + default: 0.3 + min: 0.0 + decimal: 2 + increment: 0.01 + SC_PITCHRATE_D: + description: + short: Pitch rate D gain + long: Pitch rate differential gain. Small values help reduce fast oscillations. + If value is too big oscillations will appear again. + type: float + default: 0.003 + min: 0.0 + decimal: 4 + increment: 0.0005 + SC_PITCHRATE_FF: + description: + short: Pitch rate feedforward + long: Improves tracking performance. + type: float + default: 0.0 + min: 0.0 + decimal: 4 + SC_PITCHRATE_K: + description: + short: Pitch rate controller gain + long: |- + Global gain of the controller. + + This gain scales the P, I and D terms of the controller: + output = SC_PITCHRATE_K * (SC_PITCHRATE_P * error + + SC_PITCHRATE_I * error_integral + + SC_PITCHRATE_D * error_derivative) + Set SC_PITCHRATE_P=1 to implement a PID in the ideal form. + Set SC_PITCHRATE_K=1 to implement a PID in the parallel form. + type: float + default: 1.0 + min: 0.01 + max: 5.0 + decimal: 4 + increment: 0.0005 + SC_YAWRATE_P: + description: + short: Yaw rate P gain + long: Yaw rate proportional gain, i.e. control output for angular speed error + 1 rad/s. + type: float + default: 10.0 + min: 0.0 + max: 10.0 + decimal: 2 + increment: 0.01 + SC_YAWRATE_I: + description: + short: Yaw rate I gain + long: Yaw rate integral gain. Can be set to compensate static thrust difference + or gravity center offset. + type: float + default: 0.865 + min: 0.0 + decimal: 2 + increment: 0.01 + SC_YR_INT_LIM: + description: + short: Yaw rate integrator limit + long: Yaw rate integrator limit. Can be set to increase the amount of integrator + available to counteract disturbances or reduced to improve settling time + after large yaw moment trim changes. + type: float + default: 0.2 + min: 0.0 + decimal: 2 + increment: 0.01 + SC_YAWRATE_D: + description: + short: Yaw rate D gain + long: Yaw rate differential gain. Small values help reduce fast oscillations. + If value is too big oscillations will appear again. + type: float + default: 0.0 + min: 0.0 + decimal: 2 + increment: 0.01 + SC_YAWRATE_FF: + description: + short: Yaw rate feedforward + long: Improves tracking performance. + type: float + default: 0.0 + min: 0.0 + decimal: 4 + increment: 0.01 + SC_YAWRATE_K: + description: + short: Yaw rate controller gain + long: |- + Global gain of the controller. + + This gain scales the P, I and D terms of the controller: + output = SC_YAWRATE_K * (SC_YAWRATE_P * error + + SC_YAWRATE_I * error_integral + + SC_YAWRATE_D * error_derivative) + Set SC_YAWRATE_P=1 to implement a PID in the ideal form. + Set SC_YAWRATE_K=1 to implement a PID in the parallel form. + type: float + default: 1.0 + min: 0.0 + max: 5.0 + decimal: 4 + increment: 0.0005 + SC_ACRO_R_MAX: + description: + short: Max acro roll rate + long: 'default: 2 turns per second' + type: float + default: 720.0 + unit: deg/s + min: 0.0 + max: 1800.0 + decimal: 1 + increment: 5 + SC_ACRO_P_MAX: + description: + short: Max acro pitch rate + long: 'default: 2 turns per second' + type: float + default: 720.0 + unit: deg/s + min: 0.0 + max: 1800.0 + decimal: 1 + increment: 5 + SC_ACRO_Y_MAX: + description: + short: Max acro yaw rate + long: default 1.5 turns per second + type: float + default: 540.0 + unit: deg/s + min: 0.0 + max: 1800.0 + decimal: 1 + increment: 5 + SC_ACRO_EXPO: + description: + short: Acro mode Expo factor for Roll and Pitch + long: |- + Exponential factor for tuning the input curve shape. + + 0 Purely linear input curve + 1 Purely cubic input curve + type: float + default: 0.69 + min: 0 + max: 1 + decimal: 2 + SC_ACRO_EXPO_Y: + description: + short: Acro mode Expo factor for Yaw + long: |- + Exponential factor for tuning the input curve shape. + + 0 Purely linear input curve + 1 Purely cubic input curve + type: float + default: 0.69 + min: 0 + max: 1 + decimal: 2 + SC_ACRO_SUPEXPO: + description: + short: Acro mode SuperExpo factor for Roll and Pitch + long: |- + SuperExpo factor for refining the input curve shape tuned using SC_ACRO_EXPO. + + 0 Pure Expo function + 0.7 reasonable shape enhancement for intuitive stick feel + 0.95 very strong bent input curve only near maxima have effect + type: float + default: 0.7 + min: 0 + max: 0.95 + decimal: 2 + SC_ACRO_SUPEXPOY: + description: + short: Acro mode SuperExpo factor for Yaw + long: |- + SuperExpo factor for refining the input curve shape tuned using SC_ACRO_EXPO_Y. + + 0 Pure Expo function + 0.7 reasonable shape enhancement for intuitive stick feel + 0.95 very strong bent input curve only near maxima have effect + type: float + default: 0.7 + min: 0 + max: 0.95 + decimal: 2 + SC_BAT_SCALE_EN: + description: + short: Battery power level scaler + long: |- + This compensates for voltage drop of the battery over time by attempting to + normalize performance across the operating range of the battery. The copter + should constantly behave as if it was fully charged with reduced max acceleration + at lower battery percentages. i.e. if hover is at 0.5 throttle at 100% battery, + it will still be 0.5 at 60% battery. + type: boolean + default: 0 + SC_MAN_F_MAX: + description: + short: Manual mode maximum force + long: '*' + type: float + default: 1.0 + min: 0 + max: 1.0 + decimal: 2 + SC_MAN_T_MAX: + description: + short: Manual mode maximum torque + long: '*' + type: float + default: 1.0 + min: 0 + max: 1.0 + decimal: 2