18 #include <mavros_msgs/RTCM.h> 19 #include <mavros_msgs/RTKBaseline.h> 23 namespace extra_plugins {
66 mavlink::common::msg::GPS_RTCM_DATA rtcm_data = {};
67 const size_t max_frag_len = rtcm_data.data.size();
69 uint8_t seq_u5 = uint8_t(msg->header.seq & 0x1F) << 3;
71 if (msg->data.size() > 4 * max_frag_len) {
72 ROS_FATAL(
"gps_rtk: RTCM message received is bigger than the maximal possible size.");
76 auto data_it = msg->data.begin();
77 auto end_it = msg->data.end();
79 if (msg->data.size() <= max_frag_len) {
80 rtcm_data.len = msg->data.size();
81 rtcm_data.flags = seq_u5;
82 std::copy(data_it, end_it, rtcm_data.data.begin());
83 std::fill(rtcm_data.data.begin() + rtcm_data.len, rtcm_data.data.end(), 0);
86 for (uint8_t fragment_id = 0; fragment_id < 4 && data_it < end_it; fragment_id++) {
87 uint8_t
len = std::min((
size_t) std::distance(data_it, end_it), max_frag_len);
89 rtcm_data.flags |= fragment_id << 1;
90 rtcm_data.flags |= seq_u5;
93 std::copy(data_it, data_it + len, rtcm_data.data.begin());
94 std::fill(rtcm_data.data.begin() +
len, rtcm_data.data.end(), 0);
96 std::advance(data_it, len);
108 void handle_baseline_msg(
const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS_RTK &rtk_bsln )
113 rtk_baseline_.time_last_baseline_ms = rtk_bsln.time_last_baseline_ms;
114 rtk_baseline_.rtk_receiver_id = rtk_bsln.rtk_receiver_id;
115 rtk_baseline_.wn = rtk_bsln.wn;
116 rtk_baseline_.tow = rtk_bsln.tow;
117 rtk_baseline_.rtk_health = rtk_bsln.rtk_health;
118 rtk_baseline_.rtk_rate = rtk_bsln.rtk_rate;
119 rtk_baseline_.nsats = rtk_bsln.nsats;
120 rtk_baseline_.baseline_coords_type = rtk_bsln.baseline_coords_type;
121 rtk_baseline_.baseline_a_mm = rtk_bsln.baseline_a_mm;
122 rtk_baseline_.baseline_b_mm = rtk_bsln.baseline_b_mm;
123 rtk_baseline_.baseline_c_mm = rtk_bsln.baseline_c_mm;
124 rtk_baseline_.accuracy = rtk_bsln.accuracy;
125 rtk_baseline_.iar_num_hypotheses = rtk_bsln.iar_num_hypotheses;
128 rtk_baseline_pub_.
publish( rtk_baseline_ );
ros::Subscriber gps_rtk_sub
std::shared_ptr< MAVConnInterface const > ConstPtr
void handle_baseline_msg(const mavlink::mavlink_message_t *msg, mavlink::common::msg::GPS_RTK &rtk_bsln)
Publish GPS_RTK message (MAvlink Common) received from FCU. The message is already decoded by Mavlink...
void publish(const boost::shared_ptr< M > &message) const
mavros_msgs::RTKBaseline rtk_baseline_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Publisher rtk_baseline_pub_
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
void rtcm_cb(const mavros_msgs::RTCM::ConstPtr &msg)
Handle mavros_msgs::RTCM message It converts the message to the MAVLink GPS_RTCM_DATA message for GPS...
#define UAS_FCU(uasobjptr)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
Subscriptions get_subscriptions() override
void initialize(UAS &uas_) override
std::vector< HandlerInfo > Subscriptions
void initialize(UAS &uas_) override
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
ros::NodeHandle gps_rtk_nh