I am using mavsdk::rtk.h to send rtcm messages to a Pixhawk 6C. Here is a part of code:
void subscribe_to_rtcm() {
rtcm_subscription_ = this->create_subscription<std_msgs::msg::String>(
rtcm_topic_, 10,
[this](const std_msgs::msg::String::SharedPtr msg) {
forward_to_pixhawk(msg->data);
});
}
void forward_to_pixhawk(const std::string& rtcm_data_str) {
mavsdk::Rtk::RtcmData rtcm_data;
rtcm_data.data = rtcm_data_str;
// Send RTCM data using the RTK plugin
Rtk::Result result = rtk_plugin_->send_rtcm_data(rtcm_data);
if (result == Rtk::Result::Success) {
RCLCPP_INFO(this->get_logger(), "RTCM data forwarded to Pixhawk: %zu bytes", rtcm_data_str.size());
} else {
RCLCPP_WARN(this->get_logger(), "Failed to forward RTCM data: %d", static_cast<int>(result));
}
}
But in logging the rtcm data size is not identical, What is the problem?
[INFO] [1739119220.793310883] [rtcm_base_node]: Published RTCM data of length: 256 bytes
[INFO] [1739119220.893626373] [rtcm_base_node]: Published RTCM data of length: 27 bytes
[INFO] [1739119221.075379546] [rtcm_base_node]: Published RTCM data of length: 144 bytes
[INFO] [1739119221.093328974] [rtcm_base_node]: Published RTCM data of length: 256 bytes
[INFO] [1739119221.193289930] [rtcm_base_node]: Published RTCM data of length: 256 bytes
[INFO] [1739119221.293425000] [rtcm_base_node]: Published RTCM data of length: 256 bytes
[INFO] [1739119221.393339313] [rtcm_base_node]: Published RTCM data of length: 256 bytes
[INFO] [1739119221.493329355] [rtcm_base_node]: Published RTCM data of length: 256 bytes
[INFO] [1739119221.593762593] [rtcm_base_node]: Published RTCM data of length: 256 bytes
[INFO] [1739119221.693307979] [rtcm_base_node]: Published RTCM data of length: 256 bytes
[INFO] [1739119210.293539628] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 256 bytes
[INFO] [1739119210.393929978] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 256 bytes
[INFO] [1739119210.493808059] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 168 bytes
[INFO] [1739119210.593585514] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 57 bytes
[INFO] [1739119210.693704616] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 15 bytes
[INFO] [1739119210.793863885] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 101 bytes
[INFO] [1739119210.893734223] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 1 bytes
[INFO] [1739119210.993963822] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 44 bytes
[INFO] [1739119211.093535019] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 0 bytes
[INFO] [1739119211.193466552] [rtcm_rover_node]: RTCM data forwarded to Pixhawk: 256 bytes