mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
gps driver update orb_publish usage to uORB::PublicationMulti<>
This commit is contained in:
parent
6f512cc2f1
commit
349739b812
@ -54,6 +54,7 @@
|
||||
#include <px4_platform_common/getopt.h>
|
||||
#include <px4_platform_common/module.h>
|
||||
#include <uORB/PublicationQueued.hpp>
|
||||
#include <uORB/PublicationMulti.hpp>
|
||||
#include <uORB/Subscription.hpp>
|
||||
#include <uORB/topics/gps_dump.h>
|
||||
#include <uORB/topics/gps_inject_data.h>
|
||||
@ -161,11 +162,8 @@ private:
|
||||
vehicle_gps_position_s _report_gps_pos{}; ///< uORB topic for gps position
|
||||
satellite_info_s *_p_report_sat_info{nullptr}; ///< pointer to uORB topic for satellite info
|
||||
|
||||
orb_advert_t _report_gps_pos_pub{nullptr}; ///< uORB pub for gps position
|
||||
orb_advert_t _report_sat_info_pub{nullptr}; ///< uORB pub for satellite info
|
||||
|
||||
int _gps_orb_instance{-1}; ///< uORB multi-topic instance
|
||||
int _gps_sat_orb_instance{-1}; ///< uORB multi-topic instance for satellite info
|
||||
uORB::PublicationMulti<vehicle_gps_position_s> _report_gps_pos_pub{ORB_ID(vehicle_gps_position)}; ///< uORB pub for gps position
|
||||
uORB::PublicationMulti<satellite_info_s> _report_sat_info_pub{ORB_ID(satellite_info)}; ///< uORB pub for satellite info
|
||||
|
||||
float _rate{0.0f}; ///< position update rate
|
||||
float _rate_rtcm_injection{0.0f}; ///< RTCM message injection rate
|
||||
@ -837,8 +835,6 @@ GPS::run()
|
||||
::close(_serial_fd);
|
||||
_serial_fd = -1;
|
||||
}
|
||||
|
||||
orb_unadvertise(_report_gps_pos_pub);
|
||||
}
|
||||
|
||||
int
|
||||
@ -946,8 +942,7 @@ void
|
||||
GPS::publish()
|
||||
{
|
||||
if (_instance == Instance::Main || _is_gps_main_advertised) {
|
||||
orb_publish_auto(ORB_ID(vehicle_gps_position), &_report_gps_pos_pub, &_report_gps_pos, &_gps_orb_instance,
|
||||
ORB_PRIO_DEFAULT);
|
||||
_report_gps_pos_pub.publish(_report_gps_pos);
|
||||
// Heading/yaw data can be updated at a lower rate than the other navigation data.
|
||||
// The uORB message definition requires this data to be set to a NAN if no new valid data is available.
|
||||
_report_gps_pos.heading = NAN;
|
||||
@ -959,8 +954,9 @@ void
|
||||
GPS::publishSatelliteInfo()
|
||||
{
|
||||
if (_instance == Instance::Main) {
|
||||
orb_publish_auto(ORB_ID(satellite_info), &_report_sat_info_pub, _p_report_sat_info, &_gps_sat_orb_instance,
|
||||
ORB_PRIO_DEFAULT);
|
||||
if (_p_report_sat_info != nullptr) {
|
||||
_report_sat_info_pub.publish(*_p_report_sat_info);
|
||||
}
|
||||
|
||||
} else {
|
||||
//we don't publish satellite info for the secondary gps
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user