diff --git a/src/modules/land_detector/LandDetector.cpp b/src/modules/land_detector/LandDetector.cpp index 6e2d107e92ee..2ea4c09e7227 100644 --- a/src/modules/land_detector/LandDetector.cpp +++ b/src/modules/land_detector/LandDetector.cpp @@ -57,11 +57,11 @@ LandDetector::LandDetector() : ModuleParams(nullptr), ScheduledWorkItem(px4::wq_configurations::hp_default) { - _landDetected.timestamp = hrt_absolute_time(); - _landDetected.freefall = false; - _landDetected.landed = true; - _landDetected.ground_contact = false; - _landDetected.maybe_landed = false; + _land_detected.timestamp = hrt_absolute_time(); + _land_detected.freefall = false; + _land_detected.landed = true; + _land_detected.ground_contact = false; + _land_detected.maybe_landed = false; } LandDetector::~LandDetector() @@ -95,30 +95,30 @@ void LandDetector::Run() const hrt_abstime now = hrt_absolute_time(); // publish at 1 Hz, very first time, or when the result has changed - if ((hrt_elapsed_time(&_landDetected.timestamp) >= 1_s) || + if ((hrt_elapsed_time(&_land_detected.timestamp) >= 1_s) || (_land_detected_pub == nullptr) || - (_landDetected.landed != landDetected) || - (_landDetected.freefall != freefallDetected) || - (_landDetected.maybe_landed != maybe_landedDetected) || - (_landDetected.ground_contact != ground_contactDetected) || - (_landDetected.in_ground_effect != in_ground_effect) || - (fabsf(_landDetected.alt_max - alt_max) > FLT_EPSILON)) { - - if (!landDetected && _landDetected.landed) { + (_land_detected.landed != landDetected) || + (_land_detected.freefall != freefallDetected) || + (_land_detected.maybe_landed != maybe_landedDetected) || + (_land_detected.ground_contact != ground_contactDetected) || + (_land_detected.in_ground_effect != in_ground_effect) || + (fabsf(_land_detected.alt_max - alt_max) > FLT_EPSILON)) { + + if (!landDetected && _land_detected.landed) { // We did take off _takeoff_time = now; } - _landDetected.timestamp = hrt_absolute_time(); - _landDetected.landed = landDetected; - _landDetected.freefall = freefallDetected; - _landDetected.maybe_landed = maybe_landedDetected; - _landDetected.ground_contact = ground_contactDetected; - _landDetected.alt_max = alt_max; - _landDetected.in_ground_effect = in_ground_effect; + _land_detected.timestamp = hrt_absolute_time(); + _land_detected.landed = landDetected; + _land_detected.freefall = freefallDetected; + _land_detected.maybe_landed = maybe_landedDetected; + _land_detected.ground_contact = ground_contactDetected; + _land_detected.alt_max = alt_max; + _land_detected.in_ground_effect = in_ground_effect; int instance; - orb_publish_auto(ORB_ID(vehicle_land_detected), &_land_detected_pub, &_landDetected, + orb_publish_auto(ORB_ID(vehicle_land_detected), &_land_detected_pub, &_land_detected, &instance, ORB_PRIO_DEFAULT); } diff --git a/src/modules/land_detector/LandDetector.h b/src/modules/land_detector/LandDetector.h index 9278307c7509..4fab8a80e6ff 100644 --- a/src/modules/land_detector/LandDetector.h +++ b/src/modules/land_detector/LandDetector.h @@ -143,7 +143,7 @@ class LandDetector : public ModuleBase, ModuleParams, px4::Schedul static constexpr uint32_t LAND_DETECTOR_UPDATE_INTERVAL = 20_ms; orb_advert_t _land_detected_pub{nullptr}; - vehicle_land_detected_s _landDetected{}; + vehicle_land_detected_s _land_detected{}; LandDetectionState _state{LandDetectionState::LANDED};