From 9e055e9b21ae18eff7aa2e292216e6b90c54a83e Mon Sep 17 00:00:00 2001 From: mcsauder Date: Sun, 30 Jun 2019 19:35:26 -0600 Subject: [PATCH] Implement ModuleParams inheritance in the VtolLandDetector class. Requires PR #12356. --- .../land_detector/MulticopterLandDetector.h | 1 + src/modules/land_detector/VtolLandDetector.cpp | 11 +---------- src/modules/land_detector/VtolLandDetector.h | 14 +++++--------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/modules/land_detector/MulticopterLandDetector.h b/src/modules/land_detector/MulticopterLandDetector.h index 8289c43b54..f079d88dea 100644 --- a/src/modules/land_detector/MulticopterLandDetector.h +++ b/src/modules/land_detector/MulticopterLandDetector.h @@ -84,6 +84,7 @@ private: /* get control mode dependent pilot throttle threshold with which we should quit landed state and take off */ float _get_takeoff_throttle(); + bool _has_low_thrust(); bool _has_minimal_thrust(); bool _has_altitude_lock(); diff --git a/src/modules/land_detector/VtolLandDetector.cpp b/src/modules/land_detector/VtolLandDetector.cpp index 99c77bddfc..14eef41427 100644 --- a/src/modules/land_detector/VtolLandDetector.cpp +++ b/src/modules/land_detector/VtolLandDetector.cpp @@ -48,13 +48,11 @@ namespace land_detector VtolLandDetector::VtolLandDetector() { - _paramHandle.maxAirSpeed = param_find("LNDFW_AIRSPD_MAX"); } void VtolLandDetector::_update_topics() { MulticopterLandDetector::_update_topics(); - _airspeed_sub.update(&_airspeed); _vehicle_status_sub.update(&_vehicle_status); } @@ -92,7 +90,7 @@ bool VtolLandDetector::_get_landed_state() // only consider airspeed if we have been in air before to avoid false // detections in the case of wind on the ground - if (_was_in_air && (_airspeed_filtered > _params.maxAirSpeed)) { + if (_was_in_air && (_airspeed_filtered > _param_lndfw_airspd_max.get())) { landed = false; } @@ -101,11 +99,4 @@ bool VtolLandDetector::_get_landed_state() return landed; } -void VtolLandDetector::_update_params() -{ - MulticopterLandDetector::_update_params(); - - param_get(_paramHandle.maxAirSpeed, &_params.maxAirSpeed); -} - } // namespace land_detector diff --git a/src/modules/land_detector/VtolLandDetector.h b/src/modules/land_detector/VtolLandDetector.h index 47f29f646f..d54541963a 100644 --- a/src/modules/land_detector/VtolLandDetector.h +++ b/src/modules/land_detector/VtolLandDetector.h @@ -56,19 +56,11 @@ public: VtolLandDetector(); protected: - void _update_params() override; void _update_topics() override; bool _get_landed_state() override; bool _get_maybe_landed_state() override; private: - struct { - param_t maxAirSpeed; - } _paramHandle{}; - - struct { - float maxAirSpeed; - } _params{}; uORB::Subscription _airspeed_sub{ORB_ID(airspeed)}; uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)}; @@ -78,7 +70,11 @@ private: bool _was_in_air{false}; /**< indicates whether the vehicle was in the air in the previous iteration */ float _airspeed_filtered{0.0f}; /**< low pass filtered airspeed */ + + DEFINE_PARAMETERS_CUSTOM_PARENT( + MulticopterLandDetector, + (ParamFloat) _param_lndfw_airspd_max + ); }; - } // namespace land_detector