Browse Source

land_detector: do not publish if landing or freefall state has not changed

Signed-off-by: tumbili <roman@px4.io> and bkueng <beat-kueng@gmx.net>
sbg
tumbili 9 years ago
parent
commit
8026273cb0
  1. 18
      src/modules/land_detector/LandDetector.cpp

18
src/modules/land_detector/LandDetector.cpp

@ -103,17 +103,15 @@ void LandDetector::cycle()
} }
LandDetectionResult current_state = update(); LandDetectionResult current_state = update();
bool landDetected = (current_state == LANDDETECTION_RES_LANDED);
bool freefallDetected = (current_state == LANDDETECTION_RES_FREEFALL);
_landDetected.timestamp = hrt_absolute_time(); if (_landDetectedPub == nullptr || _landDetected.landed != landDetected || _landDetected.freefall != freefallDetected) {
_landDetected.landed = (current_state == LANDDETECTION_RES_LANDED); _landDetected.timestamp = hrt_absolute_time();
_landDetected.freefall = (current_state == LANDDETECTION_RES_FREEFALL); _landDetected.landed = (current_state == LANDDETECTION_RES_LANDED);
_landDetected.freefall = (current_state == LANDDETECTION_RES_FREEFALL);
// publish the land detected broadcast int instance;
if (_landDetectedPub == nullptr) { orb_publish_auto(ORB_ID(vehicle_land_detected), &_landDetectedPub, &_landDetected, &instance, ORB_PRIO_DEFAULT);
_landDetectedPub = orb_advertise(ORB_ID(vehicle_land_detected), &_landDetected);
} else {
orb_publish(ORB_ID(vehicle_land_detected), (orb_advert_t)_landDetectedPub, &_landDetected);
} }
if (!_taskShouldExit) { if (!_taskShouldExit) {

Loading…
Cancel
Save