Skip to content

Commit 71e2f0c

Browse files
authored
Add support for forwarding RTCM correction data (#169)
1 parent 7c77ebc commit 71e2f0c

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

ublox_gps/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ find_package(std_msgs REQUIRED)
2525
find_package(tf2 REQUIRED)
2626
find_package(ublox_msgs REQUIRED)
2727
find_package(ublox_serialization REQUIRED)
28+
find_package(rtcm_msgs REQUIRED)
2829

2930
# build node
3031
add_library(ublox_gps
@@ -57,6 +58,7 @@ target_link_libraries(ublox_gps PUBLIC
5758
${rcl_interfaces_TARGETS}
5859
rclcpp::rclcpp
5960
rclcpp_components::component
61+
${rtcm_msgs_TARGETS}
6062
${sensor_msgs_TARGETS}
6163
${std_msgs_TARGETS}
6264
tf2::tf2

ublox_gps/include/ublox_gps/gps.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ class Gps final {
128128
*/
129129
void resetSerial(const std::string & port);
130130

131+
/**
132+
* @brief Send rtcm correction messages to the connected device.
133+
* @param message the RTCM correction data as a vector
134+
*/
135+
bool sendRtcm(const std::vector<uint8_t> &message);
136+
131137
/**
132138
* @brief Closes the I/O port, and initiates save on shutdown procedure
133139
* if enabled.

ublox_gps/include/ublox_gps/node.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <ublox_msgs/msg/cfg_cfg.hpp>
4242
#include <ublox_msgs/msg/cfg_dat.hpp>
4343
#include <ublox_msgs/msg/inf.h>
44+
#include <rtcm_msgs/msg/message.hpp>
4445
// Ublox GPS includes
4546
#include <ublox_gps/component_interface.hpp>
4647
#include <ublox_gps/fix_diagnostic.hpp>
@@ -136,6 +137,16 @@ class UbloxNode final : public rclcpp::Node {
136137

137138
private:
138139

140+
/**
141+
* @brief Callback for '/ntrip_client/rtcm' subscription to handle RTCM correction data
142+
*/
143+
void rtcmCallback(const rtcm_msgs::msg::Message::SharedPtr msg);
144+
145+
/**
146+
* @brief Subscription handler for RTCM data
147+
*/
148+
rclcpp::Subscription<rtcm_msgs::msg::Message>::SharedPtr subscription_;
149+
139150
/**
140151
* @brief Initialize the I/O handling.
141152
*/

ublox_gps/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<depend>tf2</depend>
2727
<depend>ublox_msgs</depend>
2828
<depend>ublox_serialization</depend>
29+
<depend>rtcm_msgs</depend>
2930

3031
<export>
3132
<build_type>ament_cmake</build_type>

ublox_gps/src/gps.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,11 @@ bool Gps::setUseAdr(bool enable) {
576576
return configure(msg);
577577
}
578578

579+
bool Gps::sendRtcm(const std::vector<uint8_t>& rtcm) {
580+
worker_->send(rtcm.data(), rtcm.size());
581+
return true;
582+
}
583+
579584
bool Gps::poll(uint8_t class_id, uint8_t message_id,
580585
const std::vector<uint8_t>& payload) {
581586
if (!worker_) {

ublox_gps/src/node.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ UbloxNode::UbloxNode(const rclcpp::NodeOptions & options) : rclcpp::Node("ublox_
190190
initialize();
191191
}
192192

193+
void UbloxNode::rtcmCallback(const rtcm_msgs::msg::Message::SharedPtr msg) {
194+
gps_->sendRtcm(msg->message);
195+
}
196+
193197
void UbloxNode::addFirmwareInterface() {
194198
int ublox_version;
195199
if (protocol_version_ < 14.0) {
@@ -483,6 +487,9 @@ void UbloxNode::getRosParams() {
483487
if (getRosBoolean(this, "publish.aid.hui")) {
484488
aid_hui_pub_ = this->create_publisher<ublox_msgs::msg::AidHUI>("aidhui", 1);
485489
}
490+
491+
// Create subscriber for RTCM correction data to enable RTK
492+
this->subscription_ = this->create_subscription<rtcm_msgs::msg::Message>("/rtcm", 10, std::bind(&UbloxNode::rtcmCallback, this, std::placeholders::_1));
486493
}
487494

488495
void UbloxNode::keepAlive() {

0 commit comments

Comments
 (0)