diff --git a/src/modules/land_detector/MulticopterLandDetector.cpp b/src/modules/land_detector/MulticopterLandDetector.cpp index 615141d7be..e34a89287a 100644 --- a/src/modules/land_detector/MulticopterLandDetector.cpp +++ b/src/modules/land_detector/MulticopterLandDetector.cpp @@ -72,6 +72,7 @@ MulticopterLandDetector::MulticopterLandDetector() : LandDetector(), _paramHandle.maxRotation = param_find("LNDMC_ROT_MAX"); _paramHandle.maxVelocity = param_find("LNDMC_XY_VEL_MAX"); _paramHandle.maxClimbRate = param_find("LNDMC_Z_VEL_MAX"); + _paramHandle.throttleRange = param_find("LNDMC_THR_RANGE"); _paramHandle.minThrottle = param_find("MPC_THR_MIN"); _paramHandle.hoverThrottleAuto = param_find("MPC_THR_HOVER"); _paramHandle.minManThrottle = param_find("MPC_MANTHR_MIN"); @@ -111,6 +112,7 @@ void MulticopterLandDetector::_update_params() _params.maxRotation_rad_s = math::radians(_params.maxRotation_rad_s); param_get(_paramHandle.minThrottle, &_params.minThrottle); param_get(_paramHandle.hoverThrottleAuto, &_params.hoverThrottleAuto); + param_get(_paramHandle.throttleRange, &_params.throttleRange); param_get(_paramHandle.minManThrottle, &_params.minManThrottle); param_get(_paramHandle.freefall_acc_threshold, &_params.freefall_acc_threshold); param_get(_paramHandle.freefall_trigger_time, &_params.freefall_trigger_time); @@ -144,7 +146,8 @@ bool MulticopterLandDetector::_get_ground_contact_state() const uint64_t now = hrt_absolute_time(); // 10% of throttle range between min and hover - float sys_min_throttle = _params.minThrottle + (_params.hoverThrottleAuto - _params.minThrottle) * 0.1f; + float sys_min_throttle = _params.minThrottle + (_params.hoverThrottleAuto - _params.minThrottle) * + _params.throttleRange; // Determine the system min throttle based on flight mode if (!_control_mode.flag_control_altitude_enabled) { diff --git a/src/modules/land_detector/MulticopterLandDetector.h b/src/modules/land_detector/MulticopterLandDetector.h index e10528ccc7..8513a6f49b 100644 --- a/src/modules/land_detector/MulticopterLandDetector.h +++ b/src/modules/land_detector/MulticopterLandDetector.h @@ -85,6 +85,7 @@ private: param_t maxRotation; param_t minThrottle; param_t hoverThrottleAuto; + param_t throttleRange; param_t minManThrottle; param_t freefall_acc_threshold; param_t freefall_trigger_time; @@ -96,6 +97,7 @@ private: float maxRotation_rad_s; float minThrottle; float hoverThrottleAuto; + float throttleRange; float minManThrottle; float freefall_acc_threshold; float freefall_trigger_time; diff --git a/src/modules/land_detector/land_detector_params.c b/src/modules/land_detector/land_detector_params.c index 7ca07b8d2d..1297f45d60 100644 --- a/src/modules/land_detector/land_detector_params.c +++ b/src/modules/land_detector/land_detector_params.c @@ -88,6 +88,22 @@ PARAM_DEFINE_FLOAT(LNDMC_ROT_MAX, 20.0f); */ PARAM_DEFINE_FLOAT(LNDMC_FFALL_THR, 2.0f); +/** + * Multicopter sub-hover throttle scaling + * + * The range between throttle_min and throttle_hover is scaled + * by this parameter to define how close to minimum throttle + * the current throttle value needs to be in order to get + * accepted as landed. + * + * @min 0.05 + * @max 0.5 + * @decimal 2 + * + * @group Land Detector + */ +PARAM_DEFINE_FLOAT(LNDMC_THR_RANGE, 0.1f); + /** * Multicopter free-fall trigger time *