18 #include <mavros_msgs/RTCM.h> 22 namespace extra_plugins {
58 mavlink::common::msg::GPS_RTCM_DATA rtcm_data;
59 const size_t max_frag_len = rtcm_data.data.size();
61 uint8_t seq_u5 = uint8_t(msg->header.seq & 0x1F) << 3;
63 if (msg->data.size() > 4 * max_frag_len) {
64 ROS_FATAL(
"gps_rtk: RTCM message received is bigger than the maximal possible size.");
68 auto data_it = msg->data.begin();
69 auto end_it = msg->data.end();
71 if (msg->data.size() <= max_frag_len) {
72 rtcm_data.len = msg->data.size();
73 rtcm_data.flags = seq_u5;
74 std::copy(data_it, end_it, rtcm_data.data.begin());
75 std::fill(rtcm_data.data.begin() + rtcm_data.len, rtcm_data.data.end(), 0);
78 for (uint8_t fragment_id = 0; fragment_id < 4 && data_it < end_it; fragment_id++) {
79 uint8_t
len = std::min((
size_t) std::distance(data_it, end_it), max_frag_len);
81 rtcm_data.flags |= fragment_id << 1;
82 rtcm_data.flags |= seq_u5;
85 std::copy(data_it, data_it + len, rtcm_data.data.begin());
86 std::fill(rtcm_data.data.begin() +
len, rtcm_data.data.end(), 0);
88 std::advance(data_it, len);
ros::Subscriber gps_rtk_sub
std::shared_ptr< MAVConnInterface const > ConstPtr
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
Subscriptions get_subscriptions()
void initialize(UAS &uas_)
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)
std::vector< HandlerInfo > Subscriptions
void initialize(UAS &uas_)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
ros::NodeHandle gps_rtk_nh