diff --git a/src/modules/land_detector/FixedwingLandDetector.cpp b/src/modules/land_detector/FixedwingLandDetector.cpp index acab306203..8e24c31655 100644 --- a/src/modules/land_detector/FixedwingLandDetector.cpp +++ b/src/modules/land_detector/FixedwingLandDetector.cpp @@ -68,6 +68,9 @@ FixedwingLandDetector::FixedwingLandDetector() : _paramHandle.maxClimbRate = param_find("LNDFW_VEL_Z_MAX"); _paramHandle.maxAirSpeed = param_find("LNDFW_AIRSPD_MAX"); _paramHandle.maxIntVelocity = param_find("LNDFW_VELI_MAX"); + + // Use Trigger time when transitioning from in-air (false) to landed (true) / ground contact (true). + _landed_hysteresis.set_hysteresis_time_from(false, LAND_DETECTOR_TRIGGER_TIME_US); } void FixedwingLandDetector::_initialize_topics() @@ -105,16 +108,15 @@ bool FixedwingLandDetector::_get_freefall_state() // TODO return false; } + bool FixedwingLandDetector::_get_ground_contact_state() { - // TODO return false; } bool FixedwingLandDetector::_get_maybe_landed_state() { - // TODO return false; } diff --git a/src/modules/land_detector/FixedwingLandDetector.h b/src/modules/land_detector/FixedwingLandDetector.h index dfcd847f46..c5b3be4d96 100644 --- a/src/modules/land_detector/FixedwingLandDetector.h +++ b/src/modules/land_detector/FixedwingLandDetector.h @@ -73,6 +73,10 @@ protected: virtual float _get_max_altitude() override; private: + + /** Time in us that landing conditions have to hold before triggering a land. */ + static constexpr uint64_t LAND_DETECTOR_TRIGGER_TIME_US = 1500000; + struct { param_t maxVelocity; param_t maxClimbRate; diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index d71898dee6..3b773c58a2 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -65,10 +65,6 @@ LandDetector::LandDetector() : _takeoff_time{0}, _work{} { - // Use Trigger time when transitioning from in-air (false) to landed (true) / ground contact (true). - _landed_hysteresis.set_hysteresis_time_from(false, LAND_DETECTOR_TRIGGER_TIME_US); - _maybe_landed_hysteresis.set_hysteresis_time_from(false, MAYBE_LAND_DETECTOR_TRIGGER_TIME_US); - _ground_contact_hysteresis.set_hysteresis_time_from(false, GROUND_CONTACT_TRIGGER_TIME_US); } LandDetector::~LandDetector() diff --git a/src/modules/land_detector/LandDetector.h b/src/modules/land_detector/LandDetector.h index 056d939aa3..250979eb3a 100644 --- a/src/modules/land_detector/LandDetector.h +++ b/src/modules/land_detector/LandDetector.h @@ -146,18 +146,6 @@ protected: /** Run main land detector loop at this rate in Hz. */ static constexpr uint32_t LAND_DETECTOR_UPDATE_RATE_HZ = 50; - /** Time in us that landing conditions have to hold before triggering a land. */ - static constexpr uint64_t LAND_DETECTOR_TRIGGER_TIME_US = 300000; - - /** Time in us that almost landing conditions have to hold before triggering almost landed . */ - static constexpr uint64_t MAYBE_LAND_DETECTOR_TRIGGER_TIME_US = 250000; - - /** Time in us that ground contact condition have to hold before triggering contact ground */ - static constexpr uint64_t GROUND_CONTACT_TRIGGER_TIME_US = 350000; - - /** Time interval in us in which wider acceptance thresholds are used after landed. */ - static constexpr uint64_t LAND_DETECTOR_LAND_PHASE_TIME_US = 2000000; - orb_advert_t _landDetectedPub; struct vehicle_land_detected_s _landDetected; diff --git a/src/modules/land_detector/MulticopterLandDetector.cpp b/src/modules/land_detector/MulticopterLandDetector.cpp index 4c95488ce4..fa018ff3f3 100644 --- a/src/modules/land_detector/MulticopterLandDetector.cpp +++ b/src/modules/land_detector/MulticopterLandDetector.cpp @@ -108,6 +108,11 @@ MulticopterLandDetector::MulticopterLandDetector() : _paramHandle.altitude_max = param_find("LNDMC_ALT_MAX"); _paramHandle.manual_stick_up_position_takeoff_threshold = param_find("LNDMC_POS_UPTHR"); _paramHandle.landSpeed = param_find("MPC_LAND_SPEED"); + + // Use Trigger time when transitioning from in-air (false) to landed (true) / ground contact (true). + _landed_hysteresis.set_hysteresis_time_from(false, LAND_DETECTOR_TRIGGER_TIME_US); + _maybe_landed_hysteresis.set_hysteresis_time_from(false, MAYBE_LAND_DETECTOR_TRIGGER_TIME_US); + _ground_contact_hysteresis.set_hysteresis_time_from(false, GROUND_CONTACT_TRIGGER_TIME_US); } void MulticopterLandDetector::_initialize_topics() diff --git a/src/modules/land_detector/MulticopterLandDetector.h b/src/modules/land_detector/MulticopterLandDetector.h index d9581d22af..7bbec9bf1d 100644 --- a/src/modules/land_detector/MulticopterLandDetector.h +++ b/src/modules/land_detector/MulticopterLandDetector.h @@ -82,6 +82,18 @@ protected: virtual float _get_max_altitude() override; private: + /** Time in us that landing conditions have to hold before triggering a land. */ + static constexpr uint64_t LAND_DETECTOR_TRIGGER_TIME_US = 300000; + + /** Time in us that almost landing conditions have to hold before triggering almost landed . */ + static constexpr uint64_t MAYBE_LAND_DETECTOR_TRIGGER_TIME_US = 250000; + + /** Time in us that ground contact condition have to hold before triggering contact ground */ + static constexpr uint64_t GROUND_CONTACT_TRIGGER_TIME_US = 350000; + + /** Time interval in us in which wider acceptance thresholds are used after landed. */ + static constexpr uint64_t LAND_DETECTOR_LAND_PHASE_TIME_US = 2000000; + /** * @brief Handles for interesting parameters **/