18 #include <mavros_msgs/GPSRAW.h> 19 #include <mavros_msgs/GPSRTK.h> 22 namespace extra_plugins {
23 using mavlink::common::RTK_BASELINE_COORDINATE_SYSTEM;
68 void handle_gps_raw_int(
const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS_RAW_INT &mav_msg) {
69 auto ros_msg = boost::make_shared<mavros_msgs::GPSRAW>();
71 ros_msg->fix_type = mav_msg.fix_type;
72 ros_msg->lat = mav_msg.lat;
73 ros_msg->lon = mav_msg.lon;
74 ros_msg->alt = mav_msg.alt;
75 ros_msg->eph = mav_msg.eph;
76 ros_msg->epv = mav_msg.epv;
77 ros_msg->vel = mav_msg.vel;
78 ros_msg->cog = mav_msg.cog;
79 ros_msg->satellites_visible = mav_msg.satellites_visible;
80 ros_msg->alt_ellipsoid = mav_msg.alt_ellipsoid;
81 ros_msg->h_acc = mav_msg.h_acc;
82 ros_msg->v_acc = mav_msg.v_acc;
83 ros_msg->vel_acc = mav_msg.vel_acc;
84 ros_msg->hdg_acc = mav_msg.hdg_acc;
85 ros_msg->dgps_numch = UINT8_MAX;
86 ros_msg->dgps_age = UINT32_MAX;
94 void handle_gps2_raw(
const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS2_RAW &mav_msg) {
95 auto ros_msg = boost::make_shared<mavros_msgs::GPSRAW>();
97 ros_msg->fix_type = mav_msg.fix_type;
98 ros_msg->lat = mav_msg.lat;
99 ros_msg->lon = mav_msg.lon;
100 ros_msg->alt = mav_msg.alt;
101 ros_msg->eph = mav_msg.eph;
102 ros_msg->epv = mav_msg.epv;
103 ros_msg->vel = mav_msg.vel;
104 ros_msg->cog = mav_msg.cog;
105 ros_msg->satellites_visible = mav_msg.satellites_visible;
106 ros_msg->alt_ellipsoid = INT32_MAX;
107 ros_msg->h_acc = UINT32_MAX;
108 ros_msg->v_acc = UINT32_MAX;
109 ros_msg->vel_acc = UINT32_MAX;
110 ros_msg->hdg_acc = UINT32_MAX;
111 ros_msg->dgps_numch = mav_msg.dgps_numch;
112 ros_msg->dgps_age = mav_msg.dgps_age;
120 void handle_gps_rtk(
const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS_RTK &mav_msg) {
121 auto ros_msg = boost::make_shared<mavros_msgs::GPSRTK>();
122 switch (static_cast<RTK_BASELINE_COORDINATE_SYSTEM>(mav_msg.baseline_coords_type))
124 case RTK_BASELINE_COORDINATE_SYSTEM::ECEF:
125 ros_msg->header.frame_id =
"earth";
127 case RTK_BASELINE_COORDINATE_SYSTEM::NED:
128 ros_msg->header.frame_id =
"map";
131 ROS_ERROR_NAMED(
"gps_status",
"GPS_RTK.baseline_coords_type MAVLink field has unknown \"%d\" value", mav_msg.baseline_coords_type);
134 ros_msg->rtk_receiver_id = mav_msg.rtk_receiver_id;
135 ros_msg->wn = mav_msg.wn;
136 ros_msg->tow = mav_msg.tow;
137 ros_msg->rtk_health = mav_msg.rtk_health;
138 ros_msg->rtk_rate = mav_msg.rtk_rate;
139 ros_msg->nsats = mav_msg.nsats;
140 ros_msg->baseline_a = mav_msg.baseline_a_mm;
141 ros_msg->baseline_b = mav_msg.baseline_b_mm;
142 ros_msg->baseline_c = mav_msg.baseline_c_mm;
143 ros_msg->accuracy = mav_msg.accuracy;
144 ros_msg->iar_num_hypotheses = mav_msg.iar_num_hypotheses;
152 void handle_gps2_rtk(
const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS2_RTK &mav_msg) {
153 auto ros_msg = boost::make_shared<mavros_msgs::GPSRTK>();
154 switch (static_cast<RTK_BASELINE_COORDINATE_SYSTEM>(mav_msg.baseline_coords_type))
156 case RTK_BASELINE_COORDINATE_SYSTEM::ECEF:
157 ros_msg->header.frame_id =
"earth";
159 case RTK_BASELINE_COORDINATE_SYSTEM::NED:
160 ros_msg->header.frame_id =
"map";
163 ROS_ERROR_NAMED(
"gps_status",
"GPS_RTK2.baseline_coords_type MAVLink field has unknown \"%d\" value", mav_msg.baseline_coords_type);
166 ros_msg->rtk_receiver_id = mav_msg.rtk_receiver_id;
167 ros_msg->wn = mav_msg.wn;
168 ros_msg->tow = mav_msg.tow;
169 ros_msg->rtk_health = mav_msg.rtk_health;
170 ros_msg->rtk_rate = mav_msg.rtk_rate;
171 ros_msg->nsats = mav_msg.nsats;
172 ros_msg->baseline_a = mav_msg.baseline_a_mm;
173 ros_msg->baseline_b = mav_msg.baseline_b_mm;
174 ros_msg->baseline_c = mav_msg.baseline_c_mm;
175 ros_msg->accuracy = mav_msg.accuracy;
176 ros_msg->iar_num_hypotheses = mav_msg.iar_num_hypotheses;
ros::NodeHandle gpsstatus_nh
std_msgs::Header synchronized_header(const std::string &frame_id, const T time_stamp)
void publish(const boost::shared_ptr< M > &message) const
void handle_gps_rtk(const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS_RTK &mav_msg)
Publish mavlink GPS_RTK message into the gps1/rtk topic.
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
void handle_gps2_raw(const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS2_RAW &mav_msg)
Publish mavlink GPS2_RAW message into the gps2/raw topic.
ros::Publisher gps1_rtk_pub
ros::Publisher gps2_raw_pub
ros::Publisher gps2_rtk_pub
void handle_gps2_rtk(const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS2_RTK &mav_msg)
Publish mavlink GPS2_RTK message into the gps2/rtk topic.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::vector< HandlerInfo > Subscriptions
ros::Publisher gps1_raw_pub
#define ROS_ERROR_NAMED(name,...)
Subscriptions get_subscriptions() override
void initialize(UAS &uas_) override
void initialize(UAS &uas_) override
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
void handle_gps_raw_int(const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS_RAW_INT &mav_msg)
Publish mavlink GPS_RAW_INT message into the gps1/raw topic.