From e6031a97fa1c0bccb6abcf8c95da6ddadc457995 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Thu, 23 Feb 2017 10:42:11 +0100 Subject: [PATCH] land_detector: added a parameter for the manual land detection stick throshold because it is definitely something that needs to be allowed to tune or disable for different application scenarios --- .../land_detector/MulticopterLandDetector.cpp | 4 +++- .../land_detector/MulticopterLandDetector.h | 2 ++ src/modules/land_detector/land_detector_params.c | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/modules/land_detector/MulticopterLandDetector.cpp b/src/modules/land_detector/MulticopterLandDetector.cpp index 7c1c191dab..5e64325b72 100644 --- a/src/modules/land_detector/MulticopterLandDetector.cpp +++ b/src/modules/land_detector/MulticopterLandDetector.cpp @@ -78,6 +78,7 @@ MulticopterLandDetector::MulticopterLandDetector() : LandDetector(), _paramHandle.minManThrottle = param_find("MPC_MANTHR_MIN"); _paramHandle.freefall_acc_threshold = param_find("LNDMC_FFALL_THR"); _paramHandle.freefall_trigger_time = param_find("LNDMC_FFALL_TTRI"); + _paramHandle.manual_stick_down_threshold = param_find("LNDMC_MAN_DWNTHR"); } void MulticopterLandDetector::_initialize_topics() @@ -117,6 +118,7 @@ void MulticopterLandDetector::_update_params() param_get(_paramHandle.freefall_acc_threshold, &_params.freefall_acc_threshold); param_get(_paramHandle.freefall_trigger_time, &_params.freefall_trigger_time); _freefall_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1e6f * _params.freefall_trigger_time)); + param_get(_paramHandle.manual_stick_down_threshold, &_params.manual_stick_down_threshold); } @@ -158,7 +160,7 @@ bool MulticopterLandDetector::_get_ground_contact_state() // Check if user commands throttle and if so, report no ground contact based on // the user intent to take off (even if the system might physically still have // ground contact at this point). - const bool manual_control_idle = (_has_manual_control_present() && _manual.z < 0.15f); + const bool manual_control_idle = (_has_manual_control_present() && _manual.z < _params.manual_stick_down_threshold); const bool manual_control_idle_or_auto = manual_control_idle || !_control_mode.flag_control_manual_enabled; // Widen acceptance thresholds for landed state right after arming diff --git a/src/modules/land_detector/MulticopterLandDetector.h b/src/modules/land_detector/MulticopterLandDetector.h index 778679f218..fc9104dab9 100644 --- a/src/modules/land_detector/MulticopterLandDetector.h +++ b/src/modules/land_detector/MulticopterLandDetector.h @@ -89,6 +89,7 @@ private: param_t minManThrottle; param_t freefall_acc_threshold; param_t freefall_trigger_time; + param_t manual_stick_down_threshold; } _paramHandle; struct { @@ -101,6 +102,7 @@ private: float minManThrottle; float freefall_acc_threshold; float freefall_trigger_time; + float manual_stick_down_threshold; } _params; int _vehicleLocalPositionSub; diff --git a/src/modules/land_detector/land_detector_params.c b/src/modules/land_detector/land_detector_params.c index 89b03545c8..61a15eb1fb 100644 --- a/src/modules/land_detector/land_detector_params.c +++ b/src/modules/land_detector/land_detector_params.c @@ -119,6 +119,21 @@ PARAM_DEFINE_FLOAT(LNDMC_THR_RANGE, 0.1f); */ PARAM_DEFINE_FLOAT(LNDMC_FFALL_TTRI, 0.3); +/** + * Manual flight stick down threshold for landing + * + * When controlling manually the throttle stick value (0 to 1) + * has to be bellow this threshold in order to pass the check for landing. + * So if set to 1 it's allowed to land with any stick position. + * + * @min 0 + * @max 1 + * @decimal 2 + * + * @group Land Detector + */ +PARAM_DEFINE_FLOAT(LNDMC_MAN_DWNTHR, 0.15f); + /** * Fixedwing max horizontal velocity *