land detector initialize landed and publish periodically

This commit is contained in:
Daniel Agar 2018-01-17 10:20:17 -05:00 committed by Lorenz Meier
parent fd3f59d8c4
commit 2ae5e575a5
1 changed files with 4 additions and 3 deletions

View File

@ -82,7 +82,7 @@ void LandDetector::_cycle()
// Advertise the first land detected uORB. // Advertise the first land detected uORB.
_landDetected.timestamp = hrt_absolute_time(); _landDetected.timestamp = hrt_absolute_time();
_landDetected.freefall = false; _landDetected.freefall = false;
_landDetected.landed = false; _landDetected.landed = true;
_landDetected.ground_contact = false; _landDetected.ground_contact = false;
_landDetected.maybe_landed = false; _landDetected.maybe_landed = false;
@ -111,8 +111,9 @@ void LandDetector::_cycle()
const hrt_abstime now = hrt_absolute_time(); const hrt_abstime now = hrt_absolute_time();
// Only publish very first time or when the result has changed. // publish at 1 Hz, very first time, or when the result has changed
if ((_landDetectedPub == nullptr) || if ((hrt_elapsed_time(&_landDetected.timestamp) >= 1000000) ||
(_landDetectedPub == nullptr) ||
(_landDetected.landed != landDetected) || (_landDetected.landed != landDetected) ||
(_landDetected.freefall != freefallDetected) || (_landDetected.freefall != freefallDetected) ||
(_landDetected.maybe_landed != maybe_landedDetected) || (_landDetected.maybe_landed != maybe_landedDetected) ||