From 0d4d988260435d2a9bca13dbaa7a95621f971d86 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 17 Mar 2026 21:55:34 -0800 Subject: [PATCH] refactor(land_detector): convert params.c to module.yaml Convert 3 parameter file(s) from legacy C format to YAML module configuration. --- src/modules/land_detector/CMakeLists.txt | 4 + .../land_detector/land_detector_params.c | 60 --------- .../land_detector/land_detector_params.yaml | 26 ++++ .../land_detector/land_detector_params_fw.c | 116 ------------------ .../land_detector_params_fw.yaml | 69 +++++++++++ .../land_detector/land_detector_params_mc.c | 86 ------------- .../land_detector_params_mc.yaml | 45 +++++++ 7 files changed, 144 insertions(+), 262 deletions(-) delete mode 100644 src/modules/land_detector/land_detector_params.c create mode 100644 src/modules/land_detector/land_detector_params.yaml delete mode 100644 src/modules/land_detector/land_detector_params_fw.c create mode 100644 src/modules/land_detector/land_detector_params_fw.yaml delete mode 100644 src/modules/land_detector/land_detector_params_mc.c create mode 100644 src/modules/land_detector/land_detector_params_mc.yaml diff --git a/src/modules/land_detector/CMakeLists.txt b/src/modules/land_detector/CMakeLists.txt index 6823df9f8b..9698bba0f0 100644 --- a/src/modules/land_detector/CMakeLists.txt +++ b/src/modules/land_detector/CMakeLists.txt @@ -42,6 +42,10 @@ px4_add_module( VtolLandDetector.cpp RoverLandDetector.cpp AirshipLandDetector.cpp + MODULE_CONFIG + land_detector_params.yaml + land_detector_params_fw.yaml + land_detector_params_mc.yaml DEPENDS hysteresis ) diff --git a/src/modules/land_detector/land_detector_params.c b/src/modules/land_detector/land_detector_params.c deleted file mode 100644 index 950956a92d..0000000000 --- a/src/modules/land_detector/land_detector_params.c +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2014-2016 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. - * - ****************************************************************************/ - -/** - * Total flight time in microseconds - * - * Total flight time of this autopilot. Higher 32 bits of the value. - * Flight time in microseconds = (LND_FLIGHT_T_HI << 32) | LND_FLIGHT_T_LO. - * - * @min 0 - * @volatile - * @category system - * @group Land Detector - * - */ -PARAM_DEFINE_INT32(LND_FLIGHT_T_HI, 0); - -/** - * Total flight time in microseconds - * - * Total flight time of this autopilot. Lower 32 bits of the value. - * Flight time in microseconds = (LND_FLIGHT_T_HI << 32) | LND_FLIGHT_T_LO. - * - * @min 0 - * @volatile - * @category system - * @group Land Detector - * - */ -PARAM_DEFINE_INT32(LND_FLIGHT_T_LO, 0); diff --git a/src/modules/land_detector/land_detector_params.yaml b/src/modules/land_detector/land_detector_params.yaml new file mode 100644 index 0000000000..f21cb1f199 --- /dev/null +++ b/src/modules/land_detector/land_detector_params.yaml @@ -0,0 +1,26 @@ +module_name: land_detector +parameters: +- group: Land Detector + definitions: + LND_FLIGHT_T_HI: + description: + short: Total flight time in microseconds + long: |- + Total flight time of this autopilot. Higher 32 bits of the value. + Flight time in microseconds = (LND_FLIGHT_T_HI << 32) | LND_FLIGHT_T_LO. + category: System + type: int32 + default: 0 + volatile: true + min: 0 + LND_FLIGHT_T_LO: + description: + short: Total flight time in microseconds + long: |- + Total flight time of this autopilot. Lower 32 bits of the value. + Flight time in microseconds = (LND_FLIGHT_T_HI << 32) | LND_FLIGHT_T_LO. + category: System + type: int32 + default: 0 + volatile: true + min: 0 diff --git a/src/modules/land_detector/land_detector_params_fw.c b/src/modules/land_detector/land_detector_params_fw.c deleted file mode 100644 index 7e438c388f..0000000000 --- a/src/modules/land_detector/land_detector_params_fw.c +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2014-2021 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. - * - ****************************************************************************/ - -/** - * Fixed-wing land detector: Max horizontal velocity threshold - * - * Maximum horizontal velocity allowed in the landed state. - * A factor of 0.7 is applied in case of airspeed-less flying - * (either because no sensor is present or sensor data got invalid in flight). - * - * @unit m/s - * @min 0.5 - * @max 20 - * @decimal 1 - * - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDFW_VEL_XY_MAX, 5.0f); - -/** - * Fixed-wing land detector: Max vertiacal velocity threshold - * - * Maximum vertical velocity allowed in the landed state. - * - * @unit m/s - * @min 0.1 - * @max 20 - * @decimal 1 - * - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDFW_VEL_Z_MAX, 1.0f); - -/** - * Fixed-wing land detector: Max horizontal acceleration - * - * Maximum horizontal (x,y body axes) acceleration allowed in the landed state - * - * @unit m/s^2 - * @min 2 - * @max 30 - * @decimal 1 - * - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDFW_XYACC_MAX, 8.0f); - -/** - * Fixed-wing land detector: Max airspeed - * - * Maximum airspeed allowed in the landed state - * - * @unit m/s - * @min 2 - * @max 30 - * @decimal 1 - * - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDFW_AIRSPD_MAX, 6.00f); - -/** - * Fixed-wing land detection trigger time - * - * Time the land conditions (speeds and acceleration) have to be satisfied to detect a landing. - * - * @unit s - * @min 0.1 - * @decimal 1 - * - * @reboot_required true - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDFW_TRIG_TIME, 2.f); - -/** - * Fixed-wing land detector: max rotational speed - * - * Maximum allowed norm of the angular velocity in the landed state. - * Only used if neither airspeed nor groundspeed can be used for landing detection. - * - * @unit deg/s - * @decimal 1 - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDFW_ROT_MAX, 0.5f); diff --git a/src/modules/land_detector/land_detector_params_fw.yaml b/src/modules/land_detector/land_detector_params_fw.yaml new file mode 100644 index 0000000000..a02aa28552 --- /dev/null +++ b/src/modules/land_detector/land_detector_params_fw.yaml @@ -0,0 +1,69 @@ +module_name: land_detector +parameters: +- group: Land Detector + definitions: + LNDFW_VEL_XY_MAX: + description: + short: 'Fixed-wing land detector: Max horizontal velocity threshold' + long: |- + Maximum horizontal velocity allowed in the landed state. + A factor of 0.7 is applied in case of airspeed-less flying + (either because no sensor is present or sensor data got invalid in flight). + type: float + default: 5.0 + unit: m/s + min: 0.5 + max: 20 + decimal: 1 + LNDFW_VEL_Z_MAX: + description: + short: 'Fixed-wing land detector: Max vertiacal velocity threshold' + long: Maximum vertical velocity allowed in the landed state. + type: float + default: 1.0 + unit: m/s + min: 0.1 + max: 20 + decimal: 1 + LNDFW_XYACC_MAX: + description: + short: 'Fixed-wing land detector: Max horizontal acceleration' + long: Maximum horizontal (x,y body axes) acceleration allowed in the landed + state + type: float + default: 8.0 + unit: m/s^2 + min: 2 + max: 30 + decimal: 1 + LNDFW_AIRSPD_MAX: + description: + short: 'Fixed-wing land detector: Max airspeed' + long: Maximum airspeed allowed in the landed state + type: float + default: 6.0 + unit: m/s + min: 2 + max: 30 + decimal: 1 + LNDFW_TRIG_TIME: + description: + short: Fixed-wing land detection trigger time + long: Time the land conditions (speeds and acceleration) have to be satisfied + to detect a landing. + type: float + default: 2.0 + unit: s + min: 0.1 + decimal: 1 + reboot_required: true + LNDFW_ROT_MAX: + description: + short: 'Fixed-wing land detector: max rotational speed' + long: |- + Maximum allowed norm of the angular velocity in the landed state. + Only used if neither airspeed nor groundspeed can be used for landing detection. + type: float + default: 0.5 + unit: deg/s + decimal: 1 diff --git a/src/modules/land_detector/land_detector_params_mc.c b/src/modules/land_detector/land_detector_params_mc.c deleted file mode 100644 index 43786f78fb..0000000000 --- a/src/modules/land_detector/land_detector_params_mc.c +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2014-2016 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. - * - ****************************************************************************/ - -/** - * Multicopter vertical velocity threshold - * - * Vertical velocity threshold to detect landing. - * Has to be set lower than the expected minimal speed for landing, - * which is either MPC_LAND_SPEED or MPC_LAND_CRWL. - * This is enforced by an automatic check. - * - * @unit m/s - * @min 0 - * @decimal 2 - * - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDMC_Z_VEL_MAX, 0.25f); - -/** - * Multicopter max horizontal velocity - * - * Maximum horizontal velocity allowed in the landed state - * - * @unit m/s - * @decimal 1 - * - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDMC_XY_VEL_MAX, 1.5f); - -/** - * Multicopter max rotational speed - * - * Maximum allowed norm of the angular velocity (roll, pitch) in the landed state. - * - * @unit deg/s - * @decimal 1 - * - * @group Land Detector - */ -PARAM_DEFINE_FLOAT(LNDMC_ROT_MAX, 20.0f); - -/** - * Ground effect altitude for multicopters - * - * The height above ground below which ground effect creates barometric altitude errors. - * A negative value indicates no ground effect. - * - * @unit m - * @min -1 - * @decimal 2 - * @group Land Detector - * - */ -PARAM_DEFINE_FLOAT(LNDMC_ALT_GND, 2.f); diff --git a/src/modules/land_detector/land_detector_params_mc.yaml b/src/modules/land_detector/land_detector_params_mc.yaml new file mode 100644 index 0000000000..26807d5610 --- /dev/null +++ b/src/modules/land_detector/land_detector_params_mc.yaml @@ -0,0 +1,45 @@ +module_name: land_detector +parameters: +- group: Land Detector + definitions: + LNDMC_Z_VEL_MAX: + description: + short: Multicopter vertical velocity threshold + long: |- + Vertical velocity threshold to detect landing. + Has to be set lower than the expected minimal speed for landing, + which is either MPC_LAND_SPEED or MPC_LAND_CRWL. + This is enforced by an automatic check. + type: float + default: 0.25 + unit: m/s + min: 0 + decimal: 2 + LNDMC_XY_VEL_MAX: + description: + short: Multicopter max horizontal velocity + long: Maximum horizontal velocity allowed in the landed state + type: float + default: 1.5 + unit: m/s + decimal: 1 + LNDMC_ROT_MAX: + description: + short: Multicopter max rotational speed + long: Maximum allowed norm of the angular velocity (roll, pitch) in the landed + state. + type: float + default: 20.0 + unit: deg/s + decimal: 1 + LNDMC_ALT_GND: + description: + short: Ground effect altitude for multicopters + long: |- + The height above ground below which ground effect creates barometric altitude errors. + A negative value indicates no ground effect. + type: float + default: 2.0 + unit: m + min: -1 + decimal: 2