Skip to content

Commit

Permalink
LandDetector: switch to uORB::Publication
Browse files Browse the repository at this point in the history
  • Loading branch information
MaEtUgR authored and dagar committed Oct 16, 2019
1 parent 679e4fe commit 45a5372
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/modules/land_detector/LandDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ void LandDetector::Run()

// publish at 1 Hz, very first time, or when the result has changed
if ((hrt_elapsed_time(&_land_detected.timestamp) >= 1_s) ||
(_land_detected_pub == nullptr) ||
(_land_detected.landed != landDetected) ||
(_land_detected.freefall != freefallDetected) ||
(_land_detected.maybe_landed != maybe_landedDetected) ||
Expand All @@ -102,9 +101,7 @@ void LandDetector::Run()
_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, &_land_detected,
&instance, ORB_PRIO_DEFAULT);
_vehicle_land_detected_pub.publish(_land_detected);
}

// set the flight time when disarming (not necessarily when landed, because all param changes should
Expand Down
3 changes: 2 additions & 1 deletion src/modules/land_detector/LandDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include <px4_module_params.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <uORB/Subscription.hpp>
#include <uORB/Publication.hpp>
#include <uORB/topics/actuator_armed.h>
#include <uORB/topics/parameter_update.h>
#include <uORB/topics/sensor_bias.h>
Expand Down Expand Up @@ -157,7 +158,7 @@ class LandDetector : public ModuleBase<LandDetector>, ModuleParams, px4::Schedul
};
vehicle_local_position_s _vehicle_local_position{};

orb_advert_t _land_detected_pub{nullptr};
uORB::Publication<vehicle_land_detected_s> _vehicle_land_detected_pub{ORB_ID(vehicle_land_detected)};

uORB::Subscription _actuator_armed_sub{ORB_ID(actuator_armed)};
uORB::Subscription _vehicle_acceleration_sub{ORB_ID(vehicle_acceleration)};
Expand Down

0 comments on commit 45a5372

Please sign in to comment.