Skip to content
Snippets Groups Projects
Commit 8026273c authored by tumbili's avatar tumbili
Browse files

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

parent 7dea8d4a
No related branches found
No related tags found
No related merge requests found
......@@ -103,17 +103,15 @@ void LandDetector::cycle()
}
LandDetectionResult current_state = update();
bool landDetected = (current_state == LANDDETECTION_RES_LANDED);
bool freefallDetected = (current_state == LANDDETECTION_RES_FREEFALL);
_landDetected.timestamp = hrt_absolute_time();
_landDetected.landed = (current_state == LANDDETECTION_RES_LANDED);
_landDetected.freefall = (current_state == LANDDETECTION_RES_FREEFALL);
// publish the land detected broadcast
if (_landDetectedPub == nullptr) {
_landDetectedPub = orb_advertise(ORB_ID(vehicle_land_detected), &_landDetected);
} else {
orb_publish(ORB_ID(vehicle_land_detected), (orb_advert_t)_landDetectedPub, &_landDetected);
if (_landDetectedPub == nullptr || _landDetected.landed != landDetected || _landDetected.freefall != freefallDetected) {
_landDetected.timestamp = hrt_absolute_time();
_landDetected.landed = (current_state == LANDDETECTION_RES_LANDED);
_landDetected.freefall = (current_state == LANDDETECTION_RES_FREEFALL);
int instance;
orb_publish_auto(ORB_ID(vehicle_land_detected), &_landDetectedPub, &_landDetected, &instance, ORB_PRIO_DEFAULT);
}
if (!_taskShouldExit) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment